From 61d5cf563475af1f0b6750b59b4e430e14f493cf Mon Sep 17 00:00:00 2001 From: Mathieu Champlon Date: Fri, 23 Mar 2018 16:02:15 +0100 Subject: [PATCH 1/2] Added /std:cxx?? to appveyor builds Build for c++17 disabled as Boost has not yet released a fully Visual Studio 2017 c++17 ready version. --- appveyor.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d6a844f..3880f4f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,11 +9,16 @@ skip_branch_with_pr: true environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - BOOST_ROOT: C:\Libraries\boost_1_59_0 + BOOST: 1_59_0 TOOLSET: msvc-14.0 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - BOOST_ROOT: C:\Libraries\boost_1_65_1 + BOOST: 1_65_1 TOOLSET: msvc-14.1 + CXX_STANDARD: 14 + # - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + # BOOST: 1_65_1 + # TOOLSET: msvc-14.1 + # CXX_STANDARD: 17 platform: - 32 @@ -36,7 +41,9 @@ install: - xsltproc -V build_script: + - set BOOST_ROOT=C:\Libraries\boost_%BOOST% - cd %BOOST_ROOT% - call bootstrap.bat - cd C:\projects\turtle\build - - call build.bat --toolset=%TOOLSET% address-model=%PLATFORM% --build-type=complete %CONFIGURATION% + - if NOT "%CXX_STANDARD%"=="" set CXX_FLAGS=cxxflags=/std:c++%CXX_STANDARD% + - call build.bat --toolset=%TOOLSET% address-model=%PLATFORM% %CXX_FLAGS% --build-type=complete %CONFIGURATION% From c42b7089506ed5c0f0be0a03326397ce5fd7e24f Mon Sep 17 00:00:00 2001 From: Mathieu Champlon Date: Fri, 23 Mar 2018 18:18:23 +0100 Subject: [PATCH 2/2] Fixed deprecation warning about std::uncaught_exception in c++17 for msvc --- doc/changelog.qbk | 1 + include/turtle/config.hpp | 7 +++++++ include/turtle/detail/function.hpp | 9 +++++++++ include/turtle/detail/function_impl_template.hpp | 4 +++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/doc/changelog.qbk b/doc/changelog.qbk index 303f163..bd93db4 100644 --- a/doc/changelog.qbk +++ b/doc/changelog.qbk @@ -17,6 +17,7 @@ Not yet released * Fixed move-only type support in constraints * Added support for dereferencing in mock::equal * Added support for movable objects in mock::retrieve +* Fixed deprecation warning about std::uncaught_exception in c++17 for msvc [endsect] diff --git a/include/turtle/config.hpp b/include/turtle/config.hpp index 5d2f78e..96a11c8 100644 --- a/include/turtle/config.hpp +++ b/include/turtle/config.hpp @@ -94,4 +94,11 @@ # endif #endif +#if defined(__cplusplus) && (__cplusplus >= 201703L) || \ + defined(_MSC_VER) && (_MSC_VER >= 1900) +# ifndef MOCK_NO_UNCAUGHT_EXCEPTIONS +# define MOCK_UNCAUGHT_EXCEPTIONS +# endif +#endif + #endif // MOCK_CONFIG_HPP_INCLUDED diff --git a/include/turtle/detail/function.hpp b/include/turtle/detail/function.hpp index 837b169..a631310 100644 --- a/include/turtle/detail/function.hpp +++ b/include/turtle/detail/function.hpp @@ -86,6 +86,15 @@ namespace detail E* e_; }; + + inline int uncaught_exceptions() + { +#ifdef MOCK_UNCAUGHT_EXCEPTIONS + return std::uncaught_exceptions(); +#else + return std::uncaught_exception() ? 1 : 0; +#endif + } } } // mock diff --git a/include/turtle/detail/function_impl_template.hpp b/include/turtle/detail/function_impl_template.hpp index 044195f..2a8d74a 100644 --- a/include/turtle/detail/function_impl_template.hpp +++ b/include/turtle/detail/function_impl_template.hpp @@ -44,10 +44,11 @@ namespace detail : context_( 0 ) , valid_( true ) , mutex_( boost::make_shared< mutex >() ) + , exceptions_( uncaught_exceptions() ) {} virtual ~function_impl() { - if( valid_ && ! std::uncaught_exception() ) + if( valid_ && exceptions_ >= uncaught_exceptions() ) for( expectations_cit it = expectations_.begin(); it != expectations_.end(); ++it ) if( ! it->verify() ) @@ -300,6 +301,7 @@ namespace detail expectations_type expectations_; context* context_; mutable bool valid_; + const int exceptions_; const boost::shared_ptr< mutex > mutex_; }; }