From 1cac82cf388c1321adf8c3e892027a4491a29e3a Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Mon, 20 Apr 2020 13:48:16 -0400 Subject: [PATCH] [libc++] Fix a few warnings when running the test suite with GCC --- libcxx/test/libcxx/algorithms/debug_less.pass.cpp | 2 ++ libcxx/test/libcxx/atomics/libcpp-has-no-threads.pass.cpp | 2 +- libcxx/test/libcxx/containers/associative/undef_min_max.pass.cpp | 4 ++-- libcxx/test/libcxx/containers/gnu_cxx/hash_map.pass.cpp | 4 +++- libcxx/test/libcxx/containers/gnu_cxx/hash_map_name_lookup.pass.cpp | 3 +++ libcxx/test/libcxx/containers/gnu_cxx/hash_set.pass.cpp | 4 +++- libcxx/test/libcxx/containers/gnu_cxx/hash_set_name_lookup.pass.cpp | 4 ++++ libcxx/test/libcxx/numerics/c.math/undef_min_max.pass.cpp | 4 ++-- libcxx/test/support/container_debug_tests.h | 2 +- libcxx/test/support/debug_mode_helper.h | 1 + 10 files changed, 22 insertions(+), 8 deletions(-) diff --git a/libcxx/test/libcxx/algorithms/debug_less.pass.cpp b/libcxx/test/libcxx/algorithms/debug_less.pass.cpp index 5d1b575..6a05b8d 100644 --- a/libcxx/test/libcxx/algorithms/debug_less.pass.cpp +++ b/libcxx/test/libcxx/algorithms/debug_less.pass.cpp @@ -183,6 +183,7 @@ inline bool operator<(FooImp const& x, Tag<0> y) { template inline bool operator<(Tag<0>, FooImp const&) { static_assert(sizeof(FooImp) != sizeof(FooImp), "should not be instantiated"); + return false; } template @@ -193,6 +194,7 @@ inline bool operator<(Tag<1> x, FooImp const& y) { template inline bool operator<(FooImp const&, Tag<1>) { static_assert(sizeof(FooImp) != sizeof(FooImp), "should not be instantiated"); + return false; } typedef FooImp<> Foo; diff --git a/libcxx/test/libcxx/atomics/libcpp-has-no-threads.pass.cpp b/libcxx/test/libcxx/atomics/libcpp-has-no-threads.pass.cpp index af2d55e..b52ba64 100644 --- a/libcxx/test/libcxx/atomics/libcpp-has-no-threads.pass.cpp +++ b/libcxx/test/libcxx/atomics/libcpp-has-no-threads.pass.cpp @@ -8,7 +8,7 @@ // XFAIL: libcpp-has-no-threads #ifdef _LIBCPP_HAS_NO_THREADS -#error This should be XFAIL'd for the purpose of detecting that the LIT feature\ +#error This should be XFAILed for the purpose of detecting that the LIT feature\ 'libcpp-has-no-threads' is available iff _LIBCPP_HAS_NO_THREADS is defined #endif diff --git a/libcxx/test/libcxx/containers/associative/undef_min_max.pass.cpp b/libcxx/test/libcxx/containers/associative/undef_min_max.pass.cpp index 1408da9..ff15f35 100644 --- a/libcxx/test/libcxx/containers/associative/undef_min_max.pass.cpp +++ b/libcxx/test/libcxx/containers/associative/undef_min_max.pass.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic ignored "-W#warnings" +#if defined(__clang__) +#pragma clang diagnostic ignored "-W#warnings" #endif #define min THIS IS A NASTY MACRO! diff --git a/libcxx/test/libcxx/containers/gnu_cxx/hash_map.pass.cpp b/libcxx/test/libcxx/containers/gnu_cxx/hash_map.pass.cpp index df41318..ff268cd 100644 --- a/libcxx/test/libcxx/containers/gnu_cxx/hash_map.pass.cpp +++ b/libcxx/test/libcxx/containers/gnu_cxx/hash_map.pass.cpp @@ -6,11 +6,13 @@ // //===----------------------------------------------------------------------===// - // Prevent emission of the deprecated warning. #ifdef __clang__ #pragma clang diagnostic ignored "-W#warnings" #endif +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wcpp" +#endif #include #include diff --git a/libcxx/test/libcxx/containers/gnu_cxx/hash_map_name_lookup.pass.cpp b/libcxx/test/libcxx/containers/gnu_cxx/hash_map_name_lookup.pass.cpp index bfcb8ae..31e877e 100644 --- a/libcxx/test/libcxx/containers/gnu_cxx/hash_map_name_lookup.pass.cpp +++ b/libcxx/test/libcxx/containers/gnu_cxx/hash_map_name_lookup.pass.cpp @@ -10,6 +10,9 @@ #ifdef __clang__ #pragma clang diagnostic ignored "-W#warnings" #endif +#ifdef __GNUC__ +#pragma GCC diagnostic push "-Wcpp" +#endif // Poison the std:: names we might use inside __gnu_cxx to ensure they're // properly qualified. diff --git a/libcxx/test/libcxx/containers/gnu_cxx/hash_set.pass.cpp b/libcxx/test/libcxx/containers/gnu_cxx/hash_set.pass.cpp index 307ba73..bfdbb38 100644 --- a/libcxx/test/libcxx/containers/gnu_cxx/hash_set.pass.cpp +++ b/libcxx/test/libcxx/containers/gnu_cxx/hash_set.pass.cpp @@ -6,11 +6,13 @@ // //===----------------------------------------------------------------------===// - // Prevent emission of the deprecated warning. #ifdef __clang__ #pragma clang diagnostic ignored "-W#warnings" #endif +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wcpp" +#endif #include #include diff --git a/libcxx/test/libcxx/containers/gnu_cxx/hash_set_name_lookup.pass.cpp b/libcxx/test/libcxx/containers/gnu_cxx/hash_set_name_lookup.pass.cpp index b3e1e19..6e50137 100644 --- a/libcxx/test/libcxx/containers/gnu_cxx/hash_set_name_lookup.pass.cpp +++ b/libcxx/test/libcxx/containers/gnu_cxx/hash_set_name_lookup.pass.cpp @@ -10,6 +10,10 @@ #ifdef __clang__ #pragma clang diagnostic ignored "-W#warnings" #endif +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wcpp" +#endif + // Poison the std:: names we might use inside __gnu_cxx to ensure they're // properly qualified. struct allocator; diff --git a/libcxx/test/libcxx/numerics/c.math/undef_min_max.pass.cpp b/libcxx/test/libcxx/numerics/c.math/undef_min_max.pass.cpp index ba1696e..a9f5017 100644 --- a/libcxx/test/libcxx/numerics/c.math/undef_min_max.pass.cpp +++ b/libcxx/test/libcxx/numerics/c.math/undef_min_max.pass.cpp @@ -5,8 +5,8 @@ // //===----------------------------------------------------------------------===// -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic ignored "-W#warnings" +#if defined(__clang__) +#pragma clang diagnostic ignored "-W#warnings" #endif #define min THIS IS A NASTY MACRO! diff --git a/libcxx/test/support/container_debug_tests.h b/libcxx/test/support/container_debug_tests.h index 36496c2..e0b0df3 100644 --- a/libcxx/test/support/container_debug_tests.h +++ b/libcxx/test/support/container_debug_tests.h @@ -11,7 +11,7 @@ #include #ifndef _LIBCPP_VERSION -#error This header may only be used for libc++ tests" +#error This header may only be used for libc++ tests #endif #ifndef _LIBCPP_DEBUG diff --git a/libcxx/test/support/debug_mode_helper.h b/libcxx/test/support/debug_mode_helper.h index ed111ab..8256f3e 100644 --- a/libcxx/test/support/debug_mode_helper.h +++ b/libcxx/test/support/debug_mode_helper.h @@ -287,6 +287,7 @@ inline bool ExpectDeath(const char* stmt, Func&& func, DebugInfoMatcher Matcher) case DeathTest::RK_MatchFailure: return OnFailure("matcher failed"); } + assert(false && "unreachable"); } template -- 2.7.4