diff --git a/ChangeLog b/ChangeLog index 3b6bd48e51..3b43b1cea1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sat Nov 14 02:19:16 2015 Koichi Sasada + + * method.h: constify rb_cref_t::scope_visi; + + * eval_intern.h (CREF_SCOPE_VISI_COPY): catch up this fix. + + * vm_method.c: ditto. + Sat Nov 14 01:53:52 2015 Naohisa Goto * pack.c (pack_unpack, AVOID_CC_BUG): Very ugly workaround for diff --git a/eval_intern.h b/eval_intern.h index 6b5ca7fe60..d78bb39f08 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -216,7 +216,7 @@ static inline void CREF_SCOPE_VISI_COPY(rb_cref_t *dst_cref, const rb_cref_t *src_cref) { const rb_scope_visibility_t *src = &src_cref->scope_visi; - rb_scope_visibility_t *dst = &dst_cref->scope_visi; + rb_scope_visibility_t *dst = (rb_scope_visibility_t *)&dst_cref->scope_visi; /* OK for const cast */ dst->method_visi = src->method_visi; dst->module_func = src->module_func; diff --git a/method.h b/method.h index 21a02bc7d0..d36cf38297 100644 --- a/method.h +++ b/method.h @@ -42,7 +42,7 @@ typedef struct rb_cref_struct { const VALUE refinements; const VALUE klass; struct rb_cref_struct * const next; - rb_scope_visibility_t scope_visi; + const rb_scope_visibility_t scope_visi; } rb_cref_t; /* method data type */ diff --git a/vm_method.c b/vm_method.c index 7d658b003e..6c2137b7b3 100644 --- a/vm_method.c +++ b/vm_method.c @@ -1048,20 +1048,24 @@ rb_scope_module_func_check(void) return CREF_SCOPE_VISI(rb_vm_cref())->module_func; } +static void +vm_cref_set_visibility(rb_method_visibility_t method_visi, int module_func) +{ + rb_scope_visibility_t *scope_visi = (rb_scope_visibility_t *)&rb_vm_cref()->scope_visi; + scope_visi->method_visi = method_visi; + scope_visi->module_func = module_func; +} + void rb_scope_visibility_set(rb_method_visibility_t visi) { - rb_scope_visibility_t *scope_visi = &rb_vm_cref()->scope_visi; - scope_visi->method_visi = visi; - scope_visi->module_func = FALSE; + vm_cref_set_visibility(visi, FALSE); } static void rb_scope_module_func_set(void) { - rb_scope_visibility_t *scope_visi = &rb_vm_cref()->scope_visi; - scope_visi->method_visi = METHOD_VISI_PRIVATE; - scope_visi->module_func = TRUE; + vm_cref_set_visibility(METHOD_VISI_PRIVATE, TRUE); } void