public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c/86134 avoid errors for unrecognized -Wno- options
@ 2020-02-14 12:02 Richard Biener
  2020-02-14 22:10 ` Joseph Myers
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2020-02-14 12:02 UTC (permalink / raw)
  To: gcc-patches; +Cc: Joseph S. Myers


This makes sure to not promote diagnostics about unrecognized -Wno-
options to errors and make the intent of the diagnostic clearer.

Bootstrapped and tested on x86_64-unknown-linux-gnu, OK for trunk?

Thanks,
Richard.

2020-02-14  Richard Biener  <rguenther@suse.de>

	PR c/86134
	* opts-global.c (print_ignored_options): Use inform and
	amend message.

	* gcc.dg/pr86134.c: New testcase.
	* gcc.dg/pr28322-2.c: Adjust.

diff --git a/gcc/opts-global.c b/gcc/opts-global.c
index d5e308bf800..52ea083a6d5 100644
--- a/gcc/opts-global.c
+++ b/gcc/opts-global.c
@@ -139,8 +139,10 @@ print_ignored_options (void)
       const char *opt;
 
       opt = ignored_options.pop ();
-      warning_at (UNKNOWN_LOCATION, 0,
-		  "unrecognized command-line option %qs", opt);
+      /* Use inform, not warning_at, to avoid promoting these to errors.  */
+      inform (UNKNOWN_LOCATION,
+	      "unrecognized command-line option %qs may have silenced "
+	      "earlier diagnostics", opt);
     }
 }
 
diff --git a/gcc/testsuite/gcc.dg/pr28322-2.c b/gcc/testsuite/gcc.dg/pr28322-2.c
index c9e5e228a7b..20adf5e92b8 100644
--- a/gcc/testsuite/gcc.dg/pr28322-2.c
+++ b/gcc/testsuite/gcc.dg/pr28322-2.c
@@ -8,5 +8,5 @@ int foo (void)
   return i;
 }
 
-/* { dg-warning "unrecognized command-line option .-Wno-foobar." "" { target *-*-* } 0 } */
+/* { dg-message "unrecognized command-line option .-Wno-foobar." "" { target *-*-* } 0 } */
 
diff --git a/gcc/testsuite/gcc.dg/pr86134.c b/gcc/testsuite/gcc.dg/pr86134.c
new file mode 100644
index 00000000000..3fd21a32306
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr86134.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-Wall -Werror -Wno-error=main -Wno-foobar" } */
+
+void main() {} /* { dg-warning "return type" } */
+
+/* { dg-message "unrecognized command-line option" "" { target *-*-* } 0 } */

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

* Re: [PATCH] c/86134 avoid errors for unrecognized -Wno- options
  2020-02-14 12:02 [PATCH] c/86134 avoid errors for unrecognized -Wno- options Richard Biener
@ 2020-02-14 22:10 ` Joseph Myers
  2020-02-17  8:31   ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Joseph Myers @ 2020-02-14 22:10 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On Fri, 14 Feb 2020, Richard Biener wrote:

> diff --git a/gcc/opts-global.c b/gcc/opts-global.c
> index d5e308bf800..52ea083a6d5 100644
> --- a/gcc/opts-global.c
> +++ b/gcc/opts-global.c
> @@ -139,8 +139,10 @@ print_ignored_options (void)
>        const char *opt;
>  
>        opt = ignored_options.pop ();
> -      warning_at (UNKNOWN_LOCATION, 0,
> -		  "unrecognized command-line option %qs", opt);
> +      /* Use inform, not warning_at, to avoid promoting these to errors.  */
> +      inform (UNKNOWN_LOCATION,
> +	      "unrecognized command-line option %qs may have silenced "
> +	      "earlier diagnostics", opt);

I agree with the principle of the patch, but I don't like the new message 
text.  I don't think "may have silenced" is right; maybe something more 
like "may have been intended to silence".

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH] c/86134 avoid errors for unrecognized -Wno- options
  2020-02-14 22:10 ` Joseph Myers
@ 2020-02-17  8:31   ` Richard Biener
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2020-02-17  8:31 UTC (permalink / raw)
  To: Joseph Myers; +Cc: gcc-patches

