This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC 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
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;
}