From 018c1ab0f8152ace247ffc951d676032f93675d6 Mon Sep 17 00:00:00 2001 From: steven Date: Tue, 20 Jul 2004 23:20:08 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84977 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 16 ++++++++++++++++ gcc/cp/cp-lang.c | 1 + gcc/cp/cp-tree.def | 5 +++-- gcc/cp/cp-tree.h | 21 ++++++++++++++++++--- gcc/cp/decl.c | 1 + gcc/cp/error.c | 4 ++-- gcc/cp/pt.c | 6 ++---- gcc/cp/tree.c | 16 ++++++++++++++++ 8 files changed, 59 insertions(+), 11 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 72fbb8b07d2..3038907545c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,19 @@ +2004-07-20 Steven Bosscher + + * 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 * parser.c (cp_parser_simple_type_specifier): Fix typo. diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c index 27c9270130f..cfdc82f4762 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 f1912b17438..d3629fd98e2 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 097295d937d..df395ebd952 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 8dee86aff14..69c64d19f8e 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 cf1bf39f36b..f9a322eacff 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 76769ef00a1..86f945e7f8f 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 918849d4ab4..0972ad2680d 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; -- 2.11.4.GIT