diff mbox

C++ PATCH for c++/49205 (failure to use variadic template constructor as default constructor)

Message ID 4DFF586C.9000701@redhat.com
State New
Headers show

Commit Message

Jason Merrill June 20, 2011, 2:25 p.m. UTC
A variadic template can take no arguments, so it's a default constructor.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit 9f50baae331019464a94de275ae370cfebb30600
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Jun 19 21:55:11 2011 -0400

    	PR c++/49205
    	* call.c (sufficient_parms_p): Allow parameter packs too.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 05bf983..09d73d0 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -534,15 +534,16 @@  null_ptr_cst_p (tree t)
   return false;
 }
 
-/* Returns nonzero if PARMLIST consists of only default parms and/or
-   ellipsis.  */
+/* Returns nonzero if PARMLIST consists of only default parms,
+   ellipsis, and/or undeduced parameter packs.  */
 
 bool
 sufficient_parms_p (const_tree parmlist)
 {
   for (; parmlist && parmlist != void_list_node;
        parmlist = TREE_CHAIN (parmlist))
-    if (!TREE_PURPOSE (parmlist))
+    if (!TREE_PURPOSE (parmlist)
+	&& !PACK_EXPANSION_P (TREE_VALUE (parmlist)))
       return false;
   return true;
 }
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-default.C b/gcc/testsuite/g++.dg/cpp0x/variadic-default.C
new file mode 100644
index 0000000..2625e25
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic-default.C
@@ -0,0 +1,12 @@ 
+// PR c++/49205
+// { dg-options -std=c++0x }
+
+#include <initializer_list>
+
+struct A {
+  template<typename ...T> A(T...);
+  A(std::initializer_list<short>);
+  A(std::initializer_list<long>);
+};
+
+A a{};