Commit b0d06515 by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (CAN_HAVE_FULL_LANG_DECL_P): New macro.

	* cp-tree.h (CAN_HAVE_FULL_LANG_DECL_P): New macro.
	* class.c (build_vtable): Use build_lang_field_decl to build the
	VAR_DECLs for vtables.
	(prepare_fresh_vtable): Likewise.
	* decl.c (duplicate_decls): Only copy DECL_SAVED_TREE if
	CAN_HAVE_FULL_LANG_DECL_P.
	(push_using_decl): Use build_lang_decl to build USING_DECLs.
	(grokdeclarator): Use build_lang_decl to build TYPE_DECLs.
	* lex.c (retrofit_lang_decl): Check CAN_HAVE_FULL_LANG_DECL_P.
	(build_lang_field_decl): Likewise.
	(copy_lang_decl): Use CAN_HAVE_FULLLANG_DECL_P to decide how much
	to copy.

From-SVN: r28731
parent 58e78708
1999-08-16 Mark Mitchell <mark@codesourcery.com> 1999-08-16 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (CAN_HAVE_FULL_LANG_DECL_P): New macro.
* class.c (build_vtable): Use build_lang_field_decl to build the
VAR_DECLs for vtables.
(prepare_fresh_vtable): Likewise.
* decl.c (duplicate_decls): Only copy DECL_SAVED_TREE if
CAN_HAVE_FULL_LANG_DECL_P.
(push_using_decl): Use build_lang_decl to build USING_DECLs.
(grokdeclarator): Use build_lang_decl to build TYPE_DECLs.
* lex.c (retrofit_lang_decl): Check CAN_HAVE_FULL_LANG_DECL_P.
(build_lang_field_decl): Likewise.
(copy_lang_decl): Use CAN_HAVE_FULLLANG_DECL_P to decide how much
to copy.
* cp-tree.def (STMT_EXPR): New tree node. * cp-tree.def (STMT_EXPR): New tree node.
* cp-tree.h (STMT_EXPR_STMT): New macro. * cp-tree.h (STMT_EXPR_STMT): New macro.
(store_return_init): Change prototype. (store_return_init): Change prototype.
......
...@@ -737,7 +737,8 @@ build_vtable (binfo, type) ...@@ -737,7 +737,8 @@ build_vtable (binfo, type)
tree offset; tree offset;
virtuals = copy_list (BINFO_VIRTUALS (binfo)); virtuals = copy_list (BINFO_VIRTUALS (binfo));
decl = build_lang_decl (VAR_DECL, name, TREE_TYPE (BINFO_VTABLE (binfo))); decl = build_lang_field_decl (VAR_DECL, name,
TREE_TYPE (BINFO_VTABLE (binfo)));
/* Now do rtti stuff. */ /* Now do rtti stuff. */
offset = get_derived_offset (TYPE_BINFO (type), NULL_TREE); offset = get_derived_offset (TYPE_BINFO (type), NULL_TREE);
...@@ -747,7 +748,7 @@ build_vtable (binfo, type) ...@@ -747,7 +748,7 @@ build_vtable (binfo, type)
else else
{ {
virtuals = NULL_TREE; virtuals = NULL_TREE;
decl = build_lang_decl (VAR_DECL, name, void_type_node); decl = build_lang_field_decl (VAR_DECL, name, void_type_node);
} }
#ifdef GATHER_STATISTICS #ifdef GATHER_STATISTICS
...@@ -897,7 +898,7 @@ prepare_fresh_vtable (binfo, for_type) ...@@ -897,7 +898,7 @@ prepare_fresh_vtable (binfo, for_type)
buf2 = new_buf2; buf2 = new_buf2;
} }
new_decl = build_lang_decl (VAR_DECL, name, TREE_TYPE (orig_decl)); new_decl = build_lang_field_decl (VAR_DECL, name, TREE_TYPE (orig_decl));
/* Remember which class this vtable is really for. */ /* Remember which class this vtable is really for. */
DECL_CONTEXT (new_decl) = for_type; DECL_CONTEXT (new_decl) = for_type;
......
...@@ -1153,12 +1153,14 @@ struct lang_type ...@@ -1153,12 +1153,14 @@ struct lang_type
/* If a DECL has DECL_LANG_SPECIFIC, it is either a lang_decl_flags or /* If a DECL has DECL_LANG_SPECIFIC, it is either a lang_decl_flags or
a lang_decl (which has lang_decl_flags as its initial prefix). A a lang_decl (which has lang_decl_flags as its initial prefix).
FUNCTION_DECL, NAMESPACE_DECL, TYPE_DECL, or USING_DECL may have a This macro is nonzero for tree nodes whose DECL_LANG_SPECIFIC is
full lang_decl. A FIELD_DECL, or a static data member VAR_DECL, the full lang_decl, and not just lang_decl_flags. */
will have only lang_decl_flags. Thus, one should only access the #define CAN_HAVE_FULL_LANG_DECL_P(NODE) \
members of lang_decl that are not in lang_decl_flags for DECLs that (!(TREE_CODE ((NODE)) == VAR_DECL \
are not FIELD_DECLs or VAR_DECLs. */ || TREE_CODE ((NODE)) == CONST_DECL \
|| TREE_CODE ((NODE)) == FIELD_DECL \
|| TREE_CODE ((NODE)) == USING_DECL))
struct lang_decl_flags struct lang_decl_flags
{ {
......
...@@ -3523,7 +3523,8 @@ duplicate_decls (newdecl, olddecl) ...@@ -3523,7 +3523,8 @@ duplicate_decls (newdecl, olddecl)
DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl); DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
DECL_SOURCE_FILE (newdecl) = DECL_SOURCE_FILE (olddecl); DECL_SOURCE_FILE (newdecl) = DECL_SOURCE_FILE (olddecl);
DECL_SOURCE_LINE (newdecl) = DECL_SOURCE_LINE (olddecl); DECL_SOURCE_LINE (newdecl) = DECL_SOURCE_LINE (olddecl);
if (DECL_LANG_SPECIFIC (newdecl) if (CAN_HAVE_FULL_LANG_DECL_P (newdecl)
&& DECL_LANG_SPECIFIC (newdecl)
&& DECL_LANG_SPECIFIC (olddecl)) && DECL_LANG_SPECIFIC (olddecl))
DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl); DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl);
} }
...@@ -4474,7 +4475,7 @@ push_using_decl (scope, name) ...@@ -4474,7 +4475,7 @@ push_using_decl (scope, name)
break; break;
if (decl) if (decl)
return NULL_TREE; return NULL_TREE;
decl = build_lang_decl (USING_DECL, name, void_type_node); decl = build_lang_field_decl (USING_DECL, name, void_type_node);
DECL_INITIAL (decl) = scope; DECL_INITIAL (decl) = scope;
TREE_CHAIN (decl) = current_binding_level->usings; TREE_CHAIN (decl) = current_binding_level->usings;
current_binding_level->usings = decl; current_binding_level->usings = decl;
...@@ -10553,7 +10554,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) ...@@ -10553,7 +10554,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
if (type != error_mark_node) if (type != error_mark_node)
push_obstacks (TYPE_OBSTACK (type), TYPE_OBSTACK (type)); push_obstacks (TYPE_OBSTACK (type), TYPE_OBSTACK (type));
if (processing_template_decl) if (processing_template_decl)
decl = build_lang_field_decl (TYPE_DECL, declarator, type); decl = build_lang_decl (TYPE_DECL, declarator, type);
else else
decl = build_decl (TYPE_DECL, declarator, type); decl = build_decl (TYPE_DECL, declarator, type);
if (type != error_mark_node) if (type != error_mark_node)
......
...@@ -4742,6 +4742,8 @@ retrofit_lang_decl (t) ...@@ -4742,6 +4742,8 @@ retrofit_lang_decl (t)
struct obstack *obstack = current_obstack; struct obstack *obstack = current_obstack;
struct lang_decl *ld; struct lang_decl *ld;
my_friendly_assert (CAN_HAVE_FULL_LANG_DECL_P (t), 19990816);
if (! TREE_PERMANENT (t)) if (! TREE_PERMANENT (t))
obstack = saveable_obstack; obstack = saveable_obstack;
else else
...@@ -4795,6 +4797,8 @@ build_lang_field_decl (code, name, type) ...@@ -4795,6 +4797,8 @@ build_lang_field_decl (code, name, type)
else else
my_friendly_assert (obstack == &permanent_obstack, 235); my_friendly_assert (obstack == &permanent_obstack, 235);
my_friendly_assert (!CAN_HAVE_FULL_LANG_DECL_P (t), 19990816);
DECL_LANG_SPECIFIC (t) DECL_LANG_SPECIFIC (t)
= ((struct lang_decl *) = ((struct lang_decl *)
obstack_alloc (obstack, sizeof (struct lang_decl_flags))); obstack_alloc (obstack, sizeof (struct lang_decl_flags)));
...@@ -4812,7 +4816,7 @@ copy_lang_decl (node) ...@@ -4812,7 +4816,7 @@ copy_lang_decl (node)
if (! DECL_LANG_SPECIFIC (node)) if (! DECL_LANG_SPECIFIC (node))
return; return;
if (TREE_CODE (node) == FIELD_DECL) if (!CAN_HAVE_FULL_LANG_DECL_P (node))
size = sizeof (struct lang_decl_flags); size = sizeof (struct lang_decl_flags);
else else
size = sizeof (struct lang_decl); size = sizeof (struct lang_decl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment