From abd52cad847e56575e6692e7f43a76e510e67b7e Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Tue, 28 Jul 2015 07:31:50 +0000 Subject: [PATCH] Fix a handful of tests that fail in C++03 llvm-svn: 243392 --- .../sequences/array/array.tuple/get.fail.cpp | 8 ++++++- .../new.handler/new_handler.pass.cpp | 2 +- .../terminate_handler.pass.cpp | 2 +- .../support.runtime/cstdlib.pass.cpp | 6 +++--- .../thread.thread.assign/move2.pass.cpp | 10 +++------ .../allocator.members/construct.pass.cpp | 21 +++++++------------ .../utility/declval/declval.pass.cpp | 6 ++++-- .../utility/forward/move_if_noexcept.pass.cpp | 15 ++++++------- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp index ae629bd4daaa..6b2385da065a 100644 --- a/libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp +++ b/libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp @@ -19,6 +19,7 @@ #include #include +#include "test_macros.h" #include "../suppress_array_warnings.h" int main() @@ -27,6 +28,11 @@ int main() typedef double T; typedef std::array C; C c = {1, 2, 3.5}; - std::get<3>(c) = 5.5; // expected-error@array:* {{static_assert failed "Index out of bounds in std::get<> (std::array)"}} + std::get<3>(c) = 5.5; // expected-note {{requested here}} +#if TEST_STD_VER >= 11 + // expected-error@array:* {{static_assert failed "Index out of bounds in std::get<> (std::array)"}} +#else + // expected-error@array:* {{implicit instantiation of undefined template '__static_assert_test'}} +#endif } } diff --git a/libcxx/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp b/libcxx/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp index 38e040c98e1a..0d4524cacb38 100644 --- a/libcxx/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp +++ b/libcxx/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp @@ -17,7 +17,7 @@ void f() {} int main() { - static_assert(std::is_same::value, ""); + static_assert((std::is_same::value), ""); std::new_handler p = f; assert(p == &f); } diff --git a/libcxx/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp b/libcxx/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp index 46e212662a28..e477f5298e89 100644 --- a/libcxx/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp +++ b/libcxx/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp @@ -17,7 +17,7 @@ void f() {} int main() { - static_assert(std::is_same::value, ""); + static_assert((std::is_same::value), ""); std::terminate_handler p = f; assert(p == &f); } diff --git a/libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp b/libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp index d1b335cd2044..8191350b57ff 100644 --- a/libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp +++ b/libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp @@ -37,8 +37,8 @@ template void test_div_struct() { TestType obj; static_assert(sizeof(obj) >= sizeof(IntType) * 2, ""); // >= to account for alignment. - static_assert(std::is_same::value, ""); - static_assert(std::is_same::value, ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); ((void) obj); }; @@ -46,7 +46,7 @@ int main() { std::size_t s = 0; ((void)s); - static_assert(std::is_same::value, ""); + static_assert((std::is_same::value), ""); test_div_struct(); test_div_struct(); test_div_struct(); diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp index 7198d226960a..db2a58844c26 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // NOTE: std::terminate is called so the destructors are not invoked and the // memory is not freed. This will cause ASAN to fail. @@ -38,12 +39,7 @@ public: G(const G& g) : alive_(g.alive_) {++n_alive;} ~G() {alive_ = 0; --n_alive;} - void operator()() - { - assert(alive_ == 1); - assert(n_alive >= 1); - op_run = true; - } + void operator()(int i, double j) { @@ -60,7 +56,7 @@ bool G::op_run = false; void f1() { - std::exit(0); + std::_Exit(0); } int main() diff --git a/libcxx/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp b/libcxx/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp index d0a870e60690..40c44d94906c 100644 --- a/libcxx/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp +++ b/libcxx/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include "test_macros.h" #include "count_new.hpp" int A_constructed = 0; @@ -34,30 +35,22 @@ struct A int move_only_constructed = 0; +#if TEST_STD_VER >= 11 class move_only { int data; -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - move_only(const move_only&); - move_only& operator=(const move_only&); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - move_only(move_only&); - move_only& operator=(move_only&); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + + move_only(const move_only&) = delete; + move_only& operator=(const move_only&)= delete; public: - -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES move_only(move_only&&) {++move_only_constructed;} move_only& operator=(move_only&&) {return *this;} -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - operator std::__rv () {return std::__rv(*this);} - move_only(std::__rv) {++move_only_constructed;} -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES move_only() {++move_only_constructed;} ~move_only() {--move_only_constructed;} }; +#endif // TEST_STD_VER >= 11 int main() { @@ -108,6 +101,7 @@ int main() assert(globalMemCounter.checkOutstandingNewEq(0)); assert(A_constructed == 0); } +#if TEST_STD_VER >= 11 { std::allocator a; assert(globalMemCounter.checkOutstandingNewEq(0)); @@ -139,4 +133,5 @@ int main() assert(globalMemCounter.checkOutstandingNewEq(0)); assert(move_only_constructed == 0); } +#endif } diff --git a/libcxx/test/std/utilities/utility/declval/declval.pass.cpp b/libcxx/test/std/utilities/utility/declval/declval.pass.cpp index 81f4df8e8b2b..aabd0e6f6c74 100644 --- a/libcxx/test/std/utilities/utility/declval/declval.pass.cpp +++ b/libcxx/test/std/utilities/utility/declval/declval.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "test_macros.h" + class A { A(const A&); @@ -22,9 +24,9 @@ class A int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 static_assert((std::is_same()), A&&>::value), ""); #else - static_assert((std::is_same()), A>::value), ""); + static_assert((std::is_same()), A&>::value), ""); #endif } diff --git a/libcxx/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp b/libcxx/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp index c8375e9d7238..bc60d3d27614 100644 --- a/libcxx/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp +++ b/libcxx/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp @@ -56,13 +56,14 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); #else // C++ < 11 - // libc++ defines decltype to be __typeof__ in C++03. __typeof__ does not - // deduce the reference qualifiers. - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + // In C++03 libc++ #define's decltype to be __decltype on clang and + // __typeof__ for other compilers. __typeof__ does not deduce the reference + // qualifiers and will cause this test to fail. + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); #endif #if TEST_STD_VER > 11