This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR fortran/29982, ICE with builtin folding and argument passing
- From: Andrew Pinski <pinskia at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Sat, 25 Nov 2006 18:43:38 -0800
- Subject: [PATCH] Fix PR fortran/29982, ICE with builtin folding and argument passing
Hi,
The problem here is the builtin folding can introduce a NOP_EXPR which
confuses the other part of the middle-end once we created a &CONST_DECL
which held the constant.
This patch fixes the problem by stripping off the NOP_EXPR before
creating a CONST_DECL.
OK? Bootstrapped and tested on i686-linux-gnu with no regressions.
Thanks,
Andrew Pinski
ChangeLog:
* trans-expr.c (gfc_conv_expr_reference): Strip off NOP_EXPRs.
* gfortran.fortran-torture/compile/parameter_3.f90: New
testcase.
Index: testsuite/gfortran.fortran-torture/compile/parameter_3.f90
===================================================================
--- testsuite/gfortran.fortran-torture/compile/parameter_3.f90 (revision 0)
+++ testsuite/gfortran.fortran-torture/compile/parameter_3.f90 (revision 0)
@@ -0,0 +1,4 @@
+program tst
+ write (6,"(a,es15.8)") "2.0**(-0.0) = ",2.0**(-0.0)
+end program tst
+
Index: fortran/trans-expr.c
===================================================================
--- fortran/trans-expr.c (revision 119211)
+++ fortran/trans-expr.c (working copy)
@@ -3133,8 +3133,10 @@ gfc_conv_expr_reference (gfc_se * se, gf
/* Create a temporary var to hold the value. */
if (TREE_CONSTANT (se->expr))
{
- var = build_decl (CONST_DECL, NULL, TREE_TYPE (se->expr));
- DECL_INITIAL (var) = se->expr;
+ tree tmp = se->expr;
+ STRIP_TYPE_NOPS (tmp);
+ var = build_decl (CONST_DECL, NULL, TREE_TYPE (tmp));
+ DECL_INITIAL (var) = tmp;
TREE_STATIC (var) = 1;
pushdecl (var);
}