This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Treat -Wstrict-overflow as -Wstrict-overflow=2
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 08 Mar 2007 22:44:20 -0800
- Subject: Treat -Wstrict-overflow as -Wstrict-overflow=2
Since -Wall implies -Wstrict-overflow=1, I think it makes sense to
change -Wstrict-overflow from -Wstrict-overflow=1 to
-Wstrict-overflow=2. -Wstrict-overflow=2 warns about cases where
strict overflow is used to fold a conditional to a constant. These
are the cases which catch people by surprise.
If nobody objects, I will check this in in a day or two. Bootstrapped
and tested on i686-pc-linux-gnu.
Ian
2007-03-08 Ian Lance Taylor <iant@google.com>
* opts.c (common_handle_option): Treat -Wstrict-overflow (with no
argument) like -Wstrict-overflow=2.
* doc/invoke.texi (Warning Options): Update documentation.
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi (revision 122739)
+++ gcc/doc/invoke.texi (working copy)
@@ -3017,17 +3017,17 @@ warning levels are defined.
@item -Wstrict-overflow=1
Warn about cases which are both questionable and easy to avoid. For
example: @code{x + 1 > x}; with @option{-fstrict-overflow}, the
-compiler will simplify this to @code{1}. @option{-Wstrict-overflow}
-(with no level) is the same as @option{-Wstrict-overflow=1}. This
-level of @option{-Wstrict-overflow} is enabled by @option{-Wall};
-higher levels are not, and must be explicitly requested.
+compiler will simplify this to @code{1}. This level of
+@option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
+are not, and must be explicitly requested.
@item -Wstrict-overflow=2
Also warn about other cases where a comparison is simplified to a
constant. For example: @code{abs (x) >= 0}. This can only be
simplified when @option{-fstrict-overflow} is in effect, because
@code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
-zero.
+zero. @option{-Wstrict-overflow} (with no level) is the same as
+@option{-Wstrict-overflow=2}.
@item -Wstrict-overflow=3
Also warn about other cases where a comparison is simplified. For
Index: gcc/opts.c
===================================================================
--- gcc/opts.c (revision 122739)
+++ gcc/opts.c (working copy)
@@ -1094,6 +1094,11 @@ common_handle_option (size_t scode, cons
break;
case OPT_Wstrict_overflow:
+ warn_strict_overflow = (value
+ ? (int) WARN_STRICT_OVERFLOW_CONDITIONAL
+ : 0);
+ break;
+
case OPT_Wstrict_overflow_:
warn_strict_overflow = value;
break;