From c6138f2ddb9b77a319ecbd4f6f7be5fdfa48bdbb Mon Sep 17 00:00:00 2001 From: mmitchel Date: Mon, 16 Aug 1999 22:08:42 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@28731 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 13 +++++++++++++ gcc/cp/class.c | 7 ++++--- gcc/cp/cp-tree.h | 14 ++++++++------ gcc/cp/decl.c | 7 ++++--- gcc/cp/lex.c | 6 +++++- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bf6c0ac1f38..cf9a35799da 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,18 @@ 1999-08-16 Mark Mitchell + * 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 3df13905224..45374e9ae21 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 486701324ed..1de0e310c62 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 374717cc1a6..dee05d3cc18 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 c28bba06f4e..f641dc60f90 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); -- 2.11.0