diff mbox

Add RejectNegative to some common.opt entries

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

Commit Message

Joseph Myers June 11, 2010, 8:10 p.m. UTC
In the course of other options changes I found that several options in
common.opt had Joined and UInteger but not RejectNegative.  The
combination of Joined or Separate with UInteger means that an unsigned
integer operand is read and its value overrides the 0 from a
-fno-/-Wno- option or the 1 from the positive form of an option; that
is, options such as -fno-abi-version=N act exactly the same as
-fabi-version=N.  I believe the "no-" forms of the options in question
are nonsensical and should be rejected, which this patch does.  There
are options with arguments for which "no-" versions make sense - such
as -Wno-error= - but most -[fmW] options with arguments should be
using RejectNegative.  (The correct negative form of all
-Wstrict-aliasing=N is just plain -Wno-strict-aliasing, which comes
from the Wstrict-aliasing entry in common.opt not Wstrict-aliasing=,
for example.)

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

2010-06-11  Joseph Myers  <joseph@codesourcery.com>

	* common.opt (Wstrict-aliasing=, Wstrict-overflow=, fabi-version=,
	flto-compression-level=, ftree-parallelize-loops=): Add
	RejectNegative.

testsuite:
2010-06-11  Joseph Myers  <joseph@codesourcery.com>

	* gcc.dg/opts-1.c: New test.

Comments

Richard Biener June 11, 2010, 11:24 p.m. UTC | #1
On Fri, Jun 11, 2010 at 10:10 PM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> In the course of other options changes I found that several options in
> common.opt had Joined and UInteger but not RejectNegative.  The
> combination of Joined or Separate with UInteger means that an unsigned
> integer operand is read and its value overrides the 0 from a
> -fno-/-Wno- option or the 1 from the positive form of an option; that
> is, options such as -fno-abi-version=N act exactly the same as
> -fabi-version=N.  I believe the "no-" forms of the options in question
> are nonsensical and should be rejected, which this patch does.  There
> are options with arguments for which "no-" versions make sense - such
> as -Wno-error= - but most -[fmW] options with arguments should be
> using RejectNegative.  (The correct negative form of all
> -Wstrict-aliasing=N is just plain -Wno-strict-aliasing, which comes
> from the Wstrict-aliasing entry in common.opt not Wstrict-aliasing=,
> for example.)
>
> Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  OK to
> commit?

Ok.

Thanks,
Richard.

> 2010-06-11  Joseph Myers  <joseph@codesourcery.com>
>
>        * common.opt (Wstrict-aliasing=, Wstrict-overflow=, fabi-version=,
>        flto-compression-level=, ftree-parallelize-loops=): Add
>        RejectNegative.
>
> testsuite:
> 2010-06-11  Joseph Myers  <joseph@codesourcery.com>
>
>        * gcc.dg/opts-1.c: New test.
>
> Index: common.opt
> ===================================================================
> --- common.opt  (revision 160599)
> +++ common.opt  (working copy)
> @@ -173,7 +173,7 @@
>  Warn about code which might break strict aliasing rules
>
>  Wstrict-aliasing=
> -Common Joined UInteger Var(warn_strict_aliasing) Init(-1) Warning
> +Common Joined RejectNegative UInteger Var(warn_strict_aliasing) Init(-1) Warning
>  Warn about code which might break strict aliasing rules
>
>  Wstrict-overflow
> @@ -181,7 +181,7 @@
>  Warn about optimizations that assume that signed overflow is undefined
>
>  Wstrict-overflow=
> -Common Joined UInteger Var(warn_strict_overflow) Init(-1) Warning
> +Common Joined RejectNegative UInteger Var(warn_strict_overflow) Init(-1) Warning
>  Warn about optimizations that assume that signed overflow is undefined
>
>  Wsuggest-attribute=const
> @@ -301,7 +301,7 @@
>  ; Additional positive integers will be assigned as new versions of
>  ; the ABI become the default version of the ABI.
>  fabi-version=
> -Common Joined UInteger Var(flag_abi_version) Init(2)
> +Common Joined RejectNegative UInteger Var(flag_abi_version) Init(2)
>
>  falign-functions
>  Common Report Var(align_functions,0) Optimization UInteger
> @@ -790,7 +790,7 @@
>
>  ; The initial value of -1 comes from Z_DEFAULT_COMPRESSION in zlib.h.
>  flto-compression-level=
> -Common Joined UInteger Var(flag_lto_compression_level) Init(-1)
> +Common Joined RejectNegative UInteger Var(flag_lto_compression_level) Init(-1)
>  -flto-compression-level=<number>       Use zlib compression level <number> for IL
>
>  flto-report
> @@ -1334,7 +1334,7 @@
>  Enable loop optimizations on tree level
>
>  ftree-parallelize-loops=
> -Common Report Joined UInteger Var(flag_tree_parallelize_loops) Init(1)
> +Common Report Joined RejectNegative UInteger Var(flag_tree_parallelize_loops) Init(1)
>  Enable automatic parallelization of loops
>
>  ftree-phiprop
> Index: testsuite/gcc.dg/opts-1.c
> ===================================================================
> --- testsuite/gcc.dg/opts-1.c   (revision 0)
> +++ testsuite/gcc.dg/opts-1.c   (revision 0)
> @@ -0,0 +1,9 @@
> +/* Test negative forms of various options are rejected.  */
> +/* { dg-do compile } */
> +/* { dg-options "-Wno-strict-aliasing=1 -Wno-strict-overflow=1 -fno-abi-version=1 -fno-lto-compression-level=1 -fno-tree-parallelize-loops=1" } */
> +
> +/* { 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 } */
>
> --
> Joseph S. Myers
> joseph@codesourcery.com
>
diff mbox

