aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>1999-08-16 22:08:42 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-08-16 22:08:42 +0000
commitb0d065155dcf58badec4abea8652c1b06b66a2e1 (patch)
treefd0402d39944fba3227e3d96dfb3cd381a03ca61
parent58e787081dad89dd64099d2a039651a2bcd29df6 (diff)
downloadgcc-b0d065155dcf58badec4abea8652c1b06b66a2e1.zip
gcc-b0d065155dcf58badec4abea8652c1b06b66a2e1.tar.gz
gcc-b0d065155dcf58badec4abea8652c1b06b66a2e1.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog13
-rw-r--r--gcc/cp/class.c7
-rw-r--r--gcc/cp/cp-tree.h14
-rw-r--r--gcc/cp/decl.c7
-rw-r--r--gcc/cp/lex.c6
5 files changed, 34 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index bf6c0ac..cf9a357 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,18 @@
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.h (STMT_EXPR_STMT): New macro.
(store_return_init): Change prototype.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 3df1390..45374e9 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -737,7 +737,8 @@ build_vtable (binfo, type)
tree offset;
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. */
offset = get_derived_offset (TYPE_BINFO (type), NULL_TREE);
@@ -747,7 +748,7 @@ build_vtable (binfo, type)
else
{
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
@@ -897,7 +898,7 @@ prepare_fresh_vtable (binfo, for_type)
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. */
DECL_CONTEXT (new_decl) = for_type;
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 4867013..1de0e31 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -1153,12 +1153,14 @@ struct lang_type
/* 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
- FUNCTION_DECL, NAMESPACE_DECL, TYPE_DECL, or USING_DECL may have a
- full lang_decl. A FIELD_DECL, or a static data member VAR_DECL,
- will have only lang_decl_flags. Thus, one should only access the
- members of lang_decl that are not in lang_decl_flags for DECLs that
- are not FIELD_DECLs or VAR_DECLs. */
+ a lang_decl (which has lang_decl_flags as its initial prefix).
+ This macro is nonzero for tree nodes whose DECL_LANG_SPECIFIC is
+ the full lang_decl, and not just lang_decl_flags. */
+#define CAN_HAVE_FULL_LANG_DECL_P(NODE) \
+ (!(TREE_CODE ((NODE)) == VAR_DECL \
+ || TREE_CODE ((NODE)) == CONST_DECL \
+ || TREE_CODE ((NODE)) == FIELD_DECL \
+ || TREE_CODE ((NODE)) == USING_DECL))
struct lang_decl_flags
{
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 374717c..dee05d3 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -3523,7 +3523,8 @@ duplicate_decls (newdecl, olddecl)
DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
DECL_SOURCE_FILE (newdecl) = DECL_SOURCE_FILE (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_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl);
}
@@ -4474,7 +4475,7 @@ push_using_decl (scope, name)
break;
if (decl)
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;
TREE_CHAIN (decl) = current_binding_level->usings;
current_binding_level->usings = decl;
@@ -10553,7 +10554,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
if (type != error_mark_node)
push_obstacks (TYPE_OBSTACK (type), TYPE_OBSTACK (type));
if (processing_template_decl)
- decl = build_lang_field_decl (TYPE_DECL, declarator, type);
+ decl = build_lang_decl (TYPE_DECL, declarator, type);
else
decl = build_decl (TYPE_DECL, declarator, type);
if (type != error_mark_node)
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index c28bba0..f641dc6 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -4742,6 +4742,8 @@ retrofit_lang_decl (t)
struct obstack *obstack = current_obstack;
struct lang_decl *ld;
+ my_friendly_assert (CAN_HAVE_FULL_LANG_DECL_P (t), 19990816);
+
if (! TREE_PERMANENT (t))
obstack = saveable_obstack;
else
@@ -4795,6 +4797,8 @@ build_lang_field_decl (code, name, type)
else
my_friendly_assert (obstack == &permanent_obstack, 235);
+ my_friendly_assert (!CAN_HAVE_FULL_LANG_DECL_P (t), 19990816);
+
DECL_LANG_SPECIFIC (t)
= ((struct lang_decl *)
obstack_alloc (obstack, sizeof (struct lang_decl_flags)));
@@ -4812,7 +4816,7 @@ copy_lang_decl (node)
if (! DECL_LANG_SPECIFIC (node))
return;
- if (TREE_CODE (node) == FIELD_DECL)
+ if (!CAN_HAVE_FULL_LANG_DECL_P (node))
size = sizeof (struct lang_decl_flags);
else
size = sizeof (struct lang_decl);