cp-tree.def (TINST_LEVEL): Make it an 'x' node.
authorSteven Bosscher <stevenb@suse.de>
Tue, 20 Jul 2004 23:20:08 +0000 (23:20 +0000)
committerSteven Bosscher <steven@gcc.gnu.org>
Tue, 20 Jul 2004 23:20:08 +0000 (23:20 +0000)
* cp-tree.def (TINST_LEVEL): Make it an 'x' node.
* cp-tree.h (tinst_level_t): New tree type.
(union lang_tree_node): Handle it.
(TINST_LOCATION): New accessor macro.
(make_tinst_level): New prototype.
* cp-lang.c (cp_tree_size): Handle TINST_LEVEL.
* decl.c (cp_tree_node_structure): Likewise.
* error.c (print_instantiation_full_context): Use TINST_LOCATION.
(print_instantiation_partial_context): Likewise.
* pt.c (pop_tinst_level): Likewise.
 (push_tinst_level): Use make_tinst_level.
* tree.c (make_tinst_level): New function.
(cp_walk_subtrees): Walk TINST_DECL for a TINST_LEVEL node.

From-SVN: r84977

gcc/cp/ChangeLog
gcc/cp/cp-lang.c
gcc/cp/cp-tree.def
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/error.c
gcc/cp/pt.c
gcc/cp/tree.c

index 72fbb8b..3038907 100644 (file)
@@ -1,3 +1,19 @@
+2004-07-20  Steven Bosscher  <stevenb@suse.de>
+
+       * cp-tree.def (TINST_LEVEL): Make it an 'x' node.
+       * cp-tree.h (tinst_level_t): New tree type.
+       (union lang_tree_node): Handle it.
+       (TINST_LOCATION): New accessor macro.
+       (make_tinst_level): New prototype.
+       * cp-lang.c (cp_tree_size): Handle TINST_LEVEL.
+       * decl.c (cp_tree_node_structure): Likewise.
+       * error.c (print_instantiation_full_context): Use TINST_LOCATION.
+       (print_instantiation_partial_context): Likewise.
+       * pt.c (pop_tinst_level): Likewise.
+        (push_tinst_level): Use make_tinst_level.
+       * tree.c (make_tinst_level): New function.
+       (cp_walk_subtrees): Walk TINST_DECL for a TINST_LEVEL node.
+
 2004-07-20  Mark Mitchell  <mark@codesourcery.com>
 
        * parser.c (cp_parser_simple_type_specifier): Fix typo.
