summaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2007-05-20 20:29:55 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2007-05-20 20:29:55 +0000
commitf6aa72dd497916b60e7a3c29e235241dadba3274 (patch)
tree90312ab1a9121fa6e7864a7b15bdaf3260ab1b8b /gcc/c-common.c
parentda5a2efd39b67a36c4e70f059ffbbb6103606f3e (diff)
downloadgcc-f6aa72dd497916b60e7a3c29e235241dadba3274.tar.gz
re PR middle-end/7651 (Define -Wextra strictly in terms of other warning flags)
2007-05-20 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR middle-end/7651 PR c++/11856 PR c/12963 PR c/23587 PR other/29694 * c.opt (Wtype-limits): New. * doc/invoke.texi (Wtype-limits): Document it. (Wextra): Enabled by -Wextra. * c-opts.c (c_common_post_options): Enabled by -Wextra. * c-common.c (shorten_compare): Warn with Wtype-limits. testsuite/ * gcc.dg/compare6.c: Replace Wall with Wtype-limits. * gcc.dg/Wtype-limits.c: New. * gcc.dg/Wtype-limits-Wextra.c: New. * gcc.dg/Wtype-limits-no.c: New. * g++.dg/warn/Wtype-limits.C: New. * g++.dg/warn/Wtype-limits-Wextra.C: New. * g++.dg/warn/Wtype-limits-no.C: New. From-SVN: r124875
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 1026499df52..3814bfde667 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -2517,9 +2517,9 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr,
if (TREE_CODE (primop0) != INTEGER_CST)
{
if (val == truthvalue_false_node)
- warning (0, "comparison is always false due to limited range of data type");
+ warning (OPT_Wtype_limits, "comparison is always false due to limited range of data type");
if (val == truthvalue_true_node)
- warning (0, "comparison is always true due to limited range of data type");
+ warning (OPT_Wtype_limits, "comparison is always true due to limited range of data type");
}
if (val != 0)
@@ -2589,24 +2589,26 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr,
switch (code)
{
case GE_EXPR:
- /* All unsigned values are >= 0, so we warn if extra warnings
- are requested. However, if OP0 is a constant that is
- >= 0, the signedness of the comparison isn't an issue,
- so suppress the warning. */
- if (extra_warnings && !in_system_header
+ /* All unsigned values are >= 0, so we warn. However,
+ if OP0 is a constant that is >= 0, the signedness of
+ the comparison isn't an issue, so suppress the
+ warning. */
+ if (warn_type_limits && !in_system_header
&& !(TREE_CODE (primop0) == INTEGER_CST
&& !TREE_OVERFLOW (convert (c_common_signed_type (type),
primop0))))
- warning (0, "comparison of unsigned expression >= 0 is always true");
+ warning (OPT_Wtype_limits,
+ "comparison of unsigned expression >= 0 is always true");
value = truthvalue_true_node;
break;
case LT_EXPR:
- if (extra_warnings && !in_system_header
+ if (warn_type_limits && !in_system_header
&& !(TREE_CODE (primop0) == INTEGER_CST
&& !TREE_OVERFLOW (convert (c_common_signed_type (type),
primop0))))
- warning (0, "comparison of unsigned expression < 0 is always false");
+ warning (OPT_Wtype_limits,
+ "comparison of unsigned expression < 0 is always false");
value = truthvalue_false_node;
break;