[libc++abi] Get rid of warnings when running the tests with GCC

This commit is contained in:
Louis Dionne 2020-10-30 17:33:02 -04:00
parent 5a7bc5e259
commit 8d31392753
16 changed files with 103 additions and 52 deletions

View File

@ -54,6 +54,14 @@
#endif
#endif
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wtautological-pointer-compare"
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Waddress"
#endif
// To make testing possible, this header is included from both cxa_guard.cpp
// and a number of tests.
//
@ -112,25 +120,25 @@ class AtomicInt {
public:
using MemoryOrder = std::__libcpp_atomic_order;
explicit AtomicInt(IntType *b) : b(b) {}
explicit AtomicInt(IntType *b) : b_(b) {}
AtomicInt(AtomicInt const&) = delete;
AtomicInt& operator=(AtomicInt const&) = delete;
IntType load(MemoryOrder ord) {
return std::__libcpp_atomic_load(b, ord);
return std::__libcpp_atomic_load(b_, ord);
}
void store(IntType val, MemoryOrder ord) {
std::__libcpp_atomic_store(b, val, ord);
std::__libcpp_atomic_store(b_, val, ord);
}
IntType exchange(IntType new_val, MemoryOrder ord) {
return std::__libcpp_atomic_exchange(b, new_val, ord);
return std::__libcpp_atomic_exchange(b_, new_val, ord);
}
bool compare_exchange(IntType *expected, IntType desired, MemoryOrder ord_success, MemoryOrder ord_failure) {
return std::__libcpp_atomic_compare_exchange(b, expected, desired, ord_success, ord_failure);
return std::__libcpp_atomic_compare_exchange(b_, expected, desired, ord_success, ord_failure);
}
private:
IntType *b;
IntType *b_;
};
//===----------------------------------------------------------------------===//
@ -154,14 +162,7 @@ constexpr uint32_t (*PlatformThreadID)() = nullptr;
constexpr bool PlatformSupportsThreadID() {
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wtautological-pointer-compare"
#endif
return +PlatformThreadID != nullptr;
#ifdef __clang__
#pragma clang diagnostic pop
#endif
}
//===----------------------------------------------------------------------===//
@ -375,18 +376,18 @@ private:
LockGuard& operator=(LockGuard const&) = delete;
explicit LockGuard(const char* calling_func)
: calling_func(calling_func) {
: calling_func_(calling_func) {
if (global_mutex.lock())
ABORT_WITH_MESSAGE("%s failed to acquire mutex", calling_func);
ABORT_WITH_MESSAGE("%s failed to acquire mutex", calling_func_);
}
~LockGuard() {
if (global_mutex.unlock())
ABORT_WITH_MESSAGE("%s failed to release mutex", calling_func);
ABORT_WITH_MESSAGE("%s failed to release mutex", calling_func_);
}
private:
const char* const calling_func;
const char* const calling_func_;
};
};
@ -411,14 +412,7 @@ constexpr void (*PlatformFutexWake)(int*) = nullptr;
#endif
constexpr bool PlatformSupportsFutex() {
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wtautological-pointer-compare"
#endif
return +PlatformFutexWait != nullptr;
#ifdef __clang__
#pragma clang diagnostic pop
#endif
}
/// InitByteFutex - Manages initialization using atomics and the futex syscall
@ -589,4 +583,10 @@ using SelectedImplementation =
} // end namespace
} // end namespace __cxxabiv1
#if defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__GNUC__)
# pragma GCC diagnostic pop
#endif
#endif // LIBCXXABI_SRC_INCLUDE_CXA_GUARD_IMPL_H

View File

