[PATCH] Fix PR fortran/29982, ICE with builtin folding and argument passing

Jerry DeLisle jvdelisle@verizon.net
Sun Nov 26 04:47:00 GMT 2006


Andrew Pinski wrote:
> 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);
>      }
> 
OK, straight forward.



More information about the Gcc-patches mailing list