diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cee60ef10bd..f430d58ad3d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +1999-10-30 Mark Mitchell + + * decl.c (pop_cp_function_context): Don't call free on a NULL + pointer. + * semantics.c: Include ggc.h. + (expand_body): Do garbage-collection after processing a template + function. Clear DECL_SAVED_TREE after generating RTL for a + function. + * Makefile.in (semantics.o): Depend on ggc.h. + 1999-10-29 Mark Mitchell * cp-tree.h (make_typename_type): Change prototype. diff --git a/gcc/cp/Makefile.in b/gcc/cp/Makefile.in index d731a5808ca..398703b1a26 100644 --- a/gcc/cp/Makefile.in +++ b/gcc/cp/Makefile.in @@ -295,7 +295,7 @@ repo.o : repo.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../system.h \ $(srcdir)/../toplev.h $(srcdir)/../ggc.h semantics.o: semantics.c $(CONFIG_H) $(CXX_TREE_H) lex.h \ $(srcdir)/../except.h $(srcdir)/../system.h $(srcdir)/../toplev.h \ - $(srcdir)/../flags.h + $(srcdir)/../flags.h $(srcdir)/../ggc.h dump.o: dump.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../system.h # diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 00b52e44903..0f9b5ab3ba8 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -14234,7 +14234,8 @@ static void pop_cp_function_context (f) struct function *f; { - free (f->language); + if (f->language) + free (f->language); f->language = 0; } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index d0a30ba79e3..54dd7e11f48 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -32,6 +32,7 @@ #include "lex.h" #include "toplev.h" #include "flags.h" +#include "ggc.h" /* There routines provide a modular interface to perform many parsing operations. They may therefore be used during actual parsing, or @@ -2509,7 +2510,14 @@ expand_body (fn) || (DECL_LANG_SPECIFIC (fn) && DECL_TEMPLATE_INFO (fn) && uses_template_parms (DECL_TI_ARGS (fn)))) - return; + { + /* Normally, collection only occurs in rest_of_compilation. So, + if we don't collect here, we never collect junk generated + during the processing of templates until we hit a + non-template function. */ + ggc_collect (); + return; + } /* There's no reason to do any of the work here if we're only doing semantic analysis; this code just generates RTL. */ @@ -2546,6 +2554,11 @@ expand_body (fn) /* Generate code for the function. */ finish_function (lineno, 0); + /* We don't need the body any more. Allow it to be garbage + collected. We can't do this if we're going to dump everything. */ + if (!flag_dump_translation_unit) + DECL_SAVED_TREE (fn) = NULL_TREE; + /* And restore the current source position. */ lineno = saved_lineno; input_filename = saved_input_filename;