This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix function inlining ICE
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ PATCH] Fix function inlining ICE
- From: Kriang Lerdsuwanakij <lerdsuwa at users dot sourceforge dot net>
- Date: Sun, 18 Feb 2001 08:01:32 -0800 (PST)
Hi
The attached patch fixes the ICE in copy_body_r() bug reported a few
times in the GNATS database. When inlining functions, certain
CALL_EXPR nodes are expanded when they shouldn't be. They are the
CALL_EXPRs that buried deep inside type nodes. Since type nodes
inside function were not copied by copy_body(), expanding those
CALL_EXPRs also modifies tree nodes of the original function,
causing ICE if the same function is later inlined again.
Tested on i586-pc-linux-gnu. OK to install on mainline and gcc 3.0
branch?
--Kriang
==========================================
ChangeLog
2001-02-18 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* optimize.c (expand_call_inline): Don't walk subtrees of type
nodes.
2001-02-18 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* inline19.c: Remove XFAIL.
Index: gcc/cp/optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/optimize.c,v
retrieving revision 1.51
diff -c -p -r1.51 optimize.c
*** optimize.c 2001/02/12 09:58:18 1.51
--- optimize.c 2001/02/18 15:27:24
*************** expand_call_inline (tp, walk_subtrees, d
*** 666,671 ****
--- 666,677 ----
return NULL_TREE;
}
+ if (TREE_CODE_CLASS (TREE_CODE (t)) == 't')
+ /* Because types were not copied in copy_body, CALL_EXPRs beneath
+ them should not be expanded. This can happen if the type is a
+ dynamic array type, for example. */
+ *walk_subtrees = 0;
+
/* From here on, we're only interested in CALL_EXPRs. */
if (TREE_CODE (t) != CALL_EXPR)
return NULL_TREE;
Index: gcc/testsuite/g++.old-deja/g++.other/inline19.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.other/inline19.C,v
retrieving revision 1.1
diff -c -p -r1.1 inline19.C
*** inline19.C 2001/01/31 00:08:44 1.1
--- inline19.C 2001/02/18 15:27:44
***************
*** 2,8 ****
// Origin: Scott Snyder <snyder@fnal.gov> via PR 1733.
// Special g++ Options: -O1
//
! // crash test - XFAIL *-*-*
struct TBtItem
{
--- 2,8 ----
// Origin: Scott Snyder <snyder@fnal.gov> via PR 1733.
// Special g++ Options: -O1
//
! // crash test
struct TBtItem
{