Fix preprocessor checks for Clang builtins
authorJonathan Wakely <jwakely@redhat.com>
Tue, 2 Jul 2019 11:50:27 +0000 (12:50 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 2 Jul 2019 11:50:27 +0000 (12:50 +0100)
Clang seems to define built-ins that start with "__builtin_" as
non-keywords, which means that we need to use __has_builtin to detect
them, not __is_identifier. The built-ins that don't start with
"__builtin_" are keywords, and can only be detected using
__is_identifier and not by __has_builtin.

* include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_LAUNDER)
(_GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED): Use __has_builtin
instead of __is_identifier to detect Clang support.

From-SVN: r272931

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/c++config

index 8d36a12c724646c932d8e7887441b2d0eab53077..0a31f6bdb769bb1d21176a4c34964673dc9f172f 100644 (file)
@@ -1,3 +1,9 @@
+2019-07-02  Jonathan Wakely  <jwakely@redhat.com>
+
+       * include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_LAUNDER)
+       (_GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED): Use __has_builtin
+       instead of __is_identifier to detect Clang support.
+
 2019-07-02  Jim Wilson  <jimw@sifive.com>
 
        * configure.ac (BUILD_PDF): Also test for doxygen, dot, xsltproc,
index 746e35efbfc893153ec65dc85ebe8ade30d24222..c8e099aaadd31ba0961f3167d1b713b982fbdab5 100644 (file)
@@ -636,7 +636,7 @@ namespace std
 # if __GNUC__ >= 9
 #  define _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED 1
 # endif
-#elif defined(__is_identifier)
+#elif defined(__is_identifier) && defined(__has_builtin)
 // For non-GNU compilers:
 # if ! __is_identifier(__has_unique_object_representations)
 #  define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
@@ -644,10 +644,10 @@ namespace std
 # if ! __is_identifier(__is_aggregate)
 #  define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
 # endif
-# if ! __is_identifier(__builtin_launder)
+# if __has_builtin(__builtin_launder)
 #  define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
 # endif
-# if ! __is_identifier(__builtin_is_constant_evaluated)
+# if __has_builtin(__builtin_is_constant_evaluated)
 #  define _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED 1
 # endif
 #endif // GCC