diff --git a/gcc/c-common.c b/gcc/c-common.c index b71a4252eaf..ecdeb8f9277 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -1078,9 +1078,10 @@ void constant_expression_warning (value) tree value; { - if (TREE_CODE (value) == INTEGER_CST && TREE_CONSTANT_OVERFLOW (value)) - if (pedantic) - pedwarn ("overflow in constant expression"); + if ((TREE_CODE (value) == INTEGER_CST || TREE_CODE (value) == REAL_CST + || TREE_CODE (value) == COMPLEX_CST) + && TREE_CONSTANT_OVERFLOW (value) && pedantic) + pedwarn ("overflow in constant expression"); } /* Print a warning if an expression had overflow in folding. @@ -1094,11 +1095,22 @@ void overflow_warning (value) tree value; { - if (TREE_CODE (value) == INTEGER_CST && TREE_OVERFLOW (value)) + if ((TREE_CODE (value) == INTEGER_CST + || (TREE_CODE (value) == COMPLEX_CST + && TREE_CODE (TREE_REALPART (value)) == INTEGER_CST)) + && TREE_OVERFLOW (value)) { TREE_OVERFLOW (value) = 0; warning ("integer overflow in expression"); } + else if ((TREE_CODE (value) == REAL_CST + || (TREE_CODE (value) == COMPLEX_CST + && TREE_CODE (TREE_REALPART (value)) == REAL_CST)) + && TREE_OVERFLOW (value)) + { + TREE_OVERFLOW (value) = 0; + warning ("floating-pointer overflow in expression"); + } } /* Print a warning if a large constant is truncated to unsigned,