diff options
author | Nathan Sidwell <nathan@gcc.gnu.org> | 2003-03-24 20:40:25 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2003-03-24 20:40:25 +0000 |
commit | bd83b409c56d2a1d1d7a536a5a65fc1ca97b6618 (patch) | |
tree | 4406753d0d9cfe1b65f113dc41067cc1b4e5352c | |
parent | 1c82cc908167526cae555db74532db40f889fe1d (diff) | |
download | gcc-bd83b409c56d2a1d1d7a536a5a65fc1ca97b6618.zip gcc-bd83b409c56d2a1d1d7a536a5a65fc1ca97b6618.tar.gz gcc-bd83b409c56d2a1d1d7a536a5a65fc1ca97b6618.tar.bz2 |
Changelog commit escaped earlier
Changelog commit escaped earlier
cp:
PR c++/10119
* error.c (dump_expr) [BASELINK]: Use dump_expr.
* pt.c (maybe_fold_nontype_args): New function.
(tsubst_copy) [SCOPE_REF]: Subst any template_id args.
[TEMPLATE_ID_EXPR]: Break out folding code, call it.
(tsubst_copy_and_build) [TEMPLATE_ID_EXPR]: Call
maybe_fold_nontype_args.
testsuite:
PR c++/10119
* g++.dg/template/ptrmem5.C: New test.
From-SVN: r64819
-rw-r--r-- | gcc/cp/error.c | 2 | ||||
-rw-r--r-- | gcc/cp/pt.c | 49 |
2 files changed, 32 insertions, 19 deletions
diff --git a/gcc/cp/error.c b/gcc/cp/error.c index e687ac0..a19374a 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -2010,7 +2010,7 @@ dump_expr (tree t, int flags) break; case BASELINK: - print_tree_identifier (scratch_buffer, DECL_NAME (get_first_fn (t))); + dump_expr (get_first_fn (t), flags & ~TFF_EXPR_IN_PARENS); break; /* else fall through */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3557f9f..ab52970 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -117,6 +117,7 @@ static int type_unification_real PARAMS ((tree, tree, tree, tree, int, unification_kind_t, int, int)); static void note_template_header PARAMS ((int)); static tree maybe_fold_nontype_arg PARAMS ((tree)); +static void maybe_fold_nontype_args PARAMS ((tree)); static tree convert_nontype_argument PARAMS ((tree, tree)); static tree convert_template_argument PARAMS ((tree, tree, tree, tsubst_flags_t, int, tree)); @@ -5618,6 +5619,28 @@ maybe_fold_nontype_arg (arg) return arg; } +/* Apply maybe_fold_nontype_arg on a list or vector of args. */ + +static void +maybe_fold_nontype_args (tree targs) +{ + if (!targs) + /*OK*/; + else if (TREE_CODE (targs) == TREE_LIST) + { + tree chain; + for (chain = targs; chain; chain = TREE_CHAIN (chain)) + TREE_VALUE (chain) = maybe_fold_nontype_arg (TREE_VALUE (chain)); + } + else + { + int i; + for (i = 0; i < TREE_VEC_LENGTH (targs); ++i) + TREE_VEC_ELT (targs, i) + = maybe_fold_nontype_arg (TREE_VEC_ELT (targs, i)); + } +} + /* Substitute ARGS into the vector of template arguments T. */ static tree @@ -7243,6 +7266,9 @@ tsubst_copy (t, args, complain, in_decl) template_id_p = true; template_args = TREE_OPERAND (fns, 1); fns = TREE_OPERAND (fns, 0); + template_args = tsubst_copy (template_args, args, + complain, in_decl); + maybe_fold_nontype_args (template_args); } name = DECL_NAME (get_first_fn (fns)); t = lookup_fnfields (qualifying_scope, name, /*protect=*/1); @@ -7450,20 +7476,7 @@ tsubst_copy (t, args, complain, in_decl) tree targs = tsubst_copy (TREE_OPERAND (t, 1), args, complain, in_decl); - if (targs && TREE_CODE (targs) == TREE_LIST) - { - tree chain; - for (chain = targs; chain; chain = TREE_CHAIN (chain)) - TREE_VALUE (chain) = maybe_fold_nontype_arg (TREE_VALUE (chain)); - } - else if (targs) - { - int i; - for (i = 0; i < TREE_VEC_LENGTH (targs); ++i) - TREE_VEC_ELT (targs, i) - = maybe_fold_nontype_arg (TREE_VEC_ELT (targs, i)); - } - + maybe_fold_nontype_args (targs); return lookup_template_function (tsubst_copy (TREE_OPERAND (t, 0), args, complain, in_decl), targs); } @@ -7916,6 +7929,8 @@ tsubst_copy_and_build (t, args, complain, in_decl) tree object; tree template = tsubst_copy (TREE_OPERAND (t, 0), args, complain, in_decl); + tree targs + = tsubst_copy (TREE_OPERAND (t, 1), args, complain, in_decl); if (TREE_CODE (template) == COMPONENT_REF) { @@ -7924,10 +7939,8 @@ tsubst_copy_and_build (t, args, complain, in_decl) } else object = NULL_TREE; - - template = lookup_template_function - (template, - tsubst_copy (TREE_OPERAND (t, 1), args, complain, in_decl)); + maybe_fold_nontype_args (targs); + template = lookup_template_function (template, targs); if (object) return build (COMPONENT_REF, TREE_TYPE (template), |