From 49ccc31d906d26f980dcedf1197a2e18245ec50e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 8 Oct 2024 15:44:40 +0900 Subject: [PATCH] Add a macro to initialize union `cfunc_type` ``` vm_insnhelper.c:2430:49: error: ISO C prohibits argument conversion to union type [-Wpedantic] 2430 | if (!vm_method_cfunc_is(cd_owner, cd, recv, rb_obj_equal)) { | ^~~~~~~~~~~~ vm_insnhelper.c:2448:42: error: ISO C prohibits argument conversion to union type [-Wpedantic] 2448 | if (cc && check_cfunc(vm_cc_cme(cc), rb_obj_equal)) { | ^~~~~~~~~~~~ ``` and so on. --- vm_insnhelper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vm_insnhelper.c b/vm_insnhelper.c index ea4ce49b63..d1c4d1ef46 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2309,8 +2309,10 @@ typedef union { VALUE (*f15)(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE); VALUE (*fm1)(int, union { VALUE *x; const VALUE *y; } __attribute__((__transparent_union__)), VALUE); } __attribute__((__transparent_union__)) cfunc_type; +# define make_cfunc_type(f) (cfunc_type){.anyargs = (VALUE (*)(ANYARGS))(f)} #else typedef VALUE (*cfunc_type)(ANYARGS); +# define make_cfunc_type(f) (cfunc_type)(f) #endif static inline int @@ -2344,6 +2346,9 @@ vm_method_cfunc_is(const rb_iseq_t *iseq, CALL_DATA cd, VALUE recv, cfunc_type f return check_cfunc(vm_cc_cme(cc), func); } +#define check_cfunc(me, func) check_cfunc(me, make_cfunc_type(func)) +#define vm_method_cfunc_is(iseq, cd, recv, func) vm_method_cfunc_is(iseq, cd, recv, make_cfunc_type(func)) + #define EQ_UNREDEFINED_P(t) BASIC_OP_UNREDEFINED_P(BOP_EQ, t##_REDEFINED_OP_FLAG) static inline bool