This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR c++/5050: template instantiation depth exceeds/maybe recursion optimizing
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: Andrew Pinski <pinskia at physics dot uc dot edu>
- Date: Sun, 21 Dec 2003 17:18:13 -0800
- Subject: [PATCH] Fix PR c++/5050: template instantiation depth exceeds/maybe recursion optimizing
The problem here is caused by the patch which was to fix the testcase
g++.dg/template/recurse.C:
<http://gcc.gnu.org/ml/gcc-patches/2001-12/msg00514.html>.
In fact that testcase was fixed before as Phil's regression hunter
shows: Search converges between 2001-07-15-trunk (#28) and
2001-07-22-trunk (#29).
The problem is that the tree inliner is making template instantiation
depth too
high.
Basically this patch reverts most of the patch referenced above.
Bootstraped and tested on i686-pc-linux-gnu with no regressions (even
g++.dg/template/recurse.C passes still).
Ok for mainline and 3.3?
ChangeLog:
* tree.c (cp_start_inlining): Remove.
(cp_end_inlining): Remove.
* cp-lang.c (LANG_HOOKS_TREE_INLINING_START_INLINING): Do not define.
(LANG_HOOKS_TREE_INLINING_END_INLINING): Do not define.
* cp-tree.h (cp_start_inlining): Do not declare.
(cp_end_inlining): Do not declare.
Patch:
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/tree.c,v
retrieving revision 1.358
diff -u -p -r1.358 tree.c
--- tree.c 19 Dec 2003 23:28:10 -0000 1.358
+++ tree.c 22 Dec 2003 00:56:25 -0000
@@ -2194,28 +2194,6 @@ cp_copy_res_decl_for_inlining (tree resu
return var;
}
-/* Record that we're about to start inlining FN, and return nonzero if
- that's OK. Used for lang_hooks.tree_inlining.start_inlining. */
-
-int
-cp_start_inlining (tree fn)
-{
- if (DECL_TEMPLATE_INSTANTIATION (fn))
- return push_tinst_level (fn);
- else
- return 1;
-}
-
-/* Record that we're done inlining FN. Used for
- lang_hooks.tree_inlining.end_inlining. */
-
-void
-cp_end_inlining (tree fn ATTRIBUTE_UNUSED )
-{
- if (DECL_TEMPLATE_INSTANTIATION (fn))
- pop_tinst_level ();
-}
-
/* Initialize tree.c. */
void
Index: cp-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-lang.c,v
retrieving revision 1.68
diff -u -p -r1.68 cp-lang.c
--- cp-lang.c 16 Dec 2003 10:08:37 -0000 1.68
+++ cp-lang.c 22 Dec 2003 00:56:25 -0000
@@ -156,10 +156,6 @@ static void cxx_initialize_diagnostics (
#define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P anon_aggr_type_p
#undef LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P
#define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P cp_var_mod_type_p
-#undef LANG_HOOKS_TREE_INLINING_START_INLINING
-#define LANG_HOOKS_TREE_INLINING_START_INLINING cp_start_inlining
-#undef LANG_HOOKS_TREE_INLINING_END_INLINING
-#define LANG_HOOKS_TREE_INLINING_END_INLINING cp_end_inlining
#undef LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS
#define LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS
c_estimate_num_insns
#undef LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN
Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.940
diff -u -p -r1.940 cp-tree.h
--- cp-tree.h 18 Dec 2003 21:03:22 -0000 1.940
+++ cp-tree.h 22 Dec 2003 00:56:26 -0000
@@ -4175,8 +4175,6 @@ extern int cp_is_overload_p (tree);
extern int cp_auto_var_in_fn_p (tree,tree);
extern tree cp_copy_res_decl_for_inlining (tree, tree, tree, void*,
int*, tree);
-extern int cp_start_inlining (tree);
-extern void cp_end_inlining (tree);
/* in typeck.c */
extern int string_conv_p (tree, tree, int);