re PR middle-end/11984 (ICE with -ffast_math: expected integer_cst, have real_cst)

PR middle-end/11984
	* fold-const.c (fold <PLUS_EXPR>): Check for integer constant
	operands before calling tree_int_cst_lt when performing associative
	transformations.

	* gcc.dg/20030820-1.c: New test case.

From-SVN: r70618
This commit is contained in:
Roger Sayle 2003-08-20 21:55:01 +00:00 committed by Roger Sayle
parent 68ad9159aa
commit 2cf099a553
4 changed files with 28 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2003-08-20 Roger Sayle <roger@eyesopen.com>
PR middle-end/11984
* fold-const.c (fold <PLUS_EXPR>): Check for integer constant
operands before calling tree_int_cst_lt when performing associative
transformations.
2003-08-20 Jason Merrill <jason@redhat.com>
* tree.h (IS_EXPR_CODE_CLASS): Also include 'r' and 's'.

View File

@ -5884,7 +5884,9 @@ fold (tree expr)
example: ((X*2 + 4) - 8U)/2. */
if (minus_lit0 && lit0)
{
if (tree_int_cst_lt (lit0, minus_lit0))
if (TREE_CODE (lit0) == INTEGER_CST
&& TREE_CODE (minus_lit0) == INTEGER_CST
&& tree_int_cst_lt (lit0, minus_lit0))
{
minus_lit0 = associate_trees (minus_lit0, lit0,
MINUS_EXPR, type);

View File

@ -1,3 +1,8 @@
2003-08-20 Roger Sayle <roger@eyesopen.com>
PR middle-end/11984
* gcc.dg/20030820-1.c: New test case.
2003-08-20 Nathan Sidwell <nathan@codesourcery.com>
PR c++/11945

View File

@ -0,0 +1,13 @@
/* PR middle-end/11984 */
/* The following program used to ICE in fold because we didn't check
whether the constants we were reassociating were integer constants
before calling tree_int_cst_lt. */
/* { dg-do compile } */
/* { dg-options "-O2 -ffast-math" } */
double f(double x)
{
return 1.0 - x - 0.1;
}