public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH RFA] opts: -Werror=foo always implies -Wfoo [PR106213]
@ 2023-12-19 22:17 Jason Merrill
  2023-12-20 23:55 ` Joseph Myers
  2024-01-03 20:14 ` Jeff Law
  0 siblings, 2 replies; 3+ messages in thread
From: Jason Merrill @ 2023-12-19 22:17 UTC (permalink / raw)
  To: gcc-patches, Joseph Myers

Tested x86_64-pc-linux-gnu, OK for trunk?

-- 8< --

-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.
---
 gcc/opts-common.cc                      | 14 +++++++-------
 gcc/testsuite/g++.dg/cpp0x/depr-copy5.C | 16 ++++++++++++++++
 2 files changed, 23 insertions(+), 7 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/depr-copy5.C

diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc
index f0c5f483665..cc3216cf1f1 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)
     {
-      const struct cl_option *option = &cl_options[opt_index];
-
       /* -Werror=foo implies -Wfoo.  */
+      const struct cl_option *option = &cl_options[opt_index];
+      HOST_WIDE_INT value = 1;
+
       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 00000000000..377bf5dbec1
--- /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 }
+}

base-commit: 1502d724df85163b14b04e8f67072ca88eac411d
-- 
2.39.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH RFA] opts: -Werror=foo always implies -Wfoo [PR106213]
  2023-12-19 22:17 [PATCH RFA] opts: -Werror=foo always implies -Wfoo [PR106213] Jason Merrill
@ 2023-12-20 23:55 ` Joseph Myers
  2024-01-03 20:14 ` Jeff Law
  1 sibling, 0 replies; 3+ messages in thread
From: Joseph Myers @ 2023-12-20 23:55 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

On Tue, 19 Dec 2023, Jason Merrill wrote:

> Tested x86_64-pc-linux-gnu, OK for trunk?
> 
> -- 8< --
> 
> -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.

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH RFA] opts: -Werror=foo always implies -Wfoo [PR106213]
  2023-12-19 22:17 [PATCH RFA] opts: -Werror=foo always implies -Wfoo [PR106213] Jason Merrill
  2023-12-20 23:55 ` Joseph Myers
@ 2024-01-03 20:14 ` Jeff Law
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Law @ 2024-01-03 20:14 UTC (permalink / raw)
  To: Jason Merrill, gcc-patches, Joseph Myers



On 12/19/23 15:17, Jason Merrill wrote:
> Tested x86_64-pc-linux-gnu, OK for trunk?
> 
> -- 8< --
> 
> -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.
OK
jeff

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-03 20:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-19 22:17 [PATCH RFA] opts: -Werror=foo always implies -Wfoo [PR106213] Jason Merrill
2023-12-20 23:55 ` Joseph Myers
2024-01-03 20:14 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).