This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[PATCH] Fix tree-opt/29788, plain CONST_DECL leaking through
- From: Andrew Pinski <pinskia at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: fortran at gcc dot gnu dot org
- Date: Mon, 13 Nov 2006 07:17:18 -0800
- Subject: [PATCH] Fix tree-opt/29788, plain CONST_DECL leaking through
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:subject:to:cc:content-type:date:message-id:mime-version:x-mailer:from; b=PHNYfMbt269cQCJIksESSlthYAHCkn7ID3aDCVeHvwdKr7ENb+duaw9gY3qu7g2FVWEtpLLvl3t7o9DPnjCZMEL4Hz/hlpiHI8YJfS6/mK/q0rAXwPCxuWxO1L37rlGY3aTEtL83vRZ4J72dpPQuXg/eHLEJXsdGYPNkpoDkMbE=
Hi,
The problem here is that the inliner folds *&CONST_DECL to CONST_DECL
but it forgot to inline the value of the CONST_DECL. It is not valid to
have a plain CONST_DECL in the IR and it causes different ICEs,
depending on if PRE runs or not.
This patch fixes the problem by running fold after folding *&CONST_DECL.
OK? Bootstrapped and tested on i686-linux-gnu with no regressions.
Thanks,
Andrew Pinski
ChangeLog:
* tree-inline.c (copy_body_r): Call fold after folding indirect
reference.
* gfortran.fortran-torture/compile/inline_1.f90: New test.
Index: testsuite/gfortran.fortran-torture/compile/inline_1.f90
===================================================================
--- testsuite/gfortran.fortran-torture/compile/inline_1.f90 (revision 0)
+++ testsuite/gfortran.fortran-torture/compile/inline_1.f90 (revision 0)
@@ -0,0 +1,17 @@
+program gfcbug43
+ call try_fit (1)
+ call try_fit (1)
+contains
+ subroutine try_fit (k)
+ call fit (1, debug=.true.)
+ end subroutine try_fit
+ subroutine fit (k, debug)
+ logical, intent(in), optional :: debug
+ do j = 1, 2
+ maxerr1 = funk (r ,x1 , x1)
+ end do
+ if (debug) then
+ print "help"
+ end if
+ end subroutine fit
+end program gfcbug43
Index: tree-inline.c
===================================================================
--- tree-inline.c (revision 118718)
+++ tree-inline.c (working copy)
@@ -612,6 +612,7 @@ copy_body_r (tree *tp, int *walk_subtree
TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old);
}
}
+ *tp = fold (*tp);
*walk_subtrees = 0;
return NULL;
}