[Libreoffice-commits] core.git: codemaker/source include/sal

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 30 20:47:18 UTC 2021


 codemaker/source/cppumaker/cpputype.cxx |    2 +-
 include/sal/types.h                     |   16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

New commits:
commit 6a113a4f14808ac7f4bbdb4a5baff9383541d49a
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Apr 30 13:23:07 2021 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Apr 30 22:46:39 2021 +0200

    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 at redhat.com>

diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index 1ab587040b82..be1b2c2b5cc2 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -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";
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


More information about the Libreoffice-commits mailing list