merge revision(s) bbf1130f918ca26e33aba4711ccf99a8083517ea, 43dbb9a93f4de3f1170d7d18641c30e81cc08365, 2bb6fe3854e2a4854bb89bfce4eaaea9d848fd1b, 7c9dd0ecff61153b96473c6c51d5582e809da489: [Backport #21629]

[PATCH] Add `RBIMPL_ATTR_NONSTRING_ARRAY()` macro for GCC 15

	[PATCH] [Bug #21629] Enable `nonstring` attribute on clang 21

	[PATCH] [Bug #21629] Initialize `struct RString`

	[PATCH] [Bug #21629] Initialize `struct RArray`
This commit is contained in:
Takashi Kokubun 2025-10-08 16:45:24 -07:00
parent 9b5d6505ef
commit 846bb76075
5 changed files with 13 additions and 5 deletions

View File

@ -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",

View File

@ -25,8 +25,16 @@
/** 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()
# elif RBIMPL_COMPILER_SINCE(Clang, 21, 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 */

View File

@ -156,7 +156,7 @@ rb_id_attrset(ID id)
/* make new symbol and ID */
if (!(str = lookup_id_str(id))) {
RBIMPL_ATTR_NONSTRING() static const char id_types[][8] = {
RBIMPL_ATTR_NONSTRING_ARRAY() static const char id_types[][8] = {
"local",
"instance",
"invalid",

View File

@ -11,7 +11,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 7
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
#define RUBY_PATCHLEVEL 58
#define RUBY_PATCHLEVEL 59
#include "ruby/version.h"
#include "ruby/internal/abi.h"

View File

@ -6259,7 +6259,7 @@ static VALUE
vm_opt_newarray_include_p(rb_execution_context_t *ec, rb_num_t num, const VALUE *ptr, VALUE target)
{
if (BASIC_OP_UNREDEFINED_P(BOP_INCLUDE_P, ARRAY_REDEFINED_OP_FLAG)) {
struct RArray fake_ary;
struct RArray fake_ary = {RBASIC_INIT};
VALUE ary = rb_setup_fake_ary(&fake_ary, ptr, num);
return rb_ary_includes(ary, target);
}
@ -6279,7 +6279,7 @@ static VALUE
vm_opt_newarray_pack_buffer(rb_execution_context_t *ec, rb_num_t num, const VALUE *ptr, VALUE fmt, VALUE buffer)
{
if (BASIC_OP_UNREDEFINED_P(BOP_PACK, ARRAY_REDEFINED_OP_FLAG)) {
struct RArray fake_ary;
struct RArray fake_ary = {RBASIC_INIT};
VALUE ary = rb_setup_fake_ary(&fake_ary, ptr, num);
return rb_ec_pack_ary(ec, ary, fmt, (UNDEF_P(buffer) ? Qnil : buffer));
}