summaryrefslogtreecommitdiffstats
path: root/libcxx/test
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2014-10-15 10:33:02 +0000
committerMarshall Clow <mclow.lists@gmail.com>2014-10-15 10:33:02 +0000
commit14c5ec51945be51c55c58cc4d2a1e4f1cfb56533 (patch)
treecdc19eebb6caa83c76ca46cd352e0cf4c0d0c6c3 /libcxx/test
parent6373829449e48634ae7548e3a5e9c2869b104d32 (diff)
downloadbcm5719-llvm-14c5ec51945be51c55c58cc4d2a1e4f1cfb56533.tar.gz
bcm5719-llvm-14c5ec51945be51c55c58cc4d2a1e4f1cfb56533.zip
Fixes PR21157 'tuple: non-default constructible tuple hard failure' Thanks to Louis Dionne for the bug report and the patch.
llvm-svn: 219785
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp11
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp17
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp28
3 files changed, 56 insertions, 0 deletions
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp
index d6fbdae835a..7359d77c054 100644
--- a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp
@@ -16,6 +16,7 @@
#include <tuple>
#include <cassert>
+#include <type_traits>
#include "../MoveOnly.h"
@@ -30,6 +31,8 @@ struct A
#endif
+struct NoDefault { NoDefault() = delete; };
+
int main()
{
{
@@ -63,6 +66,14 @@ int main()
assert(std::get<1>(t) == MoveOnly());
assert(std::get<2>(t) == MoveOnly());
}
+ {
+ // Make sure the _Up... constructor SFINAEs out when the types that
+ // are not explicitly initialized are not all default constructible.
+ // Otherwise, std::is_constructible would return true but instantiating
+ // the constructor would fail.
+ static_assert(!std::is_constructible<std::tuple<MoveOnly, NoDefault>, MoveOnly>(), "");
+ static_assert(!std::is_constructible<std::tuple<MoveOnly, MoveOnly, NoDefault>, MoveOnly, MoveOnly>(), "");
+ }
#if _LIBCPP_STD_VER > 11
{
constexpr std::tuple<Empty> t0{Empty()};
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
index 667c4dd803c..97469869dff 100644
--- a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
@@ -22,6 +22,8 @@
#include "../alloc_first.h"
#include "../alloc_last.h"
+struct NoDefault { NoDefault() = delete; };
+
int main()
{
{
@@ -68,4 +70,19 @@ int main()
assert(std::get<1>(t) == MoveOnly());
assert(std::get<2>(t) == MoveOnly());
}
+ {
+ // Make sure the _Up... constructor SFINAEs out when the types that
+ // are not explicitly initialized are not all default constructible.
+ // Otherwise, std::is_constructible would return true but instantiating
+ // the constructor would fail.
+ static_assert(!std::is_constructible<
+ std::tuple<MoveOnly, NoDefault>,
+ std::allocator_arg_t, A1<int>, MoveOnly
+ >::value, "");
+
+ static_assert(!std::is_constructible<
+ std::tuple<MoveOnly, MoveOnly, NoDefault>,
+ std::allocator_arg_t, A1<int>, MoveOnly, MoveOnly
+ >::value, "");
+ }
}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
index b72b77ee97c..9cde90da3f5 100644
--- a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
@@ -16,9 +16,23 @@
#include <tuple>
#include <string>
#include <cassert>
+#include <type_traits>
#include "DefaultOnly.h"
+struct NoDefault {
+ NoDefault() = delete;
+ explicit NoDefault(int) { }
+};
+
+struct NoExceptDefault {
+ NoExceptDefault() noexcept = default;
+};
+
+struct ThrowingDefault {
+ ThrowingDefault() { }
+};
+
int main()
{
{
@@ -46,6 +60,20 @@ int main()
assert(std::get<2>(t) == "");
assert(std::get<3>(t) == DefaultOnly());
}
+ {
+ // See bug #21157.
+ static_assert(!std::is_default_constructible<std::tuple<NoDefault>>(), "");
+ static_assert(!std::is_default_constructible<std::tuple<DefaultOnly, NoDefault>>(), "");
+ static_assert(!std::is_default_constructible<std::tuple<NoDefault, DefaultOnly, NoDefault>>(), "");
+ }
+ {
+ static_assert(noexcept(std::tuple<NoExceptDefault>()), "");
+ static_assert(noexcept(std::tuple<NoExceptDefault, NoExceptDefault>()), "");
+
+ static_assert(!noexcept(std::tuple<ThrowingDefault, NoExceptDefault>()), "");
+ static_assert(!noexcept(std::tuple<NoExceptDefault, ThrowingDefault>()), "");
+ static_assert(!noexcept(std::tuple<ThrowingDefault, ThrowingDefault>()), "");
+ }
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
{
constexpr std::tuple<> t;
OpenPOWER on IntegriCloud