c-common.c (c_fully_fold_internal): Issue a warning if a binary operation overflows.
authorRichard Sandiford <rdsandiford@googlemail.com>
Sun, 9 Aug 2009 18:38:04 +0000 (18:38 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Sun, 9 Aug 2009 18:38:04 +0000 (18:38 +0000)
commitf517845606b6b8290b52f2068775a9325eceff6b
tree4f384af8342874e6f72150b4b11a160bb03fa4be
parent8f048d2f21ea75e65fe9000cd9f7c1cfbbb7788a
c-common.c (c_fully_fold_internal): Issue a warning if a binary operation overflows.

gcc/
* c-common.c (c_fully_fold_internal): Issue a warning if a binary
operation overflows.  Likewise non-cast unary arithmetic.
If one arm of a conditional expression is always taken,
inhibit evaluation warnings for the other arm.  Likewise inhibit
evaluation warnings for the second && or || operand if the first
operand is enough to determine the result.
* c-typeck.c (build_conditional_expr): Apply the same inhibition
rules here.
(build_binary_op): Prevent duplicate evaluation warnings.

gcc/testsuite/
* gcc.dg/overflow-warn-8.c: New test.

From-SVN: r150594
gcc/ChangeLog
gcc/c-common.c
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/overflow-warn-8.c [new file with mode: 0644]