summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-04-19 09:02:29 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-04-19 20:46:37 +0300
commitaaa432bc82d224955ebcbfaa67373b1d869e725c (patch)
treeb043c05851cfa51d7573c1fcdd4a168fc4bb6548 /include
parent8fe38c6fbd7725fa4c3d4e8132d440251e73e807 (diff)
downloadbdwgc-aaa432bc82d224955ebcbfaa67373b1d869e725c.tar.gz
Fix 'C++17 does not allow dynamic exc spec' warn if GC_NO_INLINE_STD_NEW
(fix of commit 17364f061) * gc_cpp.cc: Do not include <new> directly. * gc_cpp.cc [!GC_INCLUDE_NEW] (GC_INCLUDE_NEW): Define macro. * gc_cpp.cc (GC_DECL_NEW_THROW): Move definition to gc_cpp.h. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)] (GC_DECL_INLINE_NEW_THROW): Do not define. * include/gc/gc_cpp.h [GC_NEW_DELETE_NEED_THROW && !(__cplusplus>=201703L || _MSVC_LANG>=201703L) && !GC_INCLUDE_NEW] (GC_DECL_NEW_THROW): Define to empty. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)] (operator new, operator new[]): Replace GC_DECL_INLINE_NEW_THROW attribute to GC_DECL_NEW_THROW.
Diffstat (limited to 'include')
-rw-r--r--include/gc/gc_cpp.h22
1 files changed, 14 insertions, 8 deletions
diff --git a/include/gc/gc_cpp.h b/include/gc/gc_cpp.h
index 99df1aa5..ea05989e 100644
--- a/include/gc/gc_cpp.h
+++ b/include/gc/gc_cpp.h
@@ -175,6 +175,18 @@ by UseGC. GC is an alias for UseGC, unless GC_NAME_CONFLICT is defined.
# define GC_NEW_DELETE_NEED_THROW
#endif
+#ifndef GC_NEW_DELETE_NEED_THROW
+# define GC_DECL_NEW_THROW /* empty */
+#elif __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)
+#elif defined(GC_INCLUDE_NEW)
+# define GC_DECL_NEW_THROW throw(std::bad_alloc)
+#else
+# define GC_DECL_NEW_THROW /* empty (as bad_alloc might be undeclared) */
+#endif
+
#if defined(GC_NEW_ABORTS_ON_OOM) || defined(_LIBCPP_NO_EXCEPTIONS)
# define GC_OP_NEW_OOM_CHECK(obj) \
do { if (!(obj)) GC_abort_on_oom(); } while (0)
@@ -301,14 +313,8 @@ inline void* operator new(GC_SIZE_T, GC_NS_QUALIFY(GCPlacement),
// Inlining done to avoid mix up of new and delete operators by VC++ 9
// (due to arbitrary ordering during linking).
-# if defined(GC_NEW_DELETE_NEED_THROW) && defined(GC_INCLUDE_NEW)
-# define GC_DECL_INLINE_NEW_THROW throw(std::bad_alloc)
-# else
-# define GC_DECL_INLINE_NEW_THROW /* empty */
-# endif
-
# ifdef GC_OPERATOR_NEW_ARRAY
- inline void* operator new[](GC_SIZE_T size) GC_DECL_INLINE_NEW_THROW
+ inline void* operator new[](GC_SIZE_T size) GC_DECL_NEW_THROW
{
void* obj = GC_MALLOC_UNCOLLECTABLE(size);
GC_OP_NEW_OOM_CHECK(obj);
@@ -321,7 +327,7 @@ inline void* operator new(GC_SIZE_T, GC_NS_QUALIFY(GCPlacement),
}
# endif // GC_OPERATOR_NEW_ARRAY
- inline void* operator new(GC_SIZE_T size) GC_DECL_INLINE_NEW_THROW
+ inline void* operator new(GC_SIZE_T size) GC_DECL_NEW_THROW
{
void* obj = GC_MALLOC_UNCOLLECTABLE(size);
GC_OP_NEW_OOM_CHECK(obj);