aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@gcc.gnu.org>2005-06-07 11:56:11 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2005-06-07 11:56:11 +0000
commit01ea1ea8269ff36065e625b0b5e348568519bfa3 (patch)
tree9ba436b1b1c7d37ecfccbe0bd6d3fbbc96b13e04 /gcc/cp
parentc938250d71aa69cb46490ac49058fc1a499962e4 (diff)
downloadgcc-01ea1ea8269ff36065e625b0b5e348568519bfa3.zip
gcc-01ea1ea8269ff36065e625b0b5e348568519bfa3.tar.gz
gcc-01ea1ea8269ff36065e625b0b5e348568519bfa3.tar.bz2
cp-tree.def (DEFAULT_ARG): Adjust documentation.
* cp-tree.def (DEFAULT_ARG): Adjust documentation. * cp-tree.h (DEFARG_INSTANTIATIONS): New. (struct tree_default_arg): Add instantiations member. * parser.c (cp_parser_late_parsing_default_args): Adjust to use a VEC. * pt.c (tsubst_arg_types): Likewise. From-SVN: r100707
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/cp-tree.def6
-rw-r--r--gcc/cp/cp-tree.h3
-rw-r--r--gcc/cp/parser.c13
-rw-r--r--gcc/cp/pt.c3
4 files changed, 15 insertions, 10 deletions
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index 2728467..aa0ea83 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -206,9 +206,9 @@ DEFTREECODE (USING_DECL, "using_decl", tcc_declaration, 0)
/* A using directive. The operand is USING_STMT_NAMESPACE. */
DEFTREECODE (USING_STMT, "using_directive", tcc_statement, 1)
-/* An un-parsed default argument. Looks like an IDENTIFIER_NODE.
- TREE_CHAIN is used to hold instantiations of functions that had to
- be instantiated before the argument was parsed. */
+/* An un-parsed default argument. Holds a vector of input tokens and
+ a vector of places where the argument was instantiated before
+ parsing had occurred. */
DEFTREECODE (DEFAULT_ARG, "default_arg", tcc_exceptional, 0)
/* A template-id, like foo<int>. The first operand is the template.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 6cf7fa0..90de20c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -424,11 +424,14 @@ typedef enum cp_id_kind
#define DEFARG_TOKENS(NODE) \
(((struct tree_default_arg *)DEFAULT_ARG_CHECK (NODE))->tokens)
+#define DEFARG_INSTANTIATIONS(NODE) \
+ (((struct tree_default_arg *)DEFAULT_ARG_CHECK (NODE))->instantiations)
struct tree_default_arg GTY (())
{
struct tree_common common;
struct cp_token_cache *tokens;
+ VEC(tree,gc) *instantiations;
};
enum cp_tree_node_structure_enum {
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 23c1621..24cb027 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -12145,7 +12145,8 @@ cp_parser_parameter_declaration (cp_parser *parser,
argument. */
default_argument = make_node (DEFAULT_ARG);
DEFARG_TOKENS (default_argument)
- = cp_token_cache_new (first_token, token);
+ = cp_token_cache_new (first_token, token);
+ DEFARG_INSTANTIATIONS (default_argument) = NULL;
}
/* Outside of a class definition, we can just parse the
assignment-expression. */
@@ -15595,6 +15596,9 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn)
cp_token_cache *tokens;
tree default_arg = TREE_PURPOSE (parm);
tree parsed_arg;
+ VEC(tree,gc) *insts;
+ tree copy;
+ unsigned ix;
if (!default_arg)
continue;
@@ -15615,10 +15619,9 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn)
TREE_PURPOSE (parm) = parsed_arg;
/* Update any instantiations we've already created. */
- for (default_arg = TREE_CHAIN (default_arg);
- default_arg;
- default_arg = TREE_CHAIN (default_arg))
- TREE_PURPOSE (TREE_PURPOSE (default_arg)) = parsed_arg;
+ for (insts = DEFARG_INSTANTIATIONS (default_arg), ix = 0;
+ VEC_iterate (tree, insts, ix, copy); ix++)
+ TREE_PURPOSE (copy) = parsed_arg;
/* If the token stream has not been completely used up, then
there was extra junk after the end of the default
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 7924bbe..f7eb935 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -6745,8 +6745,7 @@ tsubst_arg_types (tree arg_types,
class, and is not an error unless we require the default
argument in a call of this function. */
result = tree_cons (default_arg, type, remaining_arg_types);
- TREE_CHAIN (default_arg) = tree_cons (result, NULL_TREE,
- TREE_CHAIN (default_arg));
+ VEC_safe_push (tree, gc, DEFARG_INSTANTIATIONS (default_arg), result);
}
else
result = hash_tree_cons (default_arg, type, remaining_arg_types);