From bf12d54dac71bbf2194ebdab932fed9b180c3ce3 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Sun, 10 Aug 2003 15:10:35 +0000 Subject: [PATCH] cp-tree.h (TMPL_ARGS_HAVE_MULTIPLE_LEVELS): non-NULL NODE is always a TREE_VEC of non-zero size. cp: * cp-tree.h (TMPL_ARGS_HAVE_MULTIPLE_LEVELS): non-NULL NODE is always a TREE_VEC of non-zero size. (NUM_TMPL_ARGS): NODE is always a TREE_VEC. * decl2.c (arg_assoc): Template args will be a vec. * error.c (dump_decl) : Call dump_template_argument_list. (dump_template_parms): Args will be a vec. * parser.c (cp_parser_template_argument_list): Produce a vector, not a list. * pt.c (coerce_template_parms): Args are always vectors. (mangle_class_name_for_template): Likewise. (lookup_template_function): Likewise. (lookup_template_class): Likewise. (tsubst_template_args): Likewise. (tsubst_baselink): Use tsubst_template_args. (tsubst_qualified_id): Likewise. (tsubst_copy) : Likewise. (tsubst_copy_and_build) : Likewise. (any_dependent_template_args_p): Args are always vectors. * tree.c (cp_tree_equal): Add TEMPLATE_ID_EXPR case. From-SVN: r70295 --- gcc/cp/ChangeLog | 21 +++++++++ gcc/cp/cp-tree.def | 8 ++-- gcc/cp/cp-tree.h | 11 ++--- gcc/cp/decl2.c | 6 +-- gcc/cp/error.c | 45 +++++-------------- gcc/cp/parser.c | 47 ++++++++++++++------ gcc/cp/pt.c | 106 +++++++++++++-------------------------------- gcc/cp/tree.c | 24 ++++++++++ 8 files changed, 129 insertions(+), 139 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c4a59498cad..47c1afc84d1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,26 @@ 2003-08-10 Nathan Sidwell + * cp-tree.h (TMPL_ARGS_HAVE_MULTIPLE_LEVELS): non-NULL + NODE is always a TREE_VEC of non-zero size. + (NUM_TMPL_ARGS): NODE is always a TREE_VEC. + * decl2.c (arg_assoc): Template args will be a vec. + * error.c (dump_decl) : Call + dump_template_argument_list. + (dump_template_parms): Args will be a vec. + * parser.c (cp_parser_template_argument_list): Produce a + vector, not a list. + * pt.c (coerce_template_parms): Args are always vectors. + (mangle_class_name_for_template): Likewise. + (lookup_template_function): Likewise. + (lookup_template_class): Likewise. + (tsubst_template_args): Likewise. + (tsubst_baselink): Use tsubst_template_args. + (tsubst_qualified_id): Likewise. + (tsubst_copy) : Likewise. + (tsubst_copy_and_build) : Likewise. + (any_dependent_template_args_p): Args are always vectors. + * tree.c (cp_tree_equal): Add TEMPLATE_ID_EXPR case. + PR c++/11670 * call.c (convert_like_real): Add rvalue binding error message. * error.c (dump_expr) : Detect when the no expr is diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index f020a23d6a2..a5fa243a167 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -207,10 +207,10 @@ DEFTREECODE (USING_STMT, "using_directive", 'e', 1) DEFTREECODE (DEFAULT_ARG, "default_arg", 'x', 0) /* A template-id, like foo. The first operand is the template. - The second is the TREE_LIST or TREE_VEC of explicitly specified - arguments. The template will be a FUNCTION_DECL, TEMPLATE_DECL, or - an OVERLOAD. If the template-id refers to a member template, the - template may be an IDENTIFIER_NODE. */ + The second is NULL if there are no explicit arguments, or a + TREE_VEC of arguments. The template will be a FUNCTION_DECL, + TEMPLATE_DECL, or an OVERLOAD. If the template-id refers to a + member template, the template may be an IDENTIFIER_NODE. */ DEFTREECODE (TEMPLATE_ID_EXPR, "template_id_expr", 'e', 2) /* A list-like node for chaining overloading candidates. TREE_TYPE is diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 36dda85fe5b..d47c3077d09 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2203,11 +2203,8 @@ struct lang_decl GTY(()) /* Nonzero if the template arguments is actually a vector of vectors, rather than just a vector. */ -#define TMPL_ARGS_HAVE_MULTIPLE_LEVELS(NODE) \ - ((NODE) != NULL_TREE \ - && TREE_CODE (NODE) == TREE_VEC \ - && TREE_VEC_LENGTH (NODE) > 0 \ - && TREE_VEC_ELT (NODE, 0) != NULL_TREE \ +#define TMPL_ARGS_HAVE_MULTIPLE_LEVELS(NODE) \ + (NODE && TREE_VEC_ELT (NODE, 0) \ && TREE_CODE (TREE_VEC_ELT (NODE, 0)) == TREE_VEC) /* The depth of a template argument vector. When called directly by @@ -2241,9 +2238,7 @@ struct lang_decl GTY(()) /* Given a single level of template arguments in NODE, return the number of arguments. */ #define NUM_TMPL_ARGS(NODE) \ - ((NODE) == NULL_TREE ? 0 \ - : (TREE_CODE (NODE) == TREE_VEC \ - ? TREE_VEC_LENGTH (NODE) : list_length (NODE))) + (TREE_VEC_LENGTH (NODE)) /* Returns the innermost level of template arguments in ARGS. */ #define INNERMOST_TEMPLATE_ARGS(NODE) \ diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 46c4083c2a7..556f62a1472 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3716,7 +3716,7 @@ arg_assoc (struct arg_lookup *k, tree n) tree template = TREE_OPERAND (n, 0); tree args = TREE_OPERAND (n, 1); tree ctx; - tree arg; + int ix; if (TREE_CODE (template) == COMPONENT_REF) template = TREE_OPERAND (template, 1); @@ -3739,8 +3739,8 @@ arg_assoc (struct arg_lookup *k, tree n) return true; /* Now the arguments. */ - for (arg = args; arg != NULL_TREE; arg = TREE_CHAIN (arg)) - if (arg_assoc_template_arg (k, TREE_VALUE (arg)) == 1) + for (ix = TREE_VEC_LENGTH (args); ix--;) + if (arg_assoc_template_arg (k, TREE_VEC_ELT (args, ix)) == 1) return true; } else diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 3531f94ec8a..cd44f15cbb4 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -920,18 +920,14 @@ dump_decl (tree t, int flags) case TEMPLATE_ID_EXPR: { - tree args; tree name = TREE_OPERAND (t, 0); + if (is_overloaded_fn (name)) name = DECL_NAME (get_first_fn (name)); dump_decl (name, flags); pp_template_argument_list_start (cxx_pp); - for (args = TREE_OPERAND (t, 1); args; args = TREE_CHAIN (args)) - { - dump_template_argument (TREE_VALUE (args), flags); - if (TREE_CHAIN (args)) - pp_separate_with_comma (cxx_pp); - } + if (TREE_OPERAND (t, 1)) + dump_template_argument_list (TREE_OPERAND (t, 1), flags); pp_template_argument_list_end (cxx_pp); } break; @@ -1256,41 +1252,24 @@ dump_template_parms (tree info, int primary, int flags) to crash producing error messages. */ if (args && !primary) { - int len = 0; - int ix = 0; - int need_comma = 0; + int len, ix; - if (TREE_CODE (args) == TREE_VEC) - { - if (TREE_VEC_LENGTH (args) > 0 - && TREE_CODE (TREE_VEC_ELT (args, 0)) == TREE_VEC) - args = TREE_VEC_ELT (args, TREE_VEC_LENGTH (args) - 1); + if (TMPL_ARGS_HAVE_MULTIPLE_LEVELS (args)) + args = TREE_VEC_ELT (args, TREE_VEC_LENGTH (args) - 1); + + len = TREE_VEC_LENGTH (args); - len = TREE_VEC_LENGTH (args); - } - else if (TREE_CODE (args) == TREE_LIST) - len = -1; - while (ix != len && args) + for (ix = 0; ix != len; ix++) { - tree arg; - if (len >= 0) - { - arg = TREE_VEC_ELT (args, ix); - ix++; - } - else - { - arg = TREE_VALUE (args); - args = TREE_CHAIN (args); - } - if (need_comma) + tree arg = TREE_VEC_ELT (args, ix); + + if (ix) pp_separate_with_comma (cxx_pp); if (!arg) pp_identifier (cxx_pp, "