From 6a5c355e4e7deb76363f474041d00465be3b317b Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 13 Apr 2023 16:48:59 +0200 Subject: [PATCH] Add RB_WARN_CATEGORY_DEFAULT_BITS Followup: ac123f167a364c3d7a43eca78d564e41f6dbb91e RB_WARN_CATEGORY_ALL_BITS is exposed in a public header, so it makes sense for it to be updated to contain all valid bits. Instead we introduce RB_WARN_CATEGORY_DEFAULT_BITS to list the categories that are enabled by default. --- error.c | 2 +- include/ruby/internal/error.h | 6 ++++++ ruby.c | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/error.c b/error.c index 61b6592bc0..3d44b6671b 100644 --- a/error.c +++ b/error.c @@ -150,7 +150,7 @@ rb_syntax_error_append(VALUE exc, VALUE file, int line, int column, static unsigned int warning_disabled_categories = ( (1U << RB_WARN_CATEGORY_DEPRECATED) | - ~RB_WARN_CATEGORY_ALL_BITS); + ~RB_WARN_CATEGORY_DEFAULT_BITS); static unsigned int rb_warning_category_mask(VALUE category) diff --git a/include/ruby/internal/error.h b/include/ruby/internal/error.h index 8ebf7cd2ab..1ce9a30e6f 100644 --- a/include/ruby/internal/error.h +++ b/include/ruby/internal/error.h @@ -53,9 +53,15 @@ typedef enum { /** Warning is for performance issues (not enabled by -w). */ RB_WARN_CATEGORY_PERFORMANCE, + RB_WARN_CATEGORY_DEFAULT_BITS = ( + (1U << RB_WARN_CATEGORY_DEPRECATED) | + (1U << RB_WARN_CATEGORY_EXPERIMENTAL) | + 0), + RB_WARN_CATEGORY_ALL_BITS = ( (1U << RB_WARN_CATEGORY_DEPRECATED) | (1U << RB_WARN_CATEGORY_EXPERIMENTAL) | + (1U << RB_WARN_CATEGORY_PERFORMANCE) | 0) } rb_warning_category_t; diff --git a/ruby.c b/ruby.c index 5ce5fb2662..109e1734fa 100644 --- a/ruby.c +++ b/ruby.c @@ -1174,7 +1174,7 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt) warning = 1; ruby_verbose = Qtrue; } - FEATURE_SET(opt->warn, RB_WARN_CATEGORY_ALL_BITS); + FEATURE_SET(opt->warn, RB_WARN_CATEGORY_DEFAULT_BITS); s++; goto reswitch; @@ -1226,13 +1226,13 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt) warning = 1; switch (v) { case 0: - FEATURE_SET_TO(opt->warn, RB_WARN_CATEGORY_ALL_BITS, 0); + FEATURE_SET_TO(opt->warn, RB_WARN_CATEGORY_DEFAULT_BITS, 0); break; case 1: FEATURE_SET_TO(opt->warn, 1U << RB_WARN_CATEGORY_DEPRECATED, 0); break; default: - FEATURE_SET(opt->warn, RB_WARN_CATEGORY_ALL_BITS); + FEATURE_SET(opt->warn, RB_WARN_CATEGORY_DEFAULT_BITS); break; } }