index 27c9270..cfdc82f 100644 (file)
@@ -284,6 +284,7 @@ cp_tree_size (enum tree_code code)
 {
   switch (code)
     {
+    case TINST_LEVEL:          return sizeof (struct tinst_level_s);
     case PTRMEM_CST:           return sizeof (struct ptrmem_cst);
     case BASELINK:             return sizeof (struct tree_baselink);
     case TEMPLATE_PARM_INDEX:  return sizeof (template_parm_index);
index f1912b1..d3629fd 100644 (file)
@@ -274,12 +274,13 @@ DEFTREECODE (TAG_DEFN, "tag_defn", 'e', 0)
 
 /* Template instantiation level node.
 
-   Operand 1 contains the original DECL node and can be accessed via TINST_DECL.
+   TINST_DECL contains the original DECL node.
+   TINST_LOCATION contains the location where the template is instantiated.
 
    A stack of template instantiation nodes is kept through the TREE_CHAIN
    fields of these nodes.  */
 
-DEFTREECODE (TINST_LEVEL, "TINST_LEVEL", 'e', 1)
+DEFTREECODE (TINST_LEVEL, "TINST_LEVEL", 'x', 0)
 
 /*
 Local variables:
index 097295d..df395eb 100644 (file)
@@ -183,14 +183,23 @@ struct lang_identifier GTY(())
 #define LANG_IDENTIFIER_CAST(NODE) \
        ((struct lang_identifier*)IDENTIFIER_NODE_CHECK (NODE))
 
-typedef struct template_parm_index_s GTY(())
+struct template_parm_index_s GTY(())
 {
   struct tree_common common;
   HOST_WIDE_INT index;
   HOST_WIDE_INT level;
   HOST_WIDE_INT orig_level;
   tree decl;
-} template_parm_index;
+};
+typedef struct template_parm_index_s template_parm_index;
+
+struct tinst_level_s GTY(())
+{
+  struct tree_common common;
+  tree decl;
+  location_t locus;
+};
+typedef struct tinst_level_s * tinst_level_t;
 
 struct ptrmem_cst GTY(())
 {
@@ -385,6 +394,7 @@ enum cp_tree_node_structure_enum {
   TS_CP_GENERIC,
   TS_CP_IDENTIFIER,
   TS_CP_TPI,
+  TS_CP_TINST_LEVEL,
   TS_CP_PTRMEM,
   TS_CP_BINDING,
   TS_CP_OVERLOAD,
@@ -401,6 +411,7 @@ union lang_tree_node GTY((desc ("cp_tree_node_structure (&%h)"),
   union tree_node GTY ((tag ("TS_CP_GENERIC"),
                        desc ("tree_node_structure (&%h)"))) generic;
   struct template_parm_index_s GTY ((tag ("TS_CP_TPI"))) tpi;
+  struct tinst_level_s GTY ((tag ("TS_CP_TINST_LEVEL"))) tinst_level;
   struct ptrmem_cst GTY ((tag ("TS_CP_PTRMEM"))) ptrmem;
   struct tree_overload GTY ((tag ("TS_CP_OVERLOAD"))) overload;
   struct tree_baselink GTY ((tag ("TS_CP_BASELINK"))) baselink;
@@ -3008,7 +3019,10 @@ typedef enum unification_kind_t {
 
 /* Macros for operating on a template instantiation level node.  */
 
-#define TINST_DECL(NODE) TREE_OPERAND (NODE, 0)
+#define TINST_DECL(NODE) \
+  (((tinst_level_t) TINST_LEVEL_CHECK (NODE))->decl)
+#define TINST_LOCATION(NODE) \
+  (((tinst_level_t) TINST_LEVEL_CHECK (NODE))->locus)
 
 /* in class.c */
 
@@ -4168,6 +4182,7 @@ extern tree build_dummy_object                    (tree);
 extern tree maybe_dummy_object                 (tree, tree *);
 extern int is_dummy_object                     (tree);
 extern const struct attribute_spec cxx_attribute_table[];
+extern tree make_tinst_level                    (tree, location_t);
 extern tree make_ptrmem_cst                     (tree, tree);
 extern tree cp_build_type_attribute_variant     (tree, tree);
 extern tree cp_build_qualified_type_real        (tree, int, tsubst_flags_t);
index 8dee86a..69c64d1 100644 (file)
@@ -10711,6 +10711,7 @@ cp_tree_node_structure (union lang_tree_node * t)
     case IDENTIFIER_NODE:      return TS_CP_IDENTIFIER;
     case OVERLOAD:             return TS_CP_OVERLOAD;
     case TEMPLATE_PARM_INDEX:  return TS_CP_TPI;
+    case TINST_LEVEL:          return TS_CP_TINST_LEVEL;
     case PTRMEM_CST:           return TS_CP_PTRMEM;
     case BASELINK:              return TS_CP_BASELINK;
     default:                   return TS_CP_GENERIC;
index cf1bf39..f9a322e 100644 (file)
@@ -2209,7 +2209,7 @@ print_instantiation_full_context (diagnostic_context *context)
                          decl_as_string (TINST_DECL (p),
                                          TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
 
-         location = EXPR_LOCATION (p);
+         location = TINST_LOCATION (p);
          p = TREE_CHAIN (p);
        }
     }
@@ -2232,7 +2232,7 @@ print_instantiation_partial_context (diagnostic_context *context,
                    xloc.file, xloc.line,
                    decl_as_string (TINST_DECL (t),
                                    TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
-      loc = EXPR_LOCATION (t);
+      loc = TINST_LOCATION (t);
     }
   pp_verbatim (context->printer, "%s:%d:   instantiated from here\n",
                xloc.file, xloc.line);
index 76769ef..86f945e 100644 (file)
@@ -4873,9 +4873,7 @@ push_tinst_level (tree d)
       return 0;
     }
 
-  new = make_node (TINST_LEVEL);
-  SET_EXPR_LOCATION (new, input_location);
-  TINST_DECL (new) = d;
+  new = make_tinst_level (d, input_location);
   TREE_CHAIN (new) = current_tinst_level;
   current_tinst_level = new;
 
@@ -4899,7 +4897,7 @@ pop_tinst_level (void)
 
   /* Restore the filename and line number stashed away when we started
      this instantiation.  */
-  input_location = EXPR_LOCATION (old);
+  input_location = TINST_LOCATION (old);
   extract_interface_info ();
   
   current_tinst_level = TREE_CHAIN (old);
index 918849d..0972ad2 100644 (file)
@@ -1900,6 +1900,17 @@ handle_init_priority_attribute (tree* node,
     }
 }
 
+/* Return a new TINST_LEVEL for DECL at location locus.  */
+tree
+make_tinst_level (tree decl, location_t locus)
+{
+  tree tinst_level = make_node (TINST_LEVEL);
+  TREE_CHAIN (tinst_level) = NULL_TREE;
+  TINST_DECL (tinst_level) = decl;
+  TINST_LOCATION (tinst_level) = locus;
+  return tinst_level;
+}
+
 /* Return a new PTRMEM_CST of the indicated TYPE.  The MEMBER is the
    thing pointed to by the constant.  */
 
@@ -1973,6 +1984,11 @@ cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func,
       *walk_subtrees_p = 0;
       break;
 
+    case TINST_LEVEL:
+      WALK_SUBTREE (TINST_DECL (*tp));
+      *walk_subtrees_p = 0;
+      break;
+
     case PTRMEM_CST:
       WALK_SUBTREE (TREE_TYPE (*tp));
       *walk_subtrees_p = 0;