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/testsuite/gcc.dg/overflow-warn-6.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/testsuite/gcc.dg/overflow-warn-6.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/overflow-warn-6.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/overflow-warn-6.c b/gcc/testsuite/gcc.dg/overflow-warn-6.c new file mode 100644 index 0000000..da8cb01 --- /dev/null +++ b/gcc/testsuite/gcc.dg/overflow-warn-6.c @@ -0,0 +1,18 @@ +/* Test non-constant operands in overflowed expressions. */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -Woverflow" } */ + +#include <limits.h> + +int +h1 (int x) +{ + return x * (0 * (INT_MAX + 1)); /* { dg-warning "warning: integer overflow in expression" } */ +} + +int +h2 (int x) +{ + return ((INT_MAX + 1) * 0) * x; /* { dg-warning "warning: integer overflow in expression" } */ +} + |