Patch

Index: common.opt
===================================================================
--- common.opt	(revision 160599)
+++ common.opt	(working copy)
@@ -173,7 +173,7 @@ 
 Warn about code which might break strict aliasing rules
 
 Wstrict-aliasing=
-Common Joined UInteger Var(warn_strict_aliasing) Init(-1) Warning
+Common Joined RejectNegative UInteger Var(warn_strict_aliasing) Init(-1) Warning
 Warn about code which might break strict aliasing rules
 
 Wstrict-overflow
@@ -181,7 +181,7 @@ 
 Warn about optimizations that assume that signed overflow is undefined
 
 Wstrict-overflow=
-Common Joined UInteger Var(warn_strict_overflow) Init(-1) Warning
+Common Joined RejectNegative UInteger Var(warn_strict_overflow) Init(-1) Warning
 Warn about optimizations that assume that signed overflow is undefined
 
 Wsuggest-attribute=const
@@ -301,7 +301,7 @@ 
 ; Additional positive integers will be assigned as new versions of
 ; the ABI become the default version of the ABI.
 fabi-version=
-Common Joined UInteger Var(flag_abi_version) Init(2)
+Common Joined RejectNegative UInteger Var(flag_abi_version) Init(2)
 
 falign-functions
 Common Report Var(align_functions,0) Optimization UInteger
@@ -790,7 +790,7 @@ 
 
 ; The initial value of -1 comes from Z_DEFAULT_COMPRESSION in zlib.h.
 flto-compression-level=
-Common Joined UInteger Var(flag_lto_compression_level) Init(-1)
+Common Joined RejectNegative UInteger Var(flag_lto_compression_level) Init(-1)
 -flto-compression-level=<number>	Use zlib compression level <number> for IL
 
 flto-report
@@ -1334,7 +1334,7 @@ 
 Enable loop optimizations on tree level
 
 ftree-parallelize-loops=
-Common Report Joined UInteger Var(flag_tree_parallelize_loops) Init(1)
+Common Report Joined RejectNegative UInteger Var(flag_tree_parallelize_loops) Init(1)
 Enable automatic parallelization of loops
 
 ftree-phiprop
Index: testsuite/gcc.dg/opts-1.c
===================================================================
--- testsuite/gcc.dg/opts-1.c	(revision 0)
+++ testsuite/gcc.dg/opts-1.c	(revision 0)
@@ -0,0 +1,9 @@ 
+/* Test negative forms of various options are rejected.  */
+/* { dg-do compile } */
+/* { dg-options "-Wno-strict-aliasing=1 -Wno-strict-overflow=1 -fno-abi-version=1 -fno-lto-compression-level=1 -fno-tree-parallelize-loops=1" } */
+
+/* { 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 } */