cp-tree.h (CAN_HAVE_FULL_LANG_DECL_P): New macro.
authorMark Mitchell <mark@codesourcery.com>
Mon, 16 Aug 1999 22:08:42 +0000 (22:08 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 16 Aug 1999 22:08:42 +0000 (22:08 +0000)
* 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

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/lex.c

index bf6c0ac..cf9a357 100644 (file)
@@ -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.
index 3df1390..45374e9 100644 (file)
@@ -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;
 
index 4867013..1de0e31 100644 (file)
@@ -1153,12 +1153,14 @@ struct lang_type
 \f
 
 /* 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
 {
index 374717c..dee05d3 100644 (file)
@@ -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)
index c28bba0..f641dc6 100644 (file)
@@ -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);