diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-12-17 14:52:15 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-12-19 09:52:16 +0900 |
commit | 9bf9de3d9d2f67bc401151fb94abf75b5eff5913 (patch) | |
tree | 94d1c981d7e604834c3ee9a5072f24a8fd199e63 /error.c | |
parent | 76035e5bb6a5b44621fd1c11a0553780474d1c01 (diff) | |
download | ruby-9bf9de3d9d2f67bc401151fb94abf75b5eff5913.tar.gz |
Made the warning for deprecated constants follow the category flag
Diffstat (limited to 'error.c')
-rw-r--r-- | error.c | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -129,32 +129,38 @@ rb_syntax_error_append(VALUE exc, VALUE file, int line, int column, } static unsigned int warning_disabled_categories; -#define RB_WARN_CATEGORY_DEPRECATED 1 static unsigned int rb_warning_category_mask(VALUE category) { - unsigned int mask = 0; + return 1U << rb_warning_category_from_name(category); +} + +rb_warning_category_t +rb_warning_category_from_name(VALUE category) +{ + rb_warning_category_t cat = RB_WARN_CATEGORY_NONE; Check_Type(category, T_SYMBOL); if (category == ID2SYM(rb_intern("deprecated"))) { - mask = RB_WARN_CATEGORY_DEPRECATED; + cat = RB_WARN_CATEGORY_DEPRECATED; } else { rb_raise(rb_eArgError, "unknown category: %"PRIsVALUE, category); } - return mask; + return cat; } -static int -rb_warning_category_enabled_p(VALUE category) +MJIT_FUNC_EXPORTED bool +rb_warning_category_enabled_p(rb_warning_category_t category) { - return !(warning_disabled_categories & rb_warning_category_mask(category)); + return !(warning_disabled_categories & (1U << category)); } static VALUE rb_warning_s_aref(VALUE mod, VALUE category) { - if (rb_warning_category_enabled_p(category)) + rb_warning_category_t cat = rb_warning_category_from_name(category); + if (rb_warning_category_enabled_p(cat)) return Qtrue; return Qfalse; } |