diff options
author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2007-01-05 21:57:01 +0000 |
---|---|---|
committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2007-01-05 21:57:01 +0000 |
commit | 59c0753dd31ebc72074a9650182896e0c6f5647a (patch) | |
tree | 6907cbd4435447e2f591dc2ff312abadddf5058a /gcc/c-typeck.c | |
parent | c2658540a35254dd462e104abf9cf8b7bdb68113 (diff) | |
download | gcc-59c0753dd31ebc72074a9650182896e0c6f5647a.zip gcc-59c0753dd31ebc72074a9650182896e0c6f5647a.tar.gz gcc-59c0753dd31ebc72074a9650182896e0c6f5647a.tar.bz2 |
re PR c/19978 (overflow in expression of constants should not cause multiple warnings)
2007-01-05 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c/19978
* tree.h (TREE_OVERFLOW_P): New.
* c-typeck.c (parser_build_unary_op): Warn only if result
overflowed and operands did not.
(parser_build_binary_op): Likewise.
(convert_for_assignment): Remove redundant overflow_warning.
* c-common.c (overflow_warning): Don't check or set TREE_OVERFLOW.
cp/
* semantics.c (finish_unary_op_expr): Warn only if result
overflowed and operands did not.
testsuite/
* gcc.dg/multiple-overflow-warn-1.c: New.
* gcc.dg/multiple-overflow-warn-2.c: New.
* gcc.dg/overflow-warn-6.c: New.
* g++.dg/warn/multiple-overflow-warn-1.C: New.
From-SVN: r120505
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r-- | gcc/c-typeck.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index e8e2f69..8119e7f 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2601,7 +2601,10 @@ parser_build_unary_op (enum tree_code code, struct c_expr arg) result.original_code = ERROR_MARK; result.value = build_unary_op (code, arg.value, 0); - overflow_warning (result.value); + + if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value)) + overflow_warning (result.value); + return result; } @@ -2645,7 +2648,10 @@ parser_build_binary_op (enum tree_code code, struct c_expr arg1, warning (OPT_Wstring_literal_comparison, "comparison with string literal"); - overflow_warning (result.value); + if (TREE_OVERFLOW_P (result.value) + && !TREE_OVERFLOW_P (arg1.value) + && !TREE_OVERFLOW_P (arg2.value)) + overflow_warning (result.value); return result; } @@ -3827,10 +3833,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype, } if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype)) - { - overflow_warning (rhs); - return rhs; - } + return rhs; if (coder == VOID_TYPE) { |