From 7f2bdaba3d584b4ad7273ebf1deb1af1ada633ee Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 15 Apr 2020 10:29:21 +0300 Subject: Check _MSVC_LANG macro in addition to __cplusplus (MS VC) Issue #314 (bdgwc). MS VC defines __cplusplus to 199711L by default (unless /Zc:__cplusplus is passed to the compiler). * gc_cpp.cc [GC_NEW_DELETE_NEED_THROW && _MSVC_LANG>=201703] (GC_DECL_NEW_THROW): Define to noexcept(false) instead of throw(bad_alloc). * gc_cpp.cc [!_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW]: Change __cplusplus>201103 to __cplusplus>=201402. * include/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)]: Likewise. * gc_cpp.cc [(!_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW) && _MSVC_LANG>=201402] (delete(void*,size_t)): Define. * gc_cpp.cc [(!_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW) && _MSVC_LANG>=201402 && GC_OPERATOR_NEW_ARRAY && !CPPCHECK] (delete[](void*,size_t)): Likewise. * include/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL) && _MSVC_LANG>=201402] (delete(void*,size_t)): Likewise. * include/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL) && _MSVC_LANG>=201402 && GC_OPERATOR_NEW_ARRAY] (delete[](void*,size_t)): Likewise. * include/gc_allocator.h [!GC_ATTR_EXPLICIT && _MSVC_LANG>=201103] (GC_ATTR_EXPLICIT): Define to "explicit" instead of empty. * tests/test_cpp.cc [!GC_ATTR_EXPLICIT && _MSVC_LANG>=201103] (GC_ATTR_EXPLICIT): Likewise. * include/gc_allocator.h [!GC_NOEXCEPT && _MSC_VER && !(_HAS_EXCEPTIONS && !_HAS_EXCEPTIONS) && _MSVC_LANG>=201103] (GC_NOEXCEPT): Define to noexcept instead of throw(). * include/gc_cpp.h [!GC_NOEXCEPT && _MSC_VER && !(_HAS_EXCEPTIONS && !_HAS_EXCEPTIONS) && _MSVC_LANG>=201103] (GC_NOEXCEPT): Likewise. --- gc_cpp.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'gc_cpp.cc') diff --git a/gc_cpp.cc b/gc_cpp.cc index cbcaf4cd..71f7c5f6 100644 --- a/gc_cpp.cc +++ b/gc_cpp.cc @@ -50,12 +50,12 @@ built-in "new" and "delete". # endif # ifdef GC_NEW_DELETE_NEED_THROW -# if __cplusplus < 201703L -# define GC_DECL_NEW_THROW throw(std::bad_alloc) -# else - // The "dynamic exception" syntax was deprecated in C++11 - // and removed in C++17. +# if __cplusplus >= 201703L || _MSVC_LANG >= 201703L + // The "dynamic exception" syntax had been deprecated in C++11 + // and was removed in C++17. # define GC_DECL_NEW_THROW noexcept(false) +# else +# define GC_DECL_NEW_THROW throw(std::bad_alloc) # endif # else # define GC_DECL_NEW_THROW /* empty */ @@ -111,7 +111,7 @@ built-in "new" and "delete". } # endif // GC_OPERATOR_NEW_ARRAY -# if __cplusplus > 201103L // C++14 +# if __cplusplus >= 201402L || _MSVC_LANG >= 201402L // C++14 void operator delete(void* obj, size_t size) GC_NOEXCEPT { (void)size; // size is ignored GC_FREE(obj); -- cgit v1.2.1