public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] Fix ADL for parameter packs of templates
@ 2007-11-18 16:54 Doug Gregor
  2007-12-03 21:38 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Doug Gregor @ 2007-11-18 16:54 UTC (permalink / raw)
  To: GCC Patches

[-- 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>());
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [C++ PATCH] Fix ADL for parameter packs of templates
  2007-11-18 16:54 [C++ PATCH] Fix ADL for parameter packs of templates Doug Gregor
@ 2007-12-03 21:38 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2007-12-03 21:38 UTC (permalink / raw)
  To: Doug Gregor; +Cc: GCC Patches

OK.

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-12-03 21:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-18 16:54 [C++ PATCH] Fix ADL for parameter packs of templates Doug Gregor
2007-12-03 21:38 ` Jason Merrill

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).