Skip to content

Commit 1821551

Browse files
bjfishrschatz
authored andcommitted
Workaround for ruby issue https://bugs.ruby-lang.org/issues/17865
1 parent d772ae7 commit 1821551

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/cext/include/ruby/ruby.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,6 +2049,12 @@ VALUE rb_check_symbol(volatile VALUE *namep);
20492049
rb_intern_id_cache = rb_intern2((str), (long)strlen(str)); \
20502050
result rb_intern_id_cache; \
20512051
}
2052+
// Workaround compound-token-split-by-macro warning
2053+
#define RUBY_CONST_ID_CACHE_TOKEN_SPLIT(result, str) \
2054+
static ID rb_intern_id_cache; \
2055+
if (!polyglot_is_value((void*)rb_intern_id_cache)) \
2056+
rb_intern_id_cache = rb_intern2((str), (long)strlen(str)); \
2057+
result rb_intern_id_cache;
20522058
#else
20532059
#define RUBY_CONST_ID_CACHE(result, str) \
20542060
{ \
@@ -2065,10 +2071,17 @@ VALUE rb_check_symbol(volatile VALUE *namep);
20652071
#if defined(HAVE_BUILTIN___BUILTIN_CONSTANT_P) && defined(HAVE_STMT_AND_DECL_IN_EXPR)
20662072
/* __builtin_constant_p and statement expression is available
20672073
* since gcc-2.7.2.3 at least. */
2074+
#ifdef TRUFFLERUBY
2075+
#define rb_intern(str) \
2076+
(__builtin_constant_p(str) ? \
2077+
__extension__ ({RUBY_CONST_ID_CACHE_TOKEN_SPLIT((ID), (str))}) : \
2078+
rb_intern(str))
2079+
#else
20682080
#define rb_intern(str) \
20692081
(__builtin_constant_p(str) ? \
20702082
__extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
20712083
rb_intern(str))
2084+
#endif
20722085
#define rb_intern_const(str) \
20732086
(__builtin_constant_p(str) ? \
20742087
__extension__ (rb_intern2((str), (long)strlen(str))) : \

0 commit comments

Comments
 (0)