This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ PATCH] Fix ADL for parameter packs of templates


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]