From: "Doug Gregor" <doug.gregor@gmail.com>
To: "GCC Patches" <gcc-patches@gcc.gnu.org>
Subject: [C++ PATCH] Fix ADL for parameter packs of templates
Date: Sun, 18 Nov 2007 16:54:00 -0000 [thread overview]
Message-ID: <24b520d20711180726w4727488cq443bafdd9b0509bf@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 709 bytes --]
This little patch fixes PR c++/34101, concerning ADL for parameter
packs containing templates (i.e., TEMPLATE_DECLs), by dealing with the
parameter packs at the level of template arguments
(arg_assoc_template_arg) instead of trying to deal with them as types
(in arg_assoc_type).
Tested i686-pc-linux-gnu; okay for mainline?
- Doug
2007-11-18 Douglas Gregor <doug.gregor@gmail.com>
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-11-18 Douglas Gregor <doug.gregor@gmail.com>
PR c++/34101
* g++.dg/cpp0x/variadic-ttp.C: New.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: variadic-ttp.patch --]
[-- Type: text/x-patch; name=variadic-ttp.patch, Size: 1701 bytes --]
Index: cp/name-lookup.c
===================================================================
--- cp/name-lookup.c (revision 130268)
+++ cp/name-lookup.c (working copy)
@@ -4477,6 +4477,17 @@ arg_assoc_template_arg (struct arg_looku
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, tr
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 ();
Index: testsuite/g++.dg/cpp0x/variadic-ttp.C
===================================================================
--- testsuite/g++.dg/cpp0x/variadic-ttp.C (revision 0)
+++ testsuite/g++.dg/cpp0x/variadic-ttp.C (revision 0)
@@ -0,0 +1,12 @@
+// { dg-options -std=c++0x }
+// PR c++/34101
+template<typename> struct A {};
+
+template<template<typename> class...> struct B {};
+
+template<template<typename> class T> void foo(const B<T>&);
+
+void bar()
+{
+ foo(B<A>());
+}
next reply other threads:[~2007-11-18 15:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-18 16:54 Doug Gregor [this message]
2007-12-03 21:38 ` Jason Merrill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=24b520d20711180726w4727488cq443bafdd9b0509bf@mail.gmail.com \
--to=doug.gregor@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).