@ -2313,9 +2313,9 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
TemplateParamList Params;
public:
ScopedTemplateParamList(AbstractManglingParser *Parser)
: Parser(Parser),
OldNumTemplateParamLists(Parser->TemplateParams.size()) {
ScopedTemplateParamList(AbstractManglingParser *TheParser)
: Parser(TheParser),
OldNumTemplateParamLists(TheParser->TemplateParams.size()) {
Parser->TemplateParams.push_back(&Params);
}
~ScopedTemplateParamList() {
@ -5103,7 +5103,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseEncoding() {
decltype(TemplateParams) OldParams;
public:
SaveTemplateParams(AbstractManglingParser *Parser) : Parser(Parser) {
SaveTemplateParams(AbstractManglingParser *TheParser) : Parser(TheParser) {
OldParams = std::move(Parser->TemplateParams);
Parser->TemplateParams.clear();
}

View File

@ -14,6 +14,12 @@
// UNSUPPORTED: no-exceptions
// FIXME: GCC doesn't allow turning off the warning for exceptions being caught
// by earlier handlers, which this test is exercising. We have to disable
// warnings altogether to remove the error.
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97675.
// ADDITIONAL_COMPILE_FLAGS: -Wno-error
#include <exception>
#include <stdlib.h>
#include <assert.h>

View File

@ -14,6 +14,12 @@
// UNSUPPORTED: no-exceptions
// FIXME: GCC doesn't allow turning off the warning for exceptions being caught
// by earlier handlers, which this test is exercising. We have to disable
// warnings altogether to remove the error.
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97675.
// ADDITIONAL_COMPILE_FLAGS: -Wno-error
#include <exception>
#include <stdlib.h>
#include <assert.h>

View File

@ -14,11 +14,11 @@
// (ignoring the top-level cv-qualifiers), or
// * the handler is of type cv T or cv T& and T is an unambiguous base
// class of E, or
// / * the handler is of type cv1 T* cv2 and E is a pointer type that can \
// | be converted to the type of the handler by either or both of |
// | o a standard pointer conversion (4.10 [conv.ptr]) not involving |
// | conversions to private or protected or ambiguous classes |
// \ o a qualification conversion /
// > * the handler is of type cv1 T* cv2 and E is a pointer type that can <
// > be converted to the type of the handler by either or both of <
// > o a standard pointer conversion (4.10 [conv.ptr]) not involving <
// > conversions to private or protected or ambiguous classes <
// > o a qualification conversion <
// * the handler is a pointer or pointer to member type and E is
// std::nullptr_t
//

View File

@ -14,6 +14,12 @@
// UNSUPPORTED: no-exceptions
// FIXME: GCC doesn't allow turning off the warning for exceptions being caught
// by earlier handlers, which this test is exercising. We have to disable
// warnings altogether to remove the error.
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97675.
// ADDITIONAL_COMPILE_FLAGS: -Wno-error
#include <exception>
#include <stdlib.h>
#include <assert.h>
@ -72,11 +78,11 @@ struct A
int A::count = 0;
A a(5);
A global_a(5);
void f1()
{
throw &a;
throw &global_a;
assert(false);
}

View File

@ -8,6 +8,12 @@
// UNSUPPORTED: no-exceptions
// FIXME: GCC doesn't allow turning off the warning for exceptions being caught
// by earlier handlers, which this test is exercising. We have to disable
// warnings altogether to remove the error.
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97675.
// ADDITIONAL_COMPILE_FLAGS: -Wno-error
#include <cassert>
// Clang emits warnings about exceptions of type 'Child' being caught by

View File

@ -43,7 +43,7 @@ int main ()
assert(false);
((void)d);
#ifndef TEST_HAS_NO_EXCEPTIONS
} catch (std::bad_cast) {
} catch (std::bad_cast const&) {
// success
return 0;
} catch (...) {

View File

@ -41,7 +41,7 @@ int main ()
test_bad_typeid(nullptr);
assert(false);
#ifndef TEST_HAS_NO_EXCEPTIONS
} catch (std::bad_typeid) {
} catch (std::bad_typeid const&) {
// success
return 0;
} catch (...) {

View File

@ -11,7 +11,9 @@
// This test explicitly tests dynamic cast with types that have inaccessible
// bases.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Winaccessible-base"
# pragma clang diagnostic ignored "-Winaccessible-base"
#elif defined(__GNUC__)
# pragma GCC diagnostic ignored "-Winaccessible-base"
#endif
typedef char Pad1[43981];

View File

@ -12,7 +12,9 @@
// This test explicitly tests dynamic cast with types that have inaccessible
// bases.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Winaccessible-base"
# pragma clang diagnostic ignored "-Winaccessible-base"
#elif defined(__GNUC__)
# pragma GCC diagnostic ignored "-Winaccessible-base"
#endif
/*

View File

@ -12,7 +12,9 @@
// This test explicitly tests dynamic cast with types that have inaccessible
// bases.
#if defined(__clang__)
#pragma clang diagnostic ignored "-Winaccessible-base"
# pragma clang diagnostic ignored "-Winaccessible-base"
#elif defined(__GNUC__)
# pragma GCC diagnostic ignored "-Winaccessible-base"
#endif
namespace t1

View File

@ -12,6 +12,11 @@
#include "../src/cxa_guard_impl.h"
#include <cassert>
// Disable GCC warning about tautological comparison of a function's address
#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic ignored "-Waddress"
#endif
using namespace __cxxabiv1;
template <class GuardType, class Impl>

View File

@ -10,10 +10,10 @@
//
// C++ ABI 15.3:
// A handler is a match for an exception object of type E if
// / * The handler is of type cv T or cv T& and E and T are the same type \
// | (ignoring the top-level cv-qualifiers), or |
// | * the handler is of type cv T or cv T& and T is an unambiguous base |
// \ class of E, or /
// > * The handler is of type cv T or cv T& and E and T are the same type <
// > (ignoring the top-level cv-qualifiers), or <
// > * the handler is of type cv T or cv T& and T is an unambiguous base <
// > class of E, or <
// * the handler is of type cv1 T* cv2 and E is a pointer type that can
// be converted to the type of the handler by either or both of
// o a standard pointer conversion (4.10 [conv.ptr]) not involving
@ -26,6 +26,12 @@
// UNSUPPORTED: no-exceptions
// FIXME: GCC doesn't allow turning off the warning for exceptions being caught
// by earlier handlers, which this test is exercising. We have to disable
// warnings altogether to remove the error.
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97675.
// ADDITIONAL_COMPILE_FLAGS: -Wno-error
// Clang emits warnings about exceptions of type 'Child' being caught by
// an earlier handler of type 'Base'. Congrats clang, you've just
// diagnosed the behavior under test.

View File

@ -17,6 +17,11 @@
#include <memory>
// Disable warning about throw always calling terminate.
#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic ignored "-Wterminate"
#endif
// use dtors instead of try/catch
namespace test1 {
struct B {

View File

@ -13,6 +13,11 @@
#include <assert.h>
#include <stdio.h>
// Suppress diagnostics about deprecated volatile operations
#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic ignored "-Wvolatile"
#endif
// Compile with -Os to get compiler uses float registers to hold float variables
double get_(int x) { return (double)x; }
@ -138,7 +143,7 @@ double foo()
try {
try1(true);
}
catch (int e) {
catch (int) {
}
assert(a == get(1));
assert(b == get(2));
@ -152,7 +157,7 @@ double foo()
try {
try2(true);
}
catch (int e) {
catch (int) {
}
assert(a == get(1));
assert(b == get(2));
@ -166,7 +171,7 @@ double foo()
try {
try3(true);
}
catch (int e) {
catch (int) {
}
assert(a == get(1));
assert(b == get(2));
@ -180,7 +185,7 @@ double foo()
try {
try4(true);
}
catch (int e) {
catch (int) {
}
assert(a == get(1));
assert(b == get(2));
@ -194,7 +199,7 @@ double foo()
try {
try5(true);
}
catch (int e) {
catch (int) {
}
assert(a == get(1));
assert(b == get(2));
@ -208,7 +213,7 @@ double foo()
try {
try6(true);
}
catch (int e) {
catch (int) {
}
assert(a == get(1));
assert(b == get(2));
@ -222,7 +227,7 @@ double foo()
try {
try7(true);
}
catch (int e) {
catch (int) {
}
assert(a == get(1));
assert(b == get(2));
@ -236,7 +241,7 @@ double foo()
try {
try8(true);
}
catch (int e) {
catch (int) {
}
assert(a == get(1));
assert(b == get(2));