* cp-tree.h (lang_decl_flags): Remove permanent_attr.
Remove next.
(LANG_DECL_PERMANENT): Remove.
* decl.c (duplicate_decls): Don't mess about with obstacks trying
to free memory.
(lang_mark_tree): Mark DECL_LANG_SPECIFIC.
* lex.c (free_lang_decl_chain): Remove.
(build_lang_decl): Don't use obstacks.
(retrofit_lang_decl): Likewise.
(copy_lang_decl): Likewise.
From-SVN: r29223
1999-09-08 Mark Mitchell <mark@codesourcery.com>
+ * cp-tree.h (lang_decl_flags): Remove permanent_attr.
+ Remove next.
+ (LANG_DECL_PERMANENT): Remove.
+ * decl.c (duplicate_decls): Don't mess about with obstacks trying
+ to free memory.
+ (lang_mark_tree): Mark DECL_LANG_SPECIFIC.
+ * lex.c (free_lang_decl_chain): Remove.
+ (build_lang_decl): Don't use obstacks.
+ (retrofit_lang_decl): Likewise.
+ (copy_lang_decl): Likewise.
+
* cp-tree.h (saved_scope): Remove old_binding_level and
function_decl. Tidy up.
* decl.c (mark_saved_scope): Don't set them.
unsigned const_memfunc : 1;
unsigned volatile_memfunc : 1;
unsigned abstract_virtual : 1;
- unsigned permanent_attr : 1 ;
-
unsigned constructor_for_vbase_attr : 1;
+
unsigned mutable_flag : 1;
unsigned saved_inline : 1;
unsigned use_template : 2;
unsigned nonconverting : 1;
unsigned declared_inline : 1;
unsigned not_really_extern : 1;
-
unsigned needs_final_overrider : 1;
+
unsigned bitfield : 1;
unsigned defined_in_class : 1;
- unsigned dummy : 5;
+ unsigned dummy : 6;
tree access;
tree context;
{
tree sorted_fields;
struct pending_inline *pending_inline_info;
- /* The lang_decls on the free_lang_decl_chain are chained together
- through this pointer. */
- struct lang_decl *next;
} u;
};
must be overridden by derived classes. */
#define DECL_NEEDS_FINAL_OVERRIDER_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.needs_final_overrider)
-/* Nonzero if allocated on permanent_obstack. */
-#define LANG_DECL_PERMANENT(LANGDECL) ((LANGDECL)->decl_flags.permanent_attr)
-
/* The _TYPE context in which this _DECL appears. This field holds the
class where a virtual function instance is actually defined, and the
lexical scope of a friend function defined in a class body. */
duplicate_decls (newdecl, olddecl)
tree newdecl, olddecl;
{
- extern struct obstack permanent_obstack;
unsigned olddecl_uid = DECL_UID (olddecl);
int olddecl_friend = 0, types_match = 0;
int new_defines_function = 0;
if (TREE_CODE (newdecl) == FUNCTION_DECL)
{
int function_size;
- struct lang_decl *ol = DECL_LANG_SPECIFIC (olddecl);
- struct lang_decl *nl = DECL_LANG_SPECIFIC (newdecl);
function_size = sizeof (struct tree_decl);
(char *) olddecl + sizeof (struct tree_common),
function_size - sizeof (struct tree_common));
- /* Can we safely free the storage used by newdecl? */
-
-#define ROUND(x) ((x + obstack_alignment_mask (&permanent_obstack)) \
- & ~ obstack_alignment_mask (&permanent_obstack))
-
if (DECL_TEMPLATE_INSTANTIATION (newdecl))
{
/* If newdecl is a template instantiation, it is possible that
if (TREE_VALUE (decls) == newdecl)
TREE_VALUE (decls) = olddecl;
}
-
- if (((char *)newdecl + ROUND (function_size) == (char *)nl
- && ((char *)newdecl + ROUND (function_size)
- + ROUND (sizeof (struct lang_decl))
- == obstack_next_free (&permanent_obstack)))
- || ((char *)newdecl + ROUND (function_size)
- == obstack_next_free (&permanent_obstack)))
- {
- DECL_MAIN_VARIANT (newdecl) = olddecl;
- DECL_LANG_SPECIFIC (olddecl) = ol;
- bcopy ((char *)nl, (char *)ol, sizeof (struct lang_decl));
-
- obstack_free (&permanent_obstack, newdecl);
- }
- else if (LANG_DECL_PERMANENT (ol) && ol != nl)
- {
- if (DECL_MAIN_VARIANT (olddecl) == olddecl)
- {
- struct lang_decl *free_lang_decl = ol;
-
- /* Save these lang_decls that would otherwise be lost. */
- if (DECL_LANG_SPECIFIC (olddecl) == ol)
- abort ();
-
- free_lang_decl->u.next = free_lang_decl_chain;
- free_lang_decl_chain = free_lang_decl;
- }
- else
- {
- /* Storage leak. */;
- }
- }
}
else
{
if (ld)
{
+ ggc_mark (ld);
ggc_mark_tree (ld->decl_flags.access);
ggc_mark_tree (ld->decl_flags.context);
if (TREE_CODE (t) != NAMESPACE_DECL)
extern int tree_node_sizes[];
#endif
-/* Place to save freed lang_decls which were allocated on the
- permanent_obstack. */
-struct lang_decl *free_lang_decl_chain;
-
tree
build_lang_decl (code, name, type)
enum tree_code code;
{
tree t;
- /* When we're building statement trees, declarations need to live
- forever. */
- if (building_stmt_tree ())
- push_permanent_obstack ();
-
t = build_decl (code, name, type);
retrofit_lang_decl (t);
- if (building_stmt_tree ())
- pop_obstacks ();
-
return t;
}
retrofit_lang_decl (t)
tree t;
{
- struct obstack *obstack = current_obstack;
struct lang_decl *ld;
size_t size;
else
size = sizeof (struct lang_decl_flags);
- if (! TREE_PERMANENT (t))
- obstack = saveable_obstack;
- else
- /* Could be that saveable is permanent and current is not. */
- obstack = &permanent_obstack;
-
- if (CAN_HAVE_FULL_LANG_DECL_P (t) && free_lang_decl_chain
- && obstack == &permanent_obstack)
- {
- ld = free_lang_decl_chain;
- free_lang_decl_chain = free_lang_decl_chain->u.next;
- }
- else
- ld = (struct lang_decl *) obstack_alloc (obstack, size);
-
+ ld = (struct lang_decl *) ggc_alloc (size);
memset (ld, 0, size);
DECL_LANG_SPECIFIC (t) = ld;
- LANG_DECL_PERMANENT (ld) = obstack == &permanent_obstack;
- my_friendly_assert (LANG_DECL_PERMANENT (ld) == TREE_PERMANENT (t), 234);
if (current_lang_name == lang_name_cplusplus)
DECL_LANGUAGE (t) = lang_cplusplus;
else if (current_lang_name == lang_name_c)
tree node;
{
int size;
- int *pi;
+ struct lang_decl *ld;
if (! DECL_LANG_SPECIFIC (node))
return;
size = sizeof (struct lang_decl_flags);
else
size = sizeof (struct lang_decl);
- pi = (int *)obstack_alloc (&permanent_obstack, size);
- bcopy ((char *)DECL_LANG_SPECIFIC (node), (char *)pi, size);
- DECL_LANG_SPECIFIC (node) = (struct lang_decl *)pi;
+ ld = (struct lang_decl *) ggc_alloc (size);
+ bcopy ((char *)DECL_LANG_SPECIFIC (node), (char *)ld, size);
+ DECL_LANG_SPECIFIC (node) = ld;
}
tree