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.
This commit is contained in:
Nobuyoshi Nakada 2024-10-08 15:44:40 +09:00 committed by Nobuyoshi Nakada
parent 9a90cd2284
commit 49ccc31d90

View File

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