From 4471b2f1335002a1fa3f0166ad8d21ff0efd4ce0 Mon Sep 17 00:00:00 2001 From: John Steele Scott Date: Mon, 1 Mar 2021 20:34:06 +1030 Subject: [PATCH] Don't explicitly suppress GCC's -Wterminate in tests' FMT_ASSERT. Throwing from a separate function is enough to silence the warning, no need to explicitly suppress it. --- test/test-assert.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/test/test-assert.h b/test/test-assert.h index d91a9ccd..42844a05 100644 --- a/test/test-assert.h +++ b/test/test-assert.h @@ -22,19 +22,11 @@ class assertion_failure : public std::logic_error { void assertion_failure::avoid_weak_vtable() {} +// We use a separate function (rather than throw directly from FMT_ASSERT) to +// avoid GCC's -Wterminate warning when FMT_ASSERT is used in a destructor. inline void throw_assertion_failure (const char *message) { -# if defined(__GNUC__) && __GNUC__ >= 6 - // Avoid warnings when FMT_ASSERT is used in a destructor. -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wterminate" -# endif - throw assertion_failure(message); - -# if defined(__GNUC__) && __GNUC__ >= 6 -# pragma GCC diagnostic pop -# endif }