diff options
author | Jason Merrill <jason@redhat.com> | 2023-12-19 15:33:07 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2023-12-20 21:06:35 -0500 |
commit | 32bab8b57ddf0df727f5eaf99a77e70882c4e6e2 (patch) | |
tree | adff706ff8049350430d5825460086026d4fa9df /gcc | |
parent | 7ad9058c042d473395ee90a4d2cdd33a456c3f7d (diff) | |
download | gcc-32bab8b57ddf0df727f5eaf99a77e70882c4e6e2.zip gcc-32bab8b57ddf0df727f5eaf99a77e70882c4e6e2.tar.gz gcc-32bab8b57ddf0df727f5eaf99a77e70882c4e6e2.tar.bz2 |
opts: -Werror=foo always implies -Wfoo [PR106213]
-Werror=foo implying -Wfoo wasn't working for -Wdeprecated-copy-dtor,
because it is specified as the value 2 of warn_deprecated_copy, which shows
up as CLVC_EQUAL, which is not one of the three var_types handled by
control_warning_option. It seems to me that we can just unconditionally
handle_generated_option, and only have special argument handling for those
types.
PR c++/106213
gcc/ChangeLog:
* opts-common.cc (control_warning_option): Call
handle_generated_option for all cl_var_types.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/depr-copy5.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/opts-common.cc | 12 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/depr-copy5.C | 16 |
2 files changed, 22 insertions, 6 deletions
diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc index f0c5f48..cc3216c 100644 --- a/gcc/opts-common.cc +++ b/gcc/opts-common.cc @@ -1907,14 +1907,14 @@ control_warning_option (unsigned int opt_index, int kind, const char *arg, diagnostic_classify_diagnostic (dc, opt_index, (diagnostic_t) kind, loc); if (imply) { + /* -Werror=foo implies -Wfoo. */ const struct cl_option *option = &cl_options[opt_index]; + HOST_WIDE_INT value = 1; - /* -Werror=foo implies -Wfoo. */ if (option->var_type == CLVC_INTEGER || option->var_type == CLVC_ENUM || option->var_type == CLVC_SIZE) { - HOST_WIDE_INT value = 1; if (arg && *arg == '\0' && !option->cl_missing_ok) arg = NULL; @@ -1961,11 +1961,11 @@ control_warning_option (unsigned int opt_index, int kind, const char *arg, return; } } - - handle_generated_option (opts, opts_set, - opt_index, arg, value, lang_mask, - kind, loc, handlers, false, dc); } + + handle_generated_option (opts, opts_set, + opt_index, arg, value, lang_mask, + kind, loc, handlers, false, dc); } } diff --git a/gcc/testsuite/g++.dg/cpp0x/depr-copy5.C b/gcc/testsuite/g++.dg/cpp0x/depr-copy5.C new file mode 100644 index 0000000..377bf5d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/depr-copy5.C @@ -0,0 +1,16 @@ +// PR c++/106213 +// { dg-additional-options -Werror=deprecated-copy-dtor } +// { dg-prune-output "warnings being treated as errors" } + +struct s { + int* i; + s(); + ~s() { delete i; } +}; + + +void bar(){ + s instance; + s instance2 = instance; + // { dg-error "deprecated-copy-dtor" "" { target c++11 } .-1 } +} |