summaryrefslogtreecommitdiff
path: root/gc_cpp.cc
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2020-04-15 10:29:21 +0300
committerIvan Maidanski <ivmai@mail.ru>2020-04-15 13:34:15 +0300
commit7f2bdaba3d584b4ad7273ebf1deb1af1ada633ee (patch)
treef73a676416066996b0db8d5dfa7b7832cc92abf5 /gc_cpp.cc
parent569490aadc50550354d8dc31601d24a3aa8542a9 (diff)
downloadbdwgc-7f2bdaba3d584b4ad7273ebf1deb1af1ada633ee.tar.gz
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.
Diffstat (limited to 'gc_cpp.cc')
-rw-r--r--gc_cpp.cc12
1 files changed, 6 insertions, 6 deletions
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);