bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

improve clang support (35)


From: Bruno Haible
Subject: improve clang support (35)
Date: Sun, 16 Aug 2020 18:58:00 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; )

clang (at least in version >= 4), in C++ mode, supports the 'throw ()' 
declaration
on functions, and uses it to optimize try/catch statements at the caller site.


2020-08-16  Bruno Haible  <bruno@clisp.org>

        Use 'throw ()' for optimization in C++ mode also on clang.
        * lib/cdefs.h (__THROW): Define to 'throw ()' also on clang.
        * lib/getopt-cdefs.in.h (__THROW): Likewise.
        * lib/md5.h (__THROW): Likewise.

diff --git a/lib/cdefs.h b/lib/cdefs.h
index dfa935f..b7f60c1 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -85,7 +85,7 @@
 #  define __NTH(fct)   __attribute__ ((__nothrow__ __LEAF)) fct
 #  define __NTHNL(fct)  __attribute__ ((__nothrow__)) fct
 # else
-#  if defined __cplusplus && __GNUC_PREREQ (2,8)
+#  if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4)
 #   define __THROW     throw ()
 #   define __THROWNL   throw ()
 #   define __NTH(fct)  __LEAF_ATTR fct throw ()
diff --git a/lib/getopt-cdefs.in.h b/lib/getopt-cdefs.in.h
index 89a7b85..641e5e9 100644
--- a/lib/getopt-cdefs.in.h
+++ b/lib/getopt-cdefs.in.h
@@ -57,7 +57,7 @@
 #endif
 
 #ifndef __THROW
-# if defined __cplusplus && __GNUC_PREREQ (2,8)
+# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
 #  define __THROW       throw ()
 # else
 #  define __THROW
diff --git a/lib/md5.h b/lib/md5.h
index 0c8b929..4631035 100644
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -40,7 +40,7 @@
 #endif
 
 #ifndef __THROW
-# if defined __cplusplus && __GNUC_PREREQ (2,8)
+# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
 #  define __THROW       throw ()
 # else
 #  define __THROW




reply via email to

[Prev in Thread] Current Thread [Next in Thread]