aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Bosscher <stevenb@suse.de>2004-07-20 23:20:08 +0000
committerSteven Bosscher <steven@gcc.gnu.org>2004-07-20 23:20:08 +0000
commit406d77a4bb10d5b60a9a061f59405e0aa850ea2b (patch)
tree60f27536fd4be89c4b8a14b5f5c8d884d5f061bd
parent3e95a7cbf534c8f738a3267773f03dfe80d69484 (diff)
downloadgcc-406d77a4bb10d5b60a9a061f59405e0aa850ea2b.zip
gcc-406d77a4bb10d5b60a9a061f59405e0aa850ea2b.tar.gz
gcc-406d77a4bb10d5b60a9a061f59405e0aa850ea2b.tar.bz2
cp-tree.def (TINST_LEVEL): Make it an 'x' node.
* 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
-rw-r--r--gcc/cp/ChangeLog16
-rw-r--r--gcc/cp/cp-lang.c1
-rw-r--r--gcc/cp/cp-tree.def5
-rw-r--r--gcc/cp/cp-tree.h21
-rw-r--r--gcc/cp/decl.c1
-rw-r--r--gcc/cp/error.c4
-rw-r--r--gcc/cp/pt.c6
-rw-r--r--gcc/cp/tree.c16
8 files changed, 59 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 72fbb8b..3038907 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c
index 27c9270..cfdc82f 100644
--- a/gcc/cp/cp-lang.c
+++ b/gcc/cp/cp-lang.c
@@ -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);
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index f1912b1..d3629fd 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -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:
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 097295d..df395eb 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 8dee86a..69c64d1 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index cf1bf39..f9a322e 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -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);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 76769ef..86f945e 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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);
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 918849d..0972ad2 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -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;