Commit e78a3b42 by Richard Kenner

(skip_evaluation): Likewise.

(overflow_warning, unsigned_conversion_warning): Don't warn about
potential runtime errors when skipping evaluation.

From-SVN: r13233
parent 6bdd692c
...@@ -37,6 +37,10 @@ Boston, MA 02111-1307, USA. */ ...@@ -37,6 +37,10 @@ Boston, MA 02111-1307, USA. */
extern struct obstack permanent_obstack; extern struct obstack permanent_obstack;
/* Nonzero means the expression being parsed will never be evaluated.
This is a count, since unevaluated expressions can nest. */
int skip_evaluation;
enum attrs {A_PACKED, A_NOCOMMON, A_COMMON, A_NORETURN, A_CONST, A_T_UNION, enum attrs {A_PACKED, A_NOCOMMON, A_COMMON, A_NORETURN, A_CONST, A_T_UNION,
A_CONSTRUCTOR, A_DESTRUCTOR, A_MODE, A_SECTION, A_ALIGNED, A_CONSTRUCTOR, A_DESTRUCTOR, A_MODE, A_SECTION, A_ALIGNED,
A_UNUSED, A_FORMAT, A_FORMAT_ARG, A_WEAK, A_ALIAS}; A_UNUSED, A_FORMAT, A_FORMAT_ARG, A_WEAK, A_ALIAS};
...@@ -1602,7 +1606,8 @@ overflow_warning (value) ...@@ -1602,7 +1606,8 @@ overflow_warning (value)
&& TREE_OVERFLOW (value)) && TREE_OVERFLOW (value))
{ {
TREE_OVERFLOW (value) = 0; TREE_OVERFLOW (value) = 0;
warning ("integer overflow in expression"); if (skip_evaluation == 0)
warning ("integer overflow in expression");
} }
else if ((TREE_CODE (value) == REAL_CST else if ((TREE_CODE (value) == REAL_CST
|| (TREE_CODE (value) == COMPLEX_CST || (TREE_CODE (value) == COMPLEX_CST
...@@ -1610,7 +1615,8 @@ overflow_warning (value) ...@@ -1610,7 +1615,8 @@ overflow_warning (value)
&& TREE_OVERFLOW (value)) && TREE_OVERFLOW (value))
{ {
TREE_OVERFLOW (value) = 0; TREE_OVERFLOW (value) = 0;
warning ("floating point overflow in expression"); if (skip_evaluation == 0)
warning ("floating point overflow in expression");
} }
} }
...@@ -1626,6 +1632,7 @@ unsigned_conversion_warning (result, operand) ...@@ -1626,6 +1632,7 @@ unsigned_conversion_warning (result, operand)
if (TREE_CODE (operand) == INTEGER_CST if (TREE_CODE (operand) == INTEGER_CST
&& TREE_CODE (TREE_TYPE (result)) == INTEGER_TYPE && TREE_CODE (TREE_TYPE (result)) == INTEGER_TYPE
&& TREE_UNSIGNED (TREE_TYPE (result)) && TREE_UNSIGNED (TREE_TYPE (result))
&& skip_evaluation == 0
&& !int_fits_type_p (operand, TREE_TYPE (result))) && !int_fits_type_p (operand, TREE_TYPE (result)))
{ {
if (!int_fits_type_p (operand, signed_type (TREE_TYPE (result)))) if (!int_fits_type_p (operand, signed_type (TREE_TYPE (result))))
...@@ -1661,10 +1668,11 @@ convert_and_check (type, expr) ...@@ -1661,10 +1668,11 @@ convert_and_check (type, expr)
&& TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (expr)))) && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (expr))))
/* If EXPR fits in the unsigned version of TYPE, /* If EXPR fits in the unsigned version of TYPE,
don't warn unless pedantic. */ don't warn unless pedantic. */
if (pedantic if ((pedantic
|| TREE_UNSIGNED (type) || TREE_UNSIGNED (type)
|| ! int_fits_type_p (expr, unsigned_type (type))) || ! int_fits_type_p (expr, unsigned_type (type)))
warning ("overflow in implicit constant conversion"); && skip_evaluation == 0)
warning ("overflow in implicit constant conversion");
} }
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