summaryrefslogtreecommitdiff
path: root/include/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-04-30 13:23:07 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-04-30 22:46:39 +0200
commit6a113a4f14808ac7f4bbdb4a5baff9383541d49a (patch)
tree06f473da02ca5a93299ab85c8a366ae782bd8380 /include/sal
parentf4880d0804478ba1edcb9f676278b77bd2bd7343 (diff)
throw() -> noexcept, part 1/3: Manual scaffolding
The legacy `throw()` dynamic exception specification is gone for good from C++20 (even if compilers typically still accept it, but e.g. Clang has -Wdeprecated-dynamic-exception-spec to at least warn about it). Introduce SAL_NOEXCEPT for use in URE interface include files. (For both the existing SAL_THROW_EXTERN_C and the new SAL_NOEXCEPT, base usage of `noexept` not on LIBO_INTERNAL_ONLY, but on the actual compiler C++ version, so that e.g. building CppunitTest_cppu_any-external, which uses gb_CppunitTest_set_external_code but not gb_CXX03FLAGS, will not potentially complain about those macros expanding to the legacy `throw()`, like when building with Clang -Wdeprecated-dynamic-exception-spec manually enabled.) Change-Id: I7e5c7f8d5f0fd622cfc9987d656b1f68541375aa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114908 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/sal')
-rw-r--r--include/sal/types.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/sal/types.h b/include/sal/types.h
index 7733920f20be..5fac8e8f9d3b 100644
--- a/include/sal/types.h
+++ b/include/sal/types.h
@@ -328,7 +328,11 @@ typedef struct _sal_Sequence
This is a macro so it can expand to nothing in C code.
*/
#if defined __cplusplus
+#if __cplusplus >= 201103L
+#define SAL_THROW_EXTERN_C() noexcept
+#else
#define SAL_THROW_EXTERN_C() throw ()
+#endif
#else
#define SAL_THROW_EXTERN_C()
#endif
@@ -400,6 +404,18 @@ namespace css = ::com::sun::star;
#define SAL_CONSTEXPR
#endif
+/** Macro for C++11 "noexcept" vs. "throw ()" exception specification.
+
+ The latter has has been removed completely from C++20.
+
+ @since LibreOffice 7.2
+ */
+#if __cplusplus >= 201103L
+#define SAL_NOEXCEPT noexcept
+#else
+#define SAL_NOEXCEPT throw ()
+#endif
+
#endif /* __cplusplus */
#ifdef __cplusplus