On Fri, 14 Feb 2020, Joseph Myers wrote:

> On Fri, 14 Feb 2020, Richard Biener wrote:
> 
> > diff --git a/gcc/opts-global.c b/gcc/opts-global.c
> > index d5e308bf800..52ea083a6d5 100644
> > --- a/gcc/opts-global.c
> > +++ b/gcc/opts-global.c
> > @@ -139,8 +139,10 @@ print_ignored_options (void)
> >        const char *opt;
> >  
> >        opt = ignored_options.pop ();
> > -      warning_at (UNKNOWN_LOCATION, 0,
> > -		  "unrecognized command-line option %qs", opt);
> > +      /* Use inform, not warning_at, to avoid promoting these to errors.  */
> > +      inform (UNKNOWN_LOCATION,
> > +	      "unrecognized command-line option %qs may have silenced "
> > +	      "earlier diagnostics", opt);
> 
> I agree with the principle of the patch, but I don't like the new message 
> text.  I don't think "may have silenced" is right; maybe something more 
> like "may have been intended to silence".

I've pushed the following variant then.

Thanks,
Richard.

From b0215b75a41ffdddb8a5fd5bcc16dcc455e69006 Mon Sep 17 00:00:00 2001
From: Richard Biener <rguenther@suse.de>
Date: Fri, 14 Feb 2020 10:25:11 +0100
Subject: [PATCH] c/86134 avoid errors for unrecognized -Wno- options

This makes sure to not promote diagnostics about unrecognized -Wno-
options to errors and make the intent of the diagnostic clearer.

2020-02-17  Richard Biener  <rguenther@suse.de>

	PR c/86134
	* opts-global.c (print_ignored_options): Use inform and
	amend message.

	* gcc.dg/pr86134.c: New testcase.
	* gcc.dg/pr28322-2.c: Adjust.

diff --git a/gcc/opts-global.c b/gcc/opts-global.c
index d5e308bf800..c658805470e 100644
--- a/gcc/opts-global.c
+++ b/gcc/opts-global.c
@@ -139,8 +139,10 @@ print_ignored_options (void)
       const char *opt;
 
       opt = ignored_options.pop ();
-      warning_at (UNKNOWN_LOCATION, 0,
-		  "unrecognized command-line option %qs", opt);
+      /* Use inform, not warning_at, to avoid promoting these to errors.  */
+      inform (UNKNOWN_LOCATION,
+	      "unrecognized command-line option %qs may have been intended "
+	      "to silence earlier diagnostics", opt);
     }
 }
 
diff --git a/gcc/testsuite/gcc.dg/pr28322-2.c b/gcc/testsuite/gcc.dg/pr28322-2.c
index c9e5e228a7b..20adf5e92b8 100644
--- a/gcc/testsuite/gcc.dg/pr28322-2.c
+++ b/gcc/testsuite/gcc.dg/pr28322-2.c
@@ -8,5 +8,5 @@ int foo (void)
   return i;
 }
 
-/* { dg-warning "unrecognized command-line option .-Wno-foobar." "" { target *-*-* } 0 } */
+/* { dg-message "unrecognized command-line option .-Wno-foobar." "" { target *-*-* } 0 } */
 
diff --git a/gcc/testsuite/gcc.dg/pr86134.c b/gcc/testsuite/gcc.dg/pr86134.c
new file mode 100644
index 00000000000..3fd21a32306
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr86134.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-Wall -Werror -Wno-error=main -Wno-foobar" } */
+
+void main() {} /* { dg-warning "return type" } */
+
+/* { dg-message "unrecognized command-line option" "" { target *-*-* } 0 } */

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

end of thread, other threads:[~2020-02-17  8:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14 12:02 [PATCH] c/86134 avoid errors for unrecognized -Wno- options Richard Biener
2020-02-14 22:10 ` Joseph Myers
2020-02-17  8:31   ` Richard Biener

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).