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>
This commit is contained in:
@@ -1173,7 +1173,7 @@ void InterfaceType::dumpDeclaration(FileStream & out)
|
||||
out << "protected:\n";
|
||||
inc();
|
||||
out << indent() << "~" << id_
|
||||
<< ("() throw () {} // avoid warnings about virtual members and"
|
||||
<< ("() SAL_NOEXCEPT {} // avoid warnings about virtual members and"
|
||||
" non-virtual dtor\n");
|
||||
dec();
|
||||
out << "};\n\n";
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user