Author: ericwf Date: Tue Jul 28 02:31:50 2015 New Revision: 243392 URL: http://llvm.org/viewvc/llvm-project?rev=243392&view=rev Log: Fix a handful of tests that fail in C++03
Modified: libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.fail.cpp libcxx/trunk/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp libcxx/trunk/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp libcxx/trunk/test/std/language.support/support.runtime/cstdlib.pass.cpp libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp libcxx/trunk/test/std/utilities/utility/declval/declval.pass.cpp libcxx/trunk/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp Modified: libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.fail.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.fail.cpp?rev=243392&r1=243391&r2=243392&view=diff ============================================================================== --- libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.fail.cpp (original) +++ libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.fail.cpp Tue Jul 28 02:31:50 2015 @@ -19,6 +19,7 @@ #include <array> #include <cassert> +#include "test_macros.h" #include "../suppress_array_warnings.h" int main() @@ -27,6 +28,11 @@ int main() typedef double T; typedef std::array<T, 3> 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<false>'}} +#endif } } Modified: libcxx/trunk/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp?rev=243392&r1=243391&r2=243392&view=diff ============================================================================== --- libcxx/trunk/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp (original) +++ libcxx/trunk/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp Tue Jul 28 02:31:50 2015 @@ -17,7 +17,7 @@ void f() {} int main() { - static_assert(std::is_same<std::new_handler, void(*)()>::value, ""); + static_assert((std::is_same<std::new_handler, void(*)()>::value), ""); std::new_handler p = f; assert(p == &f); } Modified: libcxx/trunk/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp?rev=243392&r1=243391&r2=243392&view=diff ============================================================================== --- libcxx/trunk/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp (original) +++ libcxx/trunk/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp Tue Jul 28 02:31:50 2015 @@ -17,7 +17,7 @@ void f() {} int main() { - static_assert(std::is_same<std::terminate_handler, void(*)()>::value, ""); + static_assert((std::is_same<std::terminate_handler, void(*)()>::value), ""); std::terminate_handler p = f; assert(p == &f); } Modified: libcxx/trunk/test/std/language.support/support.runtime/cstdlib.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.runtime/cstdlib.pass.cpp?rev=243392&r1=243391&r2=243392&view=diff ============================================================================== --- libcxx/trunk/test/std/language.support/support.runtime/cstdlib.pass.cpp (original) +++ libcxx/trunk/test/std/language.support/support.runtime/cstdlib.pass.cpp Tue Jul 28 02:31:50 2015 @@ -37,8 +37,8 @@ template <class TestType, class IntType> void test_div_struct() { TestType obj; static_assert(sizeof(obj) >= sizeof(IntType) * 2, ""); // >= to account for alignment. - static_assert(std::is_same<decltype(obj.quot), IntType>::value, ""); - static_assert(std::is_same<decltype(obj.rem), IntType>::value, ""); + static_assert((std::is_same<decltype(obj.quot), IntType>::value), ""); + static_assert((std::is_same<decltype(obj.rem), IntType>::value), ""); ((void) obj); }; @@ -46,7 +46,7 @@ int main() { std::size_t s = 0; ((void)s); - static_assert(std::is_same<std::size_t, decltype(sizeof(int))>::value, ""); + static_assert((std::is_same<std::size_t, decltype(sizeof(int))>::value), ""); test_div_struct<std::div_t, int>(); test_div_struct<std::ldiv_t, long>(); test_div_struct<std::lldiv_t, long long>(); Modified: libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp?rev=243392&r1=243391&r2=243392&view=diff ============================================================================== --- libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp (original) +++ libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp Tue Jul 28 02:31:50 2015 @@ -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() Modified: libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp?rev=243392&r1=243391&r2=243392&view=diff ============================================================================== --- libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp Tue Jul 28 02:31:50 2015 @@ -15,6 +15,7 @@ #include <memory> #include <cassert> +#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 -public: + move_only(const move_only&) = delete; + move_only& operator=(const move_only&)= delete; -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +public: move_only(move_only&&) {++move_only_constructed;} move_only& operator=(move_only&&) {return *this;} -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - operator std::__rv<move_only> () {return std::__rv<move_only>(*this);} - move_only(std::__rv<move_only>) {++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<move_only> a; assert(globalMemCounter.checkOutstandingNewEq(0)); @@ -139,4 +133,5 @@ int main() assert(globalMemCounter.checkOutstandingNewEq(0)); assert(move_only_constructed == 0); } +#endif } Modified: libcxx/trunk/test/std/utilities/utility/declval/declval.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/declval/declval.pass.cpp?rev=243392&r1=243391&r2=243392&view=diff ============================================================================== --- libcxx/trunk/test/std/utilities/utility/declval/declval.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/utility/declval/declval.pass.cpp Tue Jul 28 02:31:50 2015 @@ -14,6 +14,8 @@ #include <utility> #include <type_traits> +#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<decltype(std::declval<A>()), A&&>::value), ""); #else - static_assert((std::is_same<decltype(std::declval<A>()), A>::value), ""); + static_assert((std::is_same<decltype(std::declval<A>()), A&>::value), ""); #endif } Modified: libcxx/trunk/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp?rev=243392&r1=243391&r2=243392&view=diff ============================================================================== --- libcxx/trunk/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp Tue Jul 28 02:31:50 2015 @@ -56,13 +56,14 @@ int main() static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A&&>::value), ""); static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::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<decltype(std::move_if_noexcept(i)), const int>::value), ""); - static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int>::value), ""); - static_assert((std::is_same<decltype(std::move_if_noexcept(a)), const A>::value), ""); - static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A>::value), ""); - static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy>::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<decltype(std::move_if_noexcept(i)), const int&>::value), ""); + static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int&>::value), ""); + static_assert((std::is_same<decltype(std::move_if_noexcept(a)), const A&>::value), ""); + static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A&>::value), ""); + static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), ""); #endif #if TEST_STD_VER > 11 _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits