diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fdaa94ae8b9..3133b3c4ef1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-05-30 Richard Biener + + PR c/95141 + * c-fold.c (c_fully_fold_internal): Enhance guard on + overflow_warning. + 2020-05-20 Kito Cheng PR target/90811 diff --git a/gcc/c/c-fold.c b/gcc/c/c-fold.c index 63becfeaf2c..bd21d247051 100644 --- a/gcc/c/c-fold.c +++ b/gcc/c/c-fold.c @@ -374,6 +374,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, ret = fold (expr); if (TREE_OVERFLOW_P (ret) && !TREE_OVERFLOW_P (op0) + && !(BINARY_CLASS_P (op0) && TREE_OVERFLOW_P (TREE_OPERAND (op0, 1))) && !TREE_OVERFLOW_P (op1)) overflow_warning (EXPR_LOC_OR_LOC (expr, input_location), ret, expr); if (code == LSHIFT_EXPR diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 48671f1105a..401025718ee 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-05-30 Richard Biener + + PR c/95141 + * gcc.dg/pr95141.c: New testcase. + 2020-05-19 Alex Coplan PR target/94591 diff --git a/gcc/testsuite/gcc.dg/pr95141.c b/gcc/testsuite/gcc.dg/pr95141.c new file mode 100644 index 00000000000..b6cbba2f908 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr95141.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +#include + +uint64_t test(uint8_t IA1) +{ + return (uint8_t)(IA1 & 158) & 1UL; /* { dg-bogus "integer overflow" } */ +}