* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84977
138bc75d-0d04-0410-961f-
82ee72b054a4
+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.
{
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);
/* 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:
#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(())
{
TS_CP_GENERIC,
TS_CP_IDENTIFIER,
TS_CP_TPI,
+ TS_CP_TINST_LEVEL,
TS_CP_PTRMEM,
TS_CP_BINDING,
TS_CP_OVERLOAD,
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;
/* 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 */
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);
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;
decl_as_string (TINST_DECL (p),
TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
- location = EXPR_LOCATION (p);
+ location = TINST_LOCATION (p);
p = TREE_CHAIN (p);
}
}
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);
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;
/* 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);
}
}
+/* 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. */
*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;