aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2023-08-25 13:28:12 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2023-08-25 17:27:53 +0900
commitfa2712981fc109368bf914e59577fcfdbf82379a (patch)
tree8e8fa26e8ca40e004c6e5bf20209a9b7ca501562 /include
parentb88bdf1ebba52a447a39c1fee815dd55bd48ff9e (diff)
downloadruby-fa2712981fc109368bf914e59577fcfdbf82379a.tar.gz
workaround clang-17 -Wc2x-extensions
cf: https://github.com/llvm/llvm-project/commit/874217f99b99ab3c9026dc3b7bd84cd2beebde6e
Diffstat (limited to 'include')
-rw-r--r--include/ruby/internal/has/c_attribute.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/ruby/internal/has/c_attribute.h b/include/ruby/internal/has/c_attribute.h
index c5c48867bf..69b0f402cd 100644
--- a/include/ruby/internal/has/c_attribute.h
+++ b/include/ruby/internal/has/c_attribute.h
@@ -21,11 +21,23 @@
* @brief Defines #RBIMPL_HAS_C_ATTRIBUTE.
*/
+#include "ruby/internal/has/extension.h"
+#include "ruby/internal/has/warning.h"
+
/** Wraps (or simulates) `__has_c_attribute`. */
#if defined(__cplusplus)
# /* Makes no sense. */
# define RBIMPL_HAS_C_ATTRIBUTE(_) 0
+#elif RBIMPL_HAS_EXTENSION(c_attributes)
+# /* Hmm. It seems Clang 17 has this macro defined even when -std=c99 mode,
+# * _and_ fails to compile complaining that attributes are C2X feature. We
+# * need to work around this nonsense. */
+# define RBIMPL_HAS_C_ATTRIBUTE(_) __has_c_attribute(_)
+
+#elif RBIMPL_HAS_WARNING("-Wc2x-extensions")
+# define RBIMPL_HAS_C_ATTRIBUTE(_) 0
+
#elif defined(__has_c_attribute)
# define RBIMPL_HAS_C_ATTRIBUTE(_) __has_c_attribute(_)