From 51072bd6bf79ef2bc6a922079bff57c31c1effbc Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 23 Jul 2016 20:47:26 +0000 Subject: Vendor import of libc++ release_39 branch r276489: https://llvm.org/svn/llvm-project/libcxx/branches/release_39@276489 --- .../tuple.helper/tuple.include.array.pass.cpp | 2 +- .../tuple.helper/tuple.include.utility.pass.cpp | 3 +- .../tuple.helper/tuple_element.fail.cpp | 34 +++++++++++++++++ .../tuple.tuple/tuple.helper/tuple_size.fail.cpp | 27 ++++++++++++++ .../tuple.tuple/tuple.helper/tuple_size_v.fail.cpp | 26 +++++++++++++ .../tuple.tuple/tuple.helper/tuple_size_v.pass.cpp | 43 ++++++++++++++++++++++ 6 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.pass.cpp (limited to 'test/std/utilities/tuple/tuple.tuple/tuple.helper') diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp index d8a72c617cb5c..57da4b04cdfd9 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.array.pass.cpp @@ -18,7 +18,7 @@ // typedef Ti type; // }; // -// LWG #2212 says that tuple_size and tuple_element must be +// LWG #2212 says that tuple_size and tuple_element must be // available after including #include diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.utility.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.utility.pass.cpp index 8c8357d95d994..bd015ab5bbd6e 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.utility.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple.include.utility.pass.cpp @@ -15,9 +15,10 @@ // class tuple_size> // : public integral_constant { }; // -// LWG #2212 says that tuple_size and tuple_element must be +// LWG #2212 says that tuple_size and tuple_element must be // available after including +#include #include #include diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp new file mode 100644 index 0000000000000..4cb73573e7c9d --- /dev/null +++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.fail.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// class tuple_element > +// { +// public: +// typedef Ti type; +// }; + +// UNSUPPORTED: c++98, c++03 + +#include +#include + +int main() +{ + using T = std::tuple; + using E1 = typename std::tuple_element<1, T &>::type; // expected-error{{undefined template}} + using E2 = typename std::tuple_element<3, T>::type; + using E3 = typename std::tuple_element<4, T const>::type; + // expected-error@__tuple:* 2 {{static_assert failed}} + +} diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp new file mode 100644 index 0000000000000..3f132e47b626c --- /dev/null +++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// + +// template +// class tuple_size> +// : public integral_constant { }; + +// Expect failures with a reference type, pointer type, and a non-tuple type. + +#include + +int main() +{ + (void)std::tuple_size &>::value; // expected-error {{implicit instantiation of undefined template}} + (void)std::tuple_size::value; // expected-error {{implicit instantiation of undefined template}} + (void)std::tuple_size*>::value; // expected-error {{implicit instantiation of undefined template}} +} diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp new file mode 100644 index 0000000000000..957a683b47f85 --- /dev/null +++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// + +// template constexpr size_t tuple_size_v = tuple_size::value; + +// Expect failures with a reference type, pointer type, and a non-tuple type. + +#include + +int main() +{ + (void)std::tuple_size_v &>; // expected-note {{requested here}} + (void)std::tuple_size_v; // expected-note {{requested here}} + (void)std::tuple_size_v*>; // expected-note {{requested here}} + // expected-error@tuple:* 3 {{implicit instantiation of undefined template}} +} diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.pass.cpp new file mode 100644 index 0000000000000..24878a1d560e0 --- /dev/null +++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// + +// template constexpr size_t tuple_size_v = tuple_size::value; + +#include +#include +#include + +template +void test() +{ + static_assert(std::tuple_size_v == Expect, ""); + static_assert(std::tuple_size_v == std::tuple_size::value, ""); + static_assert(std::tuple_size_v == std::tuple_size::value, ""); + static_assert(std::tuple_size_v == std::tuple_size::value, ""); + static_assert(std::tuple_size_v == std::tuple_size::value, ""); +} + +int main() +{ + test, 0>(); + + test, 1>(); + test, 1>(); + + test, 2>(); + test, 2>(); + test, 2>(); + + test, 3>(); + test, 3>(); +} -- cgit v1.2.3