Skip to content

Commit

Permalink
Improve -Wparentheses supression for gcc
Browse files Browse the repository at this point in the history
If the gcc version supports `_Pragma` properly, we use that to disable
it locally inside assertions.

Otherwise we disable it for the entire TU.

Fixes #674
  • Loading branch information
horenmar committed Feb 15, 2017
1 parent 1f71d1f commit 2e0ae01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion include/internal/catch_compiler_capabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,15 @@
// GCC
#ifdef __GNUC__

# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
# define CATCH_GCC_HAS_NEW_PRAGMA
# endif

# if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__)
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
# endif

# if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) && defined(CATCH_CPP11_OR_GREATER)
# if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) && defined(CATCH_GCC_HAS_NEW_PRAGMA)
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
_Pragma( "GCC diagnostic push" ) \
_Pragma( "GCC diagnostic ignored \"-Wparentheses\"" )
Expand Down
6 changes: 6 additions & 0 deletions include/internal/catch_suppress_warnings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
#elif defined __GNUC__
# pragma GCC diagnostic ignored "-Wvariadic-macros"
# pragma GCC diagnostic ignored "-Wunused-variable"

// For newer version we can use __Pragma to disable the warnings locally
# if __GNUC__ == 4 && __GNUC_MINOR__ >= 4 && __GNUC_MINOR__ <= 7
# pragma GCC diagnostic ignored "-Wparentheses"
# endif

# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpadded"
#endif

0 comments on commit 2e0ae01

Please sign in to comment.