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

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPhil Nash2016-02-29 08:01:06 +0000
committerPhil Nash2016-02-29 08:03:48 +0000
commit91bfe68a75ccdf2efb93a4074e7b998c669f3177 (patch)
tree1cf3bb5990a4643be7a62803c38b821c21fefe52 /include
parent8ccb18daa9c380c35ae4d13751e2a1aeed905815 (diff)
downloadcatch3-91bfe68a75ccdf2efb93a4074e7b998c669f3177.tar.gz
Suppress parentheses warnings on clang and gcc
- should address #593, #528, #521, #496 (and possibly others)
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_capture.hpp1
-rw-r--r--include/internal/catch_compiler_capabilities.h26
2 files changed, 21 insertions, 6 deletions
diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp
index 20bcf6f5..1496fe3a 100644
--- a/include/internal/catch_capture.hpp
+++ b/include/internal/catch_capture.hpp
@@ -33,6 +33,7 @@
do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
try { \
+ CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
( __catchResult <= expr ).endExpression(); \
} \
catch( ... ) { \
diff --git a/include/internal/catch_compiler_capabilities.h b/include/internal/catch_compiler_capabilities.h
index 7ac7b73f..cd345370 100644
--- a/include/internal/catch_compiler_capabilities.h
+++ b/include/internal/catch_compiler_capabilities.h
@@ -36,6 +36,10 @@
// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11
+#if defined(__cplusplus) && __cplusplus >= 201103L
+# define CATCH_CPP11_OR_GREATER
+#endif
+
#ifdef __clang__
# if __has_feature(cxx_nullptr)
@@ -46,6 +50,10 @@
# define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
# endif
+# if defined(CATCH_CPP11_OR_GREATER)
+# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS _Pragma( "clang diagnostic ignored \"-Wparentheses\"" )
+# endif
+
#endif // __clang__
////////////////////////////////////////////////////////////////////////////////
@@ -73,9 +81,13 @@
// GCC
#ifdef __GNUC__
-#if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__)
-# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
-#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)
+# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS _Pragma( "gcc diagnostic ignored \"-Wparentheses\"" )
+# endif
// - otherwise more recent versions define __cplusplus >= 201103L
// and will get picked up below
@@ -111,13 +123,12 @@
#endif
+
////////////////////////////////////////////////////////////////////////////////
// C++ language feature support
// catch all support for C++11
-#if defined(__cplusplus) && __cplusplus >= 201103L
-
-# define CATCH_CPP11_OR_GREATER
+#if defined(CATCH_CPP11_OR_GREATER)
# if !defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR)
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
@@ -186,6 +197,9 @@
# define CATCH_CONFIG_CPP11_UNIQUE_PTR
#endif
+#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
+# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
+#endif
// noexcept support:
#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT)