From 661e07c97e1cc742290d045dc5102e5fbdbae6a1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 9 Jan 2020 19:08:54 +0900 Subject: [PATCH] Moved the definition of `rb_define_method_if_constexpr` Inside the block where `RB_METHOD_DEFINITION_DECL` family are defined. --- include/ruby/intern.h | 4 ++++ include/ruby/ruby.h | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/ruby/intern.h b/include/ruby/intern.h index 2f60fb569e..7854d63764 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -1052,6 +1052,10 @@ extern "C++" { } #endif +#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P) +#define rb_define_method_if_constexpr(x, t, f) __builtin_choose_expr(__builtin_choose_expr(__builtin_constant_p(x),(x),0),(t),(f)) +#endif + #define RB_UNWRAP_MACRO(...) __VA_ARGS__ #ifdef __cplusplus diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 625636fcdc..ada86dab95 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -2703,7 +2703,6 @@ RB_METHOD_DEFINITION_DECL(rb_define_method, (2,3), (VALUE klass, const char *nam #ifdef __cplusplus #define rb_define_method(m, n, f, a) rb_define_method_tmpl::define(m, n, f) #else -#define rb_define_method_if_constexpr(x, t, f) __builtin_choose_expr(__builtin_choose_expr(__builtin_constant_p(x),(x),0),(t),(f)) #define rb_define_method_choose_prototype15(n) rb_define_method_if_constexpr((n)==15,rb_define_method15,rb_define_methodm3) #define rb_define_method_choose_prototype14(n) rb_define_method_if_constexpr((n)==14,rb_define_method14,rb_define_method_choose_prototype15(n)) #define rb_define_method_choose_prototype13(n) rb_define_method_if_constexpr((n)==13,rb_define_method13,rb_define_method_choose_prototype14(n))