workaround clang-17 -Wc2x-extensions

cf: 874217f99b
This commit is contained in:
卜部昌平 2023-08-25 13:28:12 +09:00
parent b88bdf1ebb
commit fa2712981f
Notes: git 2023-08-25 08:28:20 +00:00
2 changed files with 13 additions and 1 deletions

View File

@ -127,7 +127,7 @@ jobs:
- { name: c99, env: { CFLAGS: '-std=c99 -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
# - { name: c11, env: { CFLAGS: '-std=c11 -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
# - { name: c17, env: { CFLAGS: '-std=c17 -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
- { name: c2x, env: { CFLAGS: '-std=c2x -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
- { name: c23, env: { CFLAGS: '-std=c2x -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
- { name: c++98, env: { CXXFLAGS: '-std=c++98 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
# - { name: c++11, env: { CXXFLAGS: '-std=c++11 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
# - { name: c++14, env: { CXXFLAGS: '-std=c++14 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }

View File

@ -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(_)