diff options
author | Roger Sayle <roger@eyesopen.com> | 2006-05-01 04:27:15 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2006-05-01 04:27:15 +0000 |
commit | 71834ad346a514c1ef41342403b762503e5ce05e (patch) | |
tree | e7d7d2ba340760ae4cb7b524b8aab06e994b8769 /gcc/c-common.c | |
parent | 1c56bc4a7ea665c876311f1df1658aa19107f93f (diff) | |
download | gcc-71834ad346a514c1ef41342403b762503e5ce05e.zip gcc-71834ad346a514c1ef41342403b762503e5ce05e.tar.gz gcc-71834ad346a514c1ef41342403b762503e5ce05e.tar.bz2 |
common.opt (Woverflow): New command line option.
* common.opt (Woverflow): New command line option.
* c-common.c (constant_expression_warning): Check warn_overflow.
(overflow_waring): Pass OPT_Woverflow to warning.
(unsigned_conversion_warning): Likewise.
(convert_and_check): Likewise.
* doc/invoke.texi: Document new command line option.
* gcc.dg/Woverflow-1.c: New test case.
* gcc.dg/Woverflow-2.c: Likewise.
* gcc.dg/Woverflow-3.c: Likewise.
From-SVN: r113408
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 35982e5..5e54660 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -906,7 +906,9 @@ constant_expression_warning (tree value) if ((TREE_CODE (value) == INTEGER_CST || TREE_CODE (value) == REAL_CST || TREE_CODE (value) == VECTOR_CST || TREE_CODE (value) == COMPLEX_CST) - && TREE_CONSTANT_OVERFLOW (value) && pedantic) + && TREE_CONSTANT_OVERFLOW (value) + && warn_overflow + && pedantic) pedwarn ("overflow in constant expression"); } @@ -927,7 +929,7 @@ overflow_warning (tree value) { TREE_OVERFLOW (value) = 0; if (skip_evaluation == 0) - warning (0, "integer overflow in expression"); + warning (OPT_Woverflow, "integer overflow in expression"); } else if ((TREE_CODE (value) == REAL_CST || (TREE_CODE (value) == COMPLEX_CST @@ -936,13 +938,13 @@ overflow_warning (tree value) { TREE_OVERFLOW (value) = 0; if (skip_evaluation == 0) - warning (0, "floating point overflow in expression"); + warning (OPT_Woverflow, "floating point overflow in expression"); } else if (TREE_CODE (value) == VECTOR_CST && TREE_OVERFLOW (value)) { TREE_OVERFLOW (value) = 0; if (skip_evaluation == 0) - warning (0, "vector overflow in expression"); + warning (OPT_Woverflow, "vector overflow in expression"); } } @@ -964,7 +966,8 @@ unsigned_conversion_warning (tree result, tree operand) { if (!int_fits_type_p (operand, c_common_signed_type (type))) /* This detects cases like converting -129 or 256 to unsigned char. */ - warning (0, "large integer implicitly truncated to unsigned type"); + warning (OPT_Woverflow, + "large integer implicitly truncated to unsigned type"); else warning (OPT_Wconversion, "negative integer implicitly converted to unsigned type"); @@ -1093,7 +1096,8 @@ convert_and_check (tree type, tree expr) || !constant_fits_type_p (expr, c_common_unsigned_type (type))) && skip_evaluation == 0) - warning (0, "overflow in implicit constant conversion"); + warning (OPT_Woverflow, + "overflow in implicit constant conversion"); } else unsigned_conversion_warning (t, expr); |