summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-12-14 21:22:48 +0000
committerEric Fiselier <eric@efcs.ca>2016-12-14 21:22:48 +0000
commitfec6be9c8150244c98bc2ac2bcac326fce49001a (patch)
tree23d8acc333ee89e05185255cb63ac2b9d89b035f /libcxx/test/std
parent906534fe4e702cff11d2d3478c868fe2eb2ec088 (diff)
downloadbcm5719-llvm-fec6be9c8150244c98bc2ac2bcac326fce49001a.tar.gz
bcm5719-llvm-fec6be9c8150244c98bc2ac2bcac326fce49001a.zip
Recommit r286884: P0503R0, adopted in Issaquah, rewords some requirements on nullptr_t and istream_iterator.
No code changes were needed, but I updated a few tests. Also resolved P0509 and P0521, which required no changes to the library or tests. This patch was reverted due to llvm.org/PR31016. There is a bug in Clang 3.7 which causes default.pass.cpp to fails. That test is now marked as XFAIL for that clang version. This patch was originally authored by Marshall Clow. llvm-svn: 289708
Diffstat (limited to 'libcxx/test/std')
-rw-r--r--libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp4
-rw-r--r--libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp31
-rw-r--r--libcxx/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp15
3 files changed, 47 insertions, 3 deletions
diff --git a/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp
index 0d70c7fc9ed..7f807b63e3c 100644
--- a/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp
+++ b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp
@@ -12,11 +12,15 @@
// class istream_iterator
// istream_iterator(const istream_iterator& x);
+// C++17 says: If is_trivially_copy_constructible_v<T> is true, then
+// this constructor shall beis a trivial copy constructor.
#include <iterator>
#include <sstream>
#include <cassert>
+#include "test_macros.h"
+
int main()
{
{
diff --git a/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
index c1924e4b927..745b08cbd73 100644
--- a/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
+++ b/libcxx/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
@@ -7,17 +7,41 @@
//
//===----------------------------------------------------------------------===//
+// Usage of is_trivially_constructible is broken with these compilers.
+// See https://llvm.org/bugs/show_bug.cgi?id=31016
+// XFAIL: clang-3.7
+
// <iterator>
// class istream_iterator
// constexpr istream_iterator();
+// C++17 says: If is_trivially_default_constructible_v<T> is true, then this
+// constructor shall beis a constexpr constructor.
#include <iterator>
#include <cassert>
+#include <string>
#include "test_macros.h"
+struct S { S(); }; // not constexpr
+
+#if TEST_STD_VER > 14
+template <typename T, bool isTrivial = std::is_trivially_default_constructible_v<T>>
+struct test_trivial {
+void operator ()() const {
+ constexpr std::istream_iterator<T> it;
+ }
+};
+
+template <typename T>
+struct test_trivial<T, false> {
+void operator ()() const {}
+};
+#endif
+
+
int main()
{
{
@@ -29,4 +53,11 @@ int main()
#endif
}
+#if TEST_STD_VER > 14
+ test_trivial<int>()();
+ test_trivial<char>()();
+ test_trivial<double>()();
+ test_trivial<S>()();
+ test_trivial<std::string>()();
+#endif
}
diff --git a/libcxx/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
index 1250e364d35..b1bf75b1195 100644
--- a/libcxx/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
+++ b/libcxx/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
@@ -23,9 +23,18 @@
// typedef basic_istream<charT,traits> istream_type;
// ...
//
+// Before C++17, we have:
// If T is a literal type, then the default constructor shall be a constexpr constructor.
// If T is a literal type, then this constructor shall be a trivial copy constructor.
// If T is a literal type, then this destructor shall be a trivial destructor.
+// C++17 says:
+// If is_trivially_default_constructible_v<T> is true, then
+// this constructor (the default ctor) shall beis a constexpr constructor.
+// If is_trivially_copy_constructible_v<T> is true, then
+// this constructor (the copy ctor) shall beis a trivial copy constructor.
+// If is_trivially_destructible_v<T> is true, then this
+// destructor shall beis a trivial destructor.
+// Testing the C++17 ctors for this are in the ctor tests.
#include <iterator>
#include <type_traits>
@@ -33,7 +42,7 @@
int main()
{
- typedef std::istream_iterator<double> I1;
+ typedef std::istream_iterator<double> I1; // double is trivially destructible
static_assert((std::is_convertible<I1,
std::iterator<std::input_iterator_tag, double, std::ptrdiff_t,
const double*, const double&> >::value), "");
@@ -43,7 +52,7 @@ int main()
static_assert( std::is_trivially_copy_constructible<I1>::value, "");
static_assert( std::is_trivially_destructible<I1>::value, "");
- typedef std::istream_iterator<unsigned, wchar_t> I2;
+ typedef std::istream_iterator<unsigned, wchar_t> I2; // unsigned is trivially destructible
static_assert((std::is_convertible<I2,
std::iterator<std::input_iterator_tag, unsigned, std::ptrdiff_t,
const unsigned*, const unsigned&> >::value), "");
@@ -53,7 +62,7 @@ int main()
static_assert( std::is_trivially_copy_constructible<I2>::value, "");
static_assert( std::is_trivially_destructible<I2>::value, "");
- typedef std::istream_iterator<std::string> I3;
+ typedef std::istream_iterator<std::string> I3; // string is NOT trivially destructible
static_assert(!std::is_trivially_copy_constructible<I3>::value, "");
static_assert(!std::is_trivially_destructible<I3>::value, "");
}
OpenPOWER on IntegriCloud