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 for c++/40595 (variadics and sfinae)


This bug turned out to be a simple oversight; we weren't handling the expression case when doing a partial instantation of a member template involving variadics.

Tested x86_64-pc-linux-gnu, applied to trunk.
2009-06-30  Jason Merrill  <jason@redhat.com>

	PR c++/40595
	* pt.c (tsubst_pack_expansion): Handle unexpanded packs in an
	EXPR_PACK_EXPANSION.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index e0a413b..b7c309d 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -7630,8 +7630,15 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
      and return a PACK_EXPANSION_*. The caller will need to deal with
      that.  */
   if (unsubstituted_packs)
-    return make_pack_expansion (tsubst (pattern, args, complain, 
-					in_decl));
+    {
+      tree new_pat;
+      if (TREE_CODE (t) == EXPR_PACK_EXPANSION)
+	new_pat = tsubst_expr (pattern, args, complain, in_decl,
+			       /*integral_constant_expression_p=*/false);
+      else
+	new_pat = tsubst (pattern, args, complain, in_decl);
+      return make_pack_expansion (new_pat);
+    }
 
   /* We could not find any argument packs that work.  */
   if (len < 0)
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic94.C b/gcc/testsuite/g++.dg/cpp0x/variadic94.C
new file mode 100644
index 0000000..8420f73
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic94.C
@@ -0,0 +1,33 @@
+// PR c++/40595
+// { dg-options "-std=c++0x" }
+
+template<int N>
+struct S
+{
+    typedef int type;
+};
+
+template<typename T>
+struct Get
+{
+    static T get();
+};
+
+template<typename F>
+struct B
+{
+    template<typename ... Args>
+        typename S<sizeof( Get<F>::get() (Get<Args>::get() ...) )>::type
+        f(Args&& ... a);
+};
+
+struct X
+{
+    bool operator()(int) const;
+};
+
+int main()
+{
+    B<X> b;
+    b.f(1);
+}

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