Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-02-22 15:03:18 +0100
committerMartin Hořeňovský2020-02-26 16:07:34 +0100
commite9caeb7d0be334ae804cb7680083845af6463b3d (patch)
treeb6e1a13d247e0ff15e1fd6ebd4470f017b26e753
parent6e270958a216821676998e8f6d8f524900156d4d (diff)
downloadcatch3-e9caeb7d0be334ae804cb7680083845af6463b3d.tar.gz
Fix Wparentheses for GCC
Sadly most versions still cannot properly handle the suppression via `_Pragma`, so it has to leak to the users when they use older GCC versions to compile their code
-rw-r--r--src/catch2/catch_capture.hpp6
-rw-r--r--src/catch2/catch_compiler_capabilities.h5
2 files changed, 11 insertions, 0 deletions
diff --git a/src/catch2/catch_capture.hpp b/src/catch2/catch_capture.hpp
index 3ecbab05..2b5cfa90 100644
--- a/src/catch2/catch_capture.hpp
+++ b/src/catch2/catch_capture.hpp
@@ -13,6 +13,12 @@
#include <catch2/catch_message.h>
#include <catch2/catch_stringref.h>
+// We need this suppression to leak, because it took until GCC 9
+// for the front end to handle local suppression via _Pragma properly
+#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && __GNUC__ < 9
+ #pragma GCC diagnostic ignored "-Wparentheses"
+#endif
+
#if !defined(CATCH_CONFIG_DISABLE)
#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION)
diff --git a/src/catch2/catch_compiler_capabilities.h b/src/catch2/catch_compiler_capabilities.h
index b26e815f..2a2ad2b6 100644
--- a/src/catch2/catch_compiler_capabilities.h
+++ b/src/catch2/catch_compiler_capabilities.h
@@ -48,6 +48,11 @@
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC)
# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" )
# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" )
+
+// This only works on GCC 9+. so we have to also add a global suppression of Wparentheses
+// for older versions of GCC.
+# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
+ _Pragma( "GCC diagnostic ignored \"-Wparentheses\"" )
#endif
#if defined(__clang__)