This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]