From bbf1130f918ca26e33aba4711ccf99a8083517ea Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 5 May 2025 16:16:26 +0900 Subject: [PATCH] Add `RBIMPL_ATTR_NONSTRING_ARRAY()` macro for GCC 15 --- enc/trans/iso2022.trans | 2 +- include/ruby/internal/attr/nonstring.h | 6 ++++++ symbol.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/enc/trans/iso2022.trans b/enc/trans/iso2022.trans index b0c635d574..bc42bbc19c 100644 --- a/enc/trans/iso2022.trans +++ b/enc/trans/iso2022.trans @@ -437,7 +437,7 @@ rb_cp50221_encoder = { /* JIS0201 to JIS0208 conversion table */ enum {tbl0208_num = 0xDF - 0xA1 + 1}; -RBIMPL_ATTR_NONSTRING() static const char tbl0208[tbl0208_num][2] = { +RBIMPL_ATTR_NONSTRING_ARRAY() static const char tbl0208[tbl0208_num][2] = { "\x21\x23", "\x21\x56", "\x21\x57", "\x21\x22", "\x21\x26", "\x25\x72", "\x25\x21", "\x25\x23", "\x25\x25", "\x25\x27", "\x25\x29", "\x25\x63", diff --git a/include/ruby/internal/attr/nonstring.h b/include/ruby/internal/attr/nonstring.h index de26e926d4..9a66180e19 100644 --- a/include/ruby/internal/attr/nonstring.h +++ b/include/ruby/internal/attr/nonstring.h @@ -25,8 +25,14 @@ /** Wraps (or simulates) `__attribute__((nonstring))` */ #if RBIMPL_HAS_ATTRIBUTE(nonstring) # define RBIMPL_ATTR_NONSTRING() __attribute__((nonstring)) +# if RBIMPL_COMPILER_SINCE(GCC, 15, 0, 0) +# define RBIMPL_ATTR_NONSTRING_ARRAY() RBIMPL_ATTR_NONSTRING() +# else +# define RBIMPL_ATTR_NONSTRING_ARRAY() /* void */ +# endif #else # define RBIMPL_ATTR_NONSTRING() /* void */ +# define RBIMPL_ATTR_NONSTRING_ARRAY() /* void */ #endif #endif /* RBIMPL_ATTR_NONSTRING_H */ diff --git a/symbol.c b/symbol.c index 12dea88158..7925db451d 100644 --- a/symbol.c +++ b/symbol.c @@ -172,7 +172,7 @@ rb_id_attrset(ID id) /* make new symbol and ID */ if (!(str = lookup_id_str(id))) { - static const char id_types[][8] = { + RBIMPL_ATTR_NONSTRING_ARRAY() static const char id_types[][8] = { "local", "instance", "invalid",