Commit 7193bce2 by Paul Eggert

(constant_expression_warning, overflow_warning,

convert_and_check): Distinguish between TREE_OVERFLOW, which is just
for warnings, and TREE_CONSTANT_OVERFLOW, which is for required
pedantic diagnostics.

From-SVN: r4827
parent 261450e8
...@@ -349,15 +349,8 @@ constant_expression_warning (value) ...@@ -349,15 +349,8 @@ constant_expression_warning (value)
tree value; tree value;
{ {
if (TREE_CODE (value) == INTEGER_CST && TREE_CONSTANT_OVERFLOW (value)) if (TREE_CODE (value) == INTEGER_CST && TREE_CONSTANT_OVERFLOW (value))
{ if (pedantic)
/* ??? This is a warning, not a pedwarn, in 2.4, pedwarn ("overflow in constant expression");
because it happens in contexts that are not
"constant expressions" in ANSI C.
Fix the problem differently in 2.5. */
warning ("overflow in constant expression");
/* Suppress duplicate warnings. */
TREE_CONSTANT_OVERFLOW (value) = 0;
}
} }
/* Print a warning if an expression had overflow in folding. /* Print a warning if an expression had overflow in folding.
...@@ -371,14 +364,10 @@ void ...@@ -371,14 +364,10 @@ void
overflow_warning (value) overflow_warning (value)
tree value; tree value;
{ {
if (TREE_CODE (value) == INTEGER_CST && TREE_CONSTANT_OVERFLOW (value)) if (TREE_CODE (value) == INTEGER_CST && TREE_OVERFLOW (value))
{ {
/* ??? This is a warning, not a pedwarn, in 2.4, TREE_OVERFLOW (value) = 0;
because it happens in contexts that are not
"constant expressions" in ANSI C.
Fix the problem differently in 2.5. */
warning ("integer overflow in expression"); warning ("integer overflow in expression");
TREE_CONSTANT_OVERFLOW (value) = 0;
} }
} }
...@@ -415,20 +404,15 @@ convert_and_check (type, expr) ...@@ -415,20 +404,15 @@ convert_and_check (type, expr)
tree t = convert (type, expr); tree t = convert (type, expr);
if (TREE_CODE (t) == INTEGER_CST) if (TREE_CODE (t) == INTEGER_CST)
{ {
if (TREE_UNSIGNED (TREE_TYPE (expr)) if (TREE_OVERFLOW (t))
&& !TREE_UNSIGNED (type)
&& TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
&& TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (expr)))
/* No warning for converting 0x80000000 to int. */
TREE_CONSTANT_OVERFLOW (t) = 0;
else if (TREE_CONSTANT_OVERFLOW (t))
{ {
/* ??? This is a warning, not a pedwarn, in 2.4, TREE_OVERFLOW (t) = 0;
because it happens in contexts that are not
"constant expressions" in ANSI C. /* No warning for converting 0x80000000 to int. */
Fix the problem differently in 2.5. */ if (!(TREE_UNSIGNED (type) < TREE_UNSIGNED (TREE_TYPE (expr))
&& TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
&& TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (expr))))
warning ("overflow in implicit constant conversion"); warning ("overflow in implicit constant conversion");
TREE_CONSTANT_OVERFLOW (t) = 0;
} }
else else
unsigned_conversion_warning (t, expr); unsigned_conversion_warning (t, expr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment