[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
improve clang support (4)
From: |
Bruno Haible |
Subject: |
improve clang support (4) |
Date: |
Thu, 06 Aug 2020 20:59:26 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; ) |
clang defines __OPTIMIZE__ to 1 when optimizing, like GCC.
Also, it's unlikely that when clang implements __attribute__((__warning__...)),
it will exhibit the same bug as GCC
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>.
2020-08-06 Bruno Haible <bruno@clisp.org>
Consider that clang defines __OPTIMIZE__ like GCC does.
* lib/streq.h: Define the inline functions also on clang.
* lib/c-strcaseeq.h: Likewise.
* lib/c++defs.h (_GL_CXXALIASWARN_2, _GL_CXXALIASWARN1_2): Don't enable
the GCC workaround to clang.
diff --git a/lib/c++defs.h b/lib/c++defs.h
index 402cae4..75d6250 100644
--- a/lib/c++defs.h
+++ b/lib/c++defs.h
@@ -268,7 +268,7 @@
_GL_CXXALIASWARN_2 (func, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
-# if !__OPTIMIZE__
+# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define _GL_CXXALIASWARN_2(func,namespace) \
_GL_WARN_ON_USE (func, \
"The symbol ::" #func " refers to the system function. " \
@@ -296,7 +296,7 @@
_GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
-# if !__OPTIMIZE__
+# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
# define
_GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
_GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
"The symbol ::" #func " refers to the system
function. " \
diff --git a/lib/c-strcaseeq.h b/lib/c-strcaseeq.h
index 3c33b6e..897dc99 100644
--- a/lib/c-strcaseeq.h
+++ b/lib/c-strcaseeq.h
@@ -27,7 +27,7 @@
/* Help GCC to generate good code for string comparisons with
immediate strings. */
-#if defined (__GNUC__) && defined (__OPTIMIZE__)
+#if (defined __GNUC__ || defined __clang__) && defined __OPTIMIZE__
/* Case insensitive comparison of ASCII characters. */
# if C_CTYPE_ASCII
diff --git a/lib/streq.h b/lib/streq.h
index cf15c0d..978267b 100644
--- a/lib/streq.h
+++ b/lib/streq.h
@@ -29,7 +29,7 @@
/* Help GCC to generate good code for string comparisons with
immediate strings. */
-#if defined (__GNUC__) && defined (__OPTIMIZE__)
+#if (defined __GNUC__ || defined __clang__) && defined __OPTIMIZE__
static inline int
streq9 (const char *s1, const char *s2)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- improve clang support (4),
Bruno Haible <=