From ba7963084ebe2ee2302c97a2aa70d919516311a3 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 4 Dec 2007 21:12:41 +0000 Subject: [PATCH] re PR c++/34101 (ICE with argument deduction of variadic template function) 2007-12-04 Douglas Gregor PR c++/34101 * name-lookup.c (arg_assoc_template_arg): Recurse on argument packs. (arg_assoc_type): We don't need to handle TYPE_ARGUMENT_PACK here, since arg_assoc_template_arg will deal with them (better). 2007-12-04 Douglas Gregor PR c++/34101 * g++.dg/cpp0x/variadic-ttp.C: New. From-SVN: r130608 --- gcc/cp/ChangeLog | 8 ++++++++ gcc/cp/name-lookup.c | 20 +++++++++++--------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/variadic-ttp.C | 12 ++++++++++++ 4 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-ttp.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f694c8866ef..0ade8cded77 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2007-12-04 Douglas Gregor + + PR c++/34101 + * name-lookup.c (arg_assoc_template_arg): Recurse on argument + packs. + (arg_assoc_type): We don't need to handle TYPE_ARGUMENT_PACK here, + since arg_assoc_template_arg will deal with them (better). + 2007-12-04 Douglas Gregor PR c++/33509 diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index a7bb710dace..98c866f3a19 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -4477,6 +4477,17 @@ arg_assoc_template_arg (struct arg_lookup *k, tree arg) else return arg_assoc_class (k, ctx); } + /* It's an argument pack; handle it recursively. */ + else if (ARGUMENT_PACK_P (arg)) + { + tree args = ARGUMENT_PACK_ARGS (arg); + int i, len = TREE_VEC_LENGTH (args); + for (i = 0; i < len; ++i) + if (arg_assoc_template_arg (k, TREE_VEC_ELT (args, i))) + return true; + + return false; + } /* It's not a template template argument, but it is a type template argument. */ else if (TYPE_P (arg)) @@ -4612,15 +4623,6 @@ arg_assoc_type (struct arg_lookup *k, tree type) return false; case TYPE_PACK_EXPANSION: return arg_assoc_type (k, PACK_EXPANSION_PATTERN (type)); - case TYPE_ARGUMENT_PACK: - { - tree args = ARGUMENT_PACK_ARGS (type); - int i, len = TREE_VEC_LENGTH (args); - for (i = 0; i < len; i++) - if (arg_assoc_type (k, TREE_VEC_ELT (args, i))) - return true; - } - break; default: gcc_unreachable (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a4fc563cbb6..5407e15f645 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-12-04 Douglas Gregor + + PR c++/34101 + * g++.dg/cpp0x/variadic-ttp.C: New. + 2007-12-04 Manuel Lopez-Ibanez * gcc.dg/parse-decl-after-if.c: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ttp.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ttp.C new file mode 100644 index 00000000000..41f1c1db43d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ttp.C @@ -0,0 +1,12 @@ +// { dg-options -std=c++0x } +// PR c++/34101 +template struct A {}; + +template class...> struct B {}; + +template class T> void foo(const B&); + +void bar() +{ + foo(B()); +} -- 2.30.2