From d6f8ef89919919b7cde9ac7ca8621ba2e76a2b85 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 6 Aug 2020 20:55:13 +0200 Subject: [PATCH] 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. --- ChangeLog | 8 ++++++++ lib/c++defs.h | 4 ++-- lib/c-strcaseeq.h | 2 +- lib/streq.h | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 12b4bf3870..26e33d964f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2020-08-06 Bruno Haible + + 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. + 2020-08-06 Bruno Haible safe-alloc: Remove unused code. diff --git a/lib/c++defs.h b/lib/c++defs.h index 402cae4bd5..75d6250ece 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 , 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 , 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 3c33b6eacf..897dc99ba9 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 cf15c0df66..978267b675 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) -- 2.39.5