From: Manuel López-Ibáñez Date: Sun, 27 Jan 2008 18:36:59 +0000 (+0000) Subject: re PR c/32102 (-Wall stomps on -Wstrict-overflow) X-Git-Tag: releases/gcc-4.2.3~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8fc04c7106433ba095037e107f8b9091fde2f193;p=thirdparty%2Fgcc.git re PR c/32102 (-Wall stomps on -Wstrict-overflow) 2008-01-27 Manuel Lopez-Ibanez 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8fb11f3150ad..e969fb1169de 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2008-01-27 Manuel Lopez-Ibanez + + 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 PR other/31955 diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 747ca0d76ea0..a3e6871f3375 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -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. */ diff --git a/gcc/common.opt b/gcc/common.opt index c2e6dde4ffaa..4f70c61b0bad 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -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 diff --git a/gcc/flags.h b/gcc/flags.h index 8e4de6299331..5d5f0798b2d1 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -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. */ diff --git a/gcc/opts.c b/gcc/opts.c index 09b1d23c3527..3b5f0cc019a5 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cdf6ddf1e69c..84b52bf899f8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-01-27 Manuel Lopez-Ibanez + + PR 32102 + * gcc.dg/Wstrict-overflow-21.c: New. + * g++.dg/warn/Wstrict-aliasing-8.C: New. + 2008-01-25 Kaveh R. Ghazi * 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 index 000000000000..497565eecdd0 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-8.C @@ -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 index 000000000000..201d72560c24 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-21.c @@ -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" } */ +} + +