diff mbox

Fix RejectNegative handling for -Wno- options

Message ID Pine.LNX.4.64.1008292320010.13260@digraph.polyomino.org.uk
State New
Headers show

Commit Message

Joseph Myers Aug. 29, 2010, 11:20 p.m. UTC
My previous option-handling patches accidentally caused -Wno- versions
of -W options marked RejectNegative to be treated like -Wno- versions
of completely unknown options: quietly ignored unless some other
warning was given, and in that case diagnosed with a warning.

I don't think that is appropriate for these options; the point of
RejectNegative markings for these options that take arguments is that
we know that the negative version is not meaningful (or hopelessly
confusing and likely to be a mistake, as in the case of "-Wno-" for
"-Wno-extra"), rather than being an option that might be known to a
later GCC version.  This patch causes such options to get errors
again, independent of whether any other diagnostics are given.

Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  OK to
commit?

2010-08-29  Joseph Myers  <joseph@codesourcery.com>

	* opts.h (CL_ERR_NEGATIVE): Define.
	* opts.c (unknown_option_callback): Don't postpone warnings for
	options marked with CL_ERR_NEGATIVE.
	* opts-common.c (decode_cmdline_option): Set CL_ERR_NEGATIVE error
	for negative versions of CL_REJECT_NEGATIVE options.

testsuite:
2010-08-29  Joseph Myers  <joseph@codesourcery.com>

	* gcc.dg/opts-1.c: Expect errors, not warnings.

Comments

Richard Biener Aug. 30, 2010, 6:57 a.m. UTC | #1
On Mon, Aug 30, 2010 at 1:20 AM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> My previous option-handling patches accidentally caused -Wno- versions
> of -W options marked RejectNegative to be treated like -Wno- versions
> of completely unknown options: quietly ignored unless some other
> warning was given, and in that case diagnosed with a warning.
>
> I don't think that is appropriate for these options; the point of
> RejectNegative markings for these options that take arguments is that
> we know that the negative version is not meaningful (or hopelessly
> confusing and likely to be a mistake, as in the case of "-Wno-" for
> "-Wno-extra"), rather than being an option that might be known to a
> later GCC version.  This patch causes such options to get errors
> again, independent of whether any other diagnostics are given.
>
> Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  OK to
> commit?

Ok.

Thanks,
Richard.

