From 1a6f2a0a80797c854869b2d2e0ec277b0dd76e54 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Wed, 23 Apr 2014 18:19:19 +0100 Subject: [PATCH] Changed the way noexcept support is handled to (hopefully) fix #275 and #273 --- .../internal/catch_compiler_capabilities.h | 21 +++++++++---------- include/internal/catch_evaluate.hpp | 2 ++ include/internal/catch_tostring.h | 1 + .../Baselines/console.std.approved.txt | 2 +- .../Baselines/console.sw.approved.txt | 14 ++++++++++++- .../SelfTest/Baselines/junit.sw.approved.txt | 3 ++- .../SelfTest/Baselines/xml.sw.approved.txt | 15 +++++++++++-- .../CatchSelfTest.xcodeproj/project.pbxproj | 6 ++++-- 8 files changed, 46 insertions(+), 18 deletions(-) diff --git a/include/internal/catch_compiler_capabilities.h b/include/internal/catch_compiler_capabilities.h index 0baa2b5d..76d0ffda 100644 --- a/include/internal/catch_compiler_capabilities.h +++ b/include/internal/catch_compiler_capabilities.h @@ -12,11 +12,13 @@ #ifdef __clang__ -#if __has_feature(cxx_nullptr) +# if __has_feature(cxx_nullptr) +# define CATCH_CONFIG_CPP11_NULLPTR +# endif -#define CATCH_CONFIG_CPP11_NULLPTR - -#endif +# if __has_feature(cxx_noexcept) +# define CATCH_CONFIG_CPP11_NOEXCEPT +# endif #endif // __clang__ @@ -108,13 +110,10 @@ #endif // noexcept support: -#ifdef CATCH_CPP11_OR_GREATER -# if (__has_feature(cxx_noexcept)) -# define CATCH_NOEXCEPT noexcept -# define CATCH_NOEXCEPT_IS(x) noexcept(x) -# endif -#endif -#ifndef CATCH_NO_EXCEPT +#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT) +# define CATCH_NOEXCEPT noexcept +# define CATCH_NOEXCEPT_IS(x) noexcept(x) +#else # define CATCH_NOEXCEPT throw() # define CATCH_NOEXCEPT_IS(x) #endif diff --git a/include/internal/catch_evaluate.hpp b/include/internal/catch_evaluate.hpp index f345d744..2f85a2b9 100644 --- a/include/internal/catch_evaluate.hpp +++ b/include/internal/catch_evaluate.hpp @@ -13,6 +13,8 @@ #pragma warning(disable:4389) // '==' : signed/unsigned mismatch #endif +#include + namespace Catch { namespace Internal { diff --git a/include/internal/catch_tostring.h b/include/internal/catch_tostring.h index 328dda7c..d6c2fcf2 100644 --- a/include/internal/catch_tostring.h +++ b/include/internal/catch_tostring.h @@ -15,6 +15,7 @@ #include #include #include +#include #ifdef __OBJC__ #include "catch_objc_arc.hpp" diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 5158f220..693584a1 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -772,5 +772,5 @@ with expansion: "first" == "second" =============================================================================== -126 test cases - 39 failed (628 assertions - 92 failed) +127 test cases - 39 failed (629 assertions - 92 failed) diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 978ee1e5..6e80ffbf 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -6285,6 +6285,18 @@ PASSED: with expansion: __null == 0 +------------------------------------------------------------------------------- +null_ptr +------------------------------------------------------------------------------- +TrickyTests.cpp: +............................................................................... + +TrickyTests.cpp:: +PASSED: + REQUIRE( ptr.get() == nullptr ) +with expansion: + __null == nullptr + ------------------------------------------------------------------------------- X/level/0/a ------------------------------------------------------------------------------- @@ -6668,5 +6680,5 @@ with expansion: true =============================================================================== -126 test cases - 54 failed (647 assertions - 111 failed) +127 test cases - 54 failed (648 assertions - 111 failed) diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 481718f0..5e7969b8 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,5 +1,5 @@ - + @@ -531,6 +531,7 @@ TrickyTests.cpp: + diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 8905e3df..b80c7094 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -6548,6 +6548,17 @@ there" + + + + ptr.get() == nullptr + + + __null == nullptr + + + + @@ -6881,7 +6892,7 @@ there" - + - + diff --git a/projects/XCode/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj b/projects/XCode/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj index 3f3926b5..1685cc66 100644 --- a/projects/XCode/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj +++ b/projects/XCode/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj @@ -634,7 +634,8 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++98"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_WARN__DUPLICATE_METHOD_MATCH = NO; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -649,7 +650,8 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++98"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; CLANG_WARN__DUPLICATE_METHOD_MATCH = NO; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; PRODUCT_NAME = "$(TARGET_NAME)";