From 0a01c261ff1b467cb5c706858bd444c34000fb1a Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 23 Jan 2002 19:52:08 +0100 Subject: [PATCH] spew.c (pending_inlines, [...]): Make static. * spew.c (pending_inlines, pending_inlines_tail, processing_these_inlines): Make static. (mark_pending_inlines): Remove static. (begin_parsing_inclass_inline): If in function, save pi for GC to cp_function_chain->unparsed_inlines instead. (process_next_inline): Likewise. * cp-tree.h (struct cp_language_function): Add unparsed_inlines. (mark_pending_inlines): Add prototype. * decl.c (spew_debug): Remove unused extern. (mark_lang_function): Call mark_pending_inlines. * g++.dg/other/gc1.C: New test. From-SVN: r49147 --- gcc/cp/ChangeLog | 13 +++++++++ gcc/cp/cp-tree.h | 6 ++-- gcc/cp/decl.c | 5 +--- gcc/cp/spew.c | 21 ++++++++------ gcc/testsuite/ChangeLog | 4 +++ gcc/testsuite/g++.dg/other/gc1.C | 49 ++++++++++++++++++++++++++++++++ 6 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/gc1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9c6fce3862a..f2c1791aee1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,16 @@ +2002-01-23 Jakub Jelinek + + * spew.c (pending_inlines, pending_inlines_tail, + processing_these_inlines): Make static. + (mark_pending_inlines): Remove static. + (begin_parsing_inclass_inline): If in function, save pi + for GC to cp_function_chain->unparsed_inlines instead. + (process_next_inline): Likewise. + * cp-tree.h (struct cp_language_function): Add unparsed_inlines. + (mark_pending_inlines): Add prototype. + * decl.c (spew_debug): Remove unused extern. + (mark_lang_function): Call mark_pending_inlines. + 2002-01-23 Craig Rodrigues * call.c, class.c, decl.c, decl2.c, error.c, expr.c, friend.c, diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 99f7bf71b74..8c075c51ee9 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -801,6 +801,8 @@ struct saved_scope extern struct saved_scope *scope_chain; +struct unparsed_text; + /* Global state pertinent to the current function. */ struct cp_language_function @@ -828,6 +830,7 @@ struct cp_language_function varray_type x_local_names; const char *cannot_inline; + struct unparsed_text *unparsed_inlines; }; /* The current C++-specific per-function global variables. */ @@ -1781,8 +1784,6 @@ struct lang_decl_flags } u2; }; -struct unparsed_text; - struct lang_decl { struct lang_decl_flags decl_flags; @@ -4193,6 +4194,7 @@ extern tree finish_global_stmt_expr PARAMS ((tree)); /* in spew.c */ extern void init_spew PARAMS ((void)); +extern void mark_pending_inlines PARAMS ((PTR)); extern int peekyylex PARAMS ((void)); extern tree arbitrate_lookup PARAMS ((tree, tree, tree)); extern tree frob_opname PARAMS ((tree)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 3747cabe9e3..35211135cf0 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -288,10 +288,6 @@ extern int flag_conserve_space; /* C and C++ flags are in decl2.c. */ -/* Flag used when debugging spew.c */ - -extern int spew_debug; - /* A expression of value 0 with the same precision as a sizetype node, but signed. */ tree signed_size_zero_node; @@ -14607,6 +14603,7 @@ mark_lang_function (p) mark_named_label_lists (&p->x_named_labels, &p->x_named_label_uses); mark_binding_level (&p->bindings); + mark_pending_inlines (&p->unparsed_inlines); } /* Mark the language-specific data in F for GC. */ diff --git a/gcc/cp/spew.c b/gcc/cp/spew.c index 74f89a05a53..e610aec47c0 100644 --- a/gcc/cp/spew.c +++ b/gcc/cp/spew.c @@ -119,15 +119,14 @@ static int frob_id PARAMS ((int, int, tree *)); /* The list of inline functions being held off until we reach the end of the current class declaration. */ -struct unparsed_text *pending_inlines; -struct unparsed_text *pending_inlines_tail; +static struct unparsed_text *pending_inlines; +static struct unparsed_text *pending_inlines_tail; /* The list of previously-deferred inline functions currently being parsed. This exists solely to be a GC root. */ -struct unparsed_text *processing_these_inlines; +static struct unparsed_text *processing_these_inlines; static void begin_parsing_inclass_inline PARAMS ((struct unparsed_text *)); -static void mark_pending_inlines PARAMS ((PTR)); #ifdef SPEW_DEBUG int spew_debug = 0; @@ -416,7 +415,7 @@ end_input () } /* GC callback to mark memory pointed to by the pending inline queue. */ -static void +void mark_pending_inlines (pi) PTR pi; { @@ -950,8 +949,11 @@ begin_parsing_inclass_inline (pi) tree context; /* Record that we are processing the chain of inlines starting at - PI in a special GC root. */ - processing_these_inlines = pi; + PI for GC. */ + if (cfun) + cp_function_chain->unparsed_inlines = pi; + else + processing_these_inlines = pi; ggc_collect (); @@ -1025,7 +1027,10 @@ process_next_inline (i) begin_parsing_inclass_inline (i); else { - processing_these_inlines = 0; + if (cfun) + cp_function_chain->unparsed_inlines = 0; + else + processing_these_inlines = 0; extract_interface_info (); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 414c694a870..22bc8a929c4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-01-23 Jakub Jelinek + + * g++.dg/other/gc1.C: New test. + 2002-01-23 Zack Weinberg * gcc.dg/c99-intconst-1.c: Mark XFAIL. diff --git a/gcc/testsuite/g++.dg/other/gc1.C b/gcc/testsuite/g++.dg/other/gc1.C new file mode 100644 index 00000000000..3c7a16998d1 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/gc1.C @@ -0,0 +1,49 @@ +// This test failed with GGC_ALWAYS_COLLECT because not all unparsed +// inline methods were registered with GC. +// { dg-do compile } + +const char *foo () +{ + struct A + { + const char *a1 () + { + return "a1"; + } + const char *a2 () + { + struct B + { + const char *b1 () + { + return "b1"; + } + const char *b2 () + { + struct C + { + const char *c1 () + { + return "c1"; + } + const char *c2 () + { + return "c2"; + } + }; + return "b2"; + } + const char *b3 () + { + return "b3"; + } + }; + return "a2"; + } + const char *a3 () + { + return "a3"; + } + }; + return "foo"; +} -- 2.30.2