> 2010-08-29  Joseph Myers  <joseph@codesourcery.com>
>
>        * opts.h (CL_ERR_NEGATIVE): Define.
>        * opts.c (unknown_option_callback): Don't postpone warnings for
>        options marked with CL_ERR_NEGATIVE.
>        * opts-common.c (decode_cmdline_option): Set CL_ERR_NEGATIVE error
>        for negative versions of CL_REJECT_NEGATIVE options.
>
> testsuite:
> 2010-08-29  Joseph Myers  <joseph@codesourcery.com>
>
>        * gcc.dg/opts-1.c: Expect errors, not warnings.
>
> Index: gcc/opts-common.c
> ===================================================================
> --- gcc/opts-common.c   (revision 163616)
> +++ gcc/opts-common.c   (working copy)
> @@ -197,6 +197,7 @@ decode_cmdline_option (const char **argv
>   if (!value && (option->flags & CL_REJECT_NEGATIVE))
>     {
>       opt_index = OPT_SPECIAL_unknown;
> +      errors |= CL_ERR_NEGATIVE;
>       arg = argv[0];
>       goto done;
>     }
> Index: gcc/testsuite/gcc.dg/opts-1.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/opts-1.c       (revision 163616)
> +++ gcc/testsuite/gcc.dg/opts-1.c       (working copy)
> @@ -5,5 +5,5 @@
>  /* { dg-error "-fno-abi-version" "-fno-abi-version" { target *-*-* } 0 } */
>  /* { dg-error "-fno-lto-compression-level" "-fno-lto-compression-level" { target *-*-* } 0 } */
>  /* { dg-error "-fno-tree-parallelize-loops" "-fno-tree-parallelize-loops" { target *-*-* } 0 } */
> -/* { dg-warning "-Wno-strict-overflow" "-Wno-strict-overflow" { target *-*-* } 0 } */
> -/* { dg-warning "-Wno-strict-aliasing" "-Wno-strict-aliasing" { target *-*-* } 0 } */
> +/* { dg-error "-Wno-strict-overflow" "-Wno-strict-overflow" { target *-*-* } 0 } */
> +/* { dg-error "-Wno-strict-aliasing" "-Wno-strict-aliasing" { target *-*-* } 0 } */
> Index: gcc/opts.c
> ===================================================================
> --- gcc/opts.c  (revision 163616)
> +++ gcc/opts.c  (working copy)
> @@ -482,7 +482,8 @@ unknown_option_callback (const struct cl
>  {
>   const char *opt = decoded->arg;
>
> -  if (opt[1] == 'W' && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
> +  if (opt[1] == 'W' && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-'
> +      && !(decoded->errors & CL_ERR_NEGATIVE))
>     {
>       /* We don't generate warnings for unknown -Wno-* options unless
>         we issue diagnostics.  */
> Index: gcc/opts.h
> ===================================================================
> --- gcc/opts.h  (revision 163616)
> +++ gcc/opts.h  (working copy)
> @@ -102,6 +102,9 @@ extern const unsigned int cl_lang_count;
>  #define CL_ERR_MISSING_ARG     (1 << 1) /* Argument required but missing.  */
>  #define CL_ERR_WRONG_LANG      (1 << 2) /* Option for wrong language.  */
>  #define CL_ERR_UINT_ARG                (1 << 3) /* Bad unsigned integer argument.  */
> +#define CL_ERR_NEGATIVE                (1 << 4) /* Negative form of option
> +                                           not permitted (together
> +                                           with OPT_SPECIAL_unknown).  */
>
>  /* Structure describing the result of decoding an option.  */
>
>
> --
> Joseph S. Myers
> joseph@codesourcery.com
>
diff mbox

Patch

Index: gcc/opts-common.c
===================================================================
--- gcc/opts-common.c	(revision 163616)
+++ gcc/opts-common.c	(working copy)
@@ -197,6 +197,7 @@  decode_cmdline_option (const char **argv
   if (!value && (option->flags & CL_REJECT_NEGATIVE))
     {
       opt_index = OPT_SPECIAL_unknown;
+      errors |= CL_ERR_NEGATIVE;
       arg = argv[0];
       goto done;
     }
Index: gcc/testsuite/gcc.dg/opts-1.c
===================================================================
--- gcc/testsuite/gcc.dg/opts-1.c	(revision 163616)
+++ gcc/testsuite/gcc.dg/opts-1.c	(working copy)
@@ -5,5 +5,5 @@ 
 /* { dg-error "-fno-abi-version" "-fno-abi-version" { target *-*-* } 0 } */
 /* { dg-error "-fno-lto-compression-level" "-fno-lto-compression-level" { target *-*-* } 0 } */
 /* { dg-error "-fno-tree-parallelize-loops" "-fno-tree-parallelize-loops" { target *-*-* } 0 } */
-/* { dg-warning "-Wno-strict-overflow" "-Wno-strict-overflow" { target *-*-* } 0 } */
-/* { dg-warning "-Wno-strict-aliasing" "-Wno-strict-aliasing" { target *-*-* } 0 } */
+/* { dg-error "-Wno-strict-overflow" "-Wno-strict-overflow" { target *-*-* } 0 } */
+/* { dg-error "-Wno-strict-aliasing" "-Wno-strict-aliasing" { target *-*-* } 0 } */
Index: gcc/opts.c
===================================================================
--- gcc/opts.c	(revision 163616)
+++ gcc/opts.c	(working copy)
@@ -482,7 +482,8 @@  unknown_option_callback (const struct cl
 {
   const char *opt = decoded->arg;
 
-  if (opt[1] == 'W' && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
+  if (opt[1] == 'W' && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-'
+      && !(decoded->errors & CL_ERR_NEGATIVE))
     {
       /* We don't generate warnings for unknown -Wno-* options unless
 	 we issue diagnostics.  */
Index: gcc/opts.h
===================================================================
--- gcc/opts.h	(revision 163616)
+++ gcc/opts.h	(working copy)
@@ -102,6 +102,9 @@  extern const unsigned int cl_lang_count;
 #define CL_ERR_MISSING_ARG	(1 << 1) /* Argument required but missing.  */
 #define CL_ERR_WRONG_LANG	(1 << 2) /* Option for wrong language.  */
 #define CL_ERR_UINT_ARG		(1 << 3) /* Bad unsigned integer argument.  */
+#define CL_ERR_NEGATIVE		(1 << 4) /* Negative form of option
+					    not permitted (together
+					    with OPT_SPECIAL_unknown).  */
 
 /* Structure describing the result of decoding an option.  */