[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-fortran
Subject:    [PATCH] Fix PR fortran/29982, ICE with builtin folding and 	argument passing
From:       Andrew Pinski <pinskia () gmail ! com>
Date:       2006-11-26 2:43:38
Message-ID: 1164509019.19849.146.camel () celery ! andrew ! com
[Download RAW message or body]

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.

["fixbuiltin-const.diff.txt" (fixbuiltin-const.diff.txt)]

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);
     }



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic