]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/32102 (-Wall stomps on -Wstrict-overflow)
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Sun, 27 Jan 2008 18:36:59 +0000 (18:36 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Sun, 27 Jan 2008 18:36:59 +0000 (18:36 +0000)
2008-01-27  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

PR 32102
* flags.h (warn_strict_aliasing): Remove.
(warn_strict_overflow): Remove.
* opts.c (warn_strict_aliasing): Remove.
(warn_strict_overflow): Remove.
* c-opts.c (c_common_handle_option): -Wall only sets
-Wstrict-aliasing or -Wstrict-overflow if they are uninitialized.
(c_common_post_options): Give default values to -Wstrict-aliasing
and -Wstrict-overflow if they are uninitialized.
* common.opt (Wstrict-aliasing): Specify Var and Init.
(Wstrict-overflow): Likewise.

testsuite/
* gcc.dg/Wstrict-overflow-21.c: New.
* g++.dg/warn/Wstrict-aliasing-8.C: New.

From-SVN: r131887

gcc/ChangeLog
gcc/c-opts.c
gcc/common.opt
gcc/flags.h
gcc/opts.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wstrict-aliasing-8.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wstrict-overflow-21.c [new file with mode: 0644]

index 8fb11f3150ad2a83c1d4d800149a5e5d5abe7ba3..e969fb1169debe7a92d7b961702b521c181868b1 100644 (file)
@@ -1,3 +1,17 @@
+2008-01-27  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+
+       PR 32102
+       * flags.h (warn_strict_aliasing): Remove.
+       (warn_strict_overflow): Remove.
+       * opts.c (warn_strict_aliasing): Remove.
+       (warn_strict_overflow): Remove.
+       * c-opts.c (c_common_handle_option): -Wall only sets
+       -Wstrict-aliasing or -Wstrict-overflow if they are uninitialized.
+       (c_common_post_options): Give default values to -Wstrict-aliasing
+       and -Wstrict-overflow if they are uninitialized.
+       * common.opt (Wstrict-aliasing): Specify Var and Init.
+       (Wstrict-overflow): Likewise.
+       
 2008-01-25  Joseph Myers  <joseph@codesourcery.com>
 
        PR other/31955
index 747ca0d76ea06078ab39cb86d95c3eb595a80815..a3e6871f3375ac8bcd9bbf911e77d9c7e7dcfc33 100644 (file)
@@ -1,5 +1,5 @@
 /* C/ObjC/C++ command line option handling.
-   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
+   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
    Free Software Foundation, Inc.
    Contributed by Neil Booth.
 
@@ -392,8 +392,10 @@ c_common_handle_option (size_t scode, const char *arg, int value)
       if (c_dialect_cxx ())
        warn_sign_compare = value;
       warn_switch = value;
-      warn_strict_aliasing = value;
-      warn_strict_overflow = value;
+      if (warn_strict_aliasing == -1)
+       warn_strict_aliasing = value;
+      if (warn_strict_overflow == -1)
+       warn_strict_overflow = value;
       warn_address = value;
 
       /* Only warn about unknown pragmas that are not in system
@@ -1036,6 +1038,11 @@ c_common_post_options (const char **pfilename)
   if (warn_pointer_sign == -1)
     warn_pointer_sign = 0;
 
+  if (warn_strict_aliasing == -1)
+    warn_strict_aliasing = 0;
+  if (warn_strict_overflow == -1)
+    warn_strict_overflow = 0;
+
   /* -Woverlength-strings is off by default, but is enabled by -pedantic.
      It is never enabled in C++, as the minimum limit is not normative
      in that standard.  */
index c2e6dde4ffaa071fbb53bb8358949e8178072293..4f70c61b0badb4a69cdb0e5b1c34e99f547d053e 100644 (file)
@@ -129,7 +129,7 @@ Common
 Warn about code which might break strict aliasing rules
 
 Wstrict-aliasing=
-Common Joined UInteger
+Common Joined UInteger Var(warn_strict_aliasing) Init(-1)
 Warn about code which might break strict aliasing rules
 
 Wstrict-overflow
@@ -137,7 +137,7 @@ Common
 Warn about optimizations that assume that signed overflow is undefined
 
 Wstrict-overflow=
-Common Joined UInteger
+Common Joined UInteger Var(warn_strict_overflow) Init(-1)
 Warn about optimizations that assume that signed overflow is undefined
 
 Wswitch
index 8e4de629933122fc0e60a3006809935883e2066c..5d5f0798b2d1ef5ef764c05e7deb1d675740e210 100644 (file)
@@ -108,16 +108,6 @@ extern void set_Wunused (int setting);
 extern bool warn_larger_than;
 extern HOST_WIDE_INT larger_than_size;
 
-/* Nonzero means warn about constructs which might not be strict
-   aliasing safe.  */
-
-extern int warn_strict_aliasing;
-
-/* Nonzero means warn about optimizations which rely on undefined
-   signed overflow.  */
-
-extern int warn_strict_overflow;
-
 /* Temporarily suppress certain warnings.
    This is set while reading code from a system header file.  */
 
index 09b1d23c3527e34897b1f8d3b2b5143f13b8086c..3b5f0cc019a56a104e1f8e2f08299b5a8b522523 100644 (file)
@@ -56,14 +56,6 @@ bool extra_warnings;
 bool warn_larger_than;
 HOST_WIDE_INT larger_than_size;
 
-/* Nonzero means warn about constructs which might not be
-   strict-aliasing safe.  */
-int warn_strict_aliasing;
-
-/* Nonzero means warn about optimizations which rely on undefined
-   signed overflow.  */
-int warn_strict_overflow;
-
 /* Hack for cooperation between set_Wunused and set_Wextra.  */
 static bool maybe_warn_unused_parameter;
 
index cdf6ddf1e69c90310b0fafb88fdc30594720dfe3..84b52bf899f81f61d37d2dca33abe143e6336a75 100644 (file)
@@ -1,3 +1,9 @@
+2008-01-27  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+
+       PR 32102
+       * gcc.dg/Wstrict-overflow-21.c: New.
+       * g++.dg/warn/Wstrict-aliasing-8.C: New.
+
 2008-01-25  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * gcc.dg/pr29254.c (func1): Mark static when pic.
diff --git a/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-8.C b/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-8.C
new file mode 100644 (file)
index 0000000..497565e
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-Wstrict-aliasing=2 -O2 -Wall" } */
+
+int a[2];
+
+double *foo1(void)
+{
+  return (double *)a; /* { dg-warning "strict-aliasing" } */
+}
+
+double *foo2(void)
+{
+  return (double *)&a[0]; /* { dg-warning "strict-aliasing" } */
+}
+
+__complex__ double x;
+int *bar(void)
+{
+  return (int *)&__imag__ x; /* { dg-warning "strict-aliasing" } */
+}
diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-21.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-21.c
new file mode 100644 (file)
index 0000000..201d725
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR 32102: -Wall stomps on -Wstrict-overflow */
+/* { dg-do compile } */
+/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=2 -Wall" } */
+int
+foo (int i)
+{
+  return __builtin_abs (i) >= 0; /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */
+}
+
+