Patchwork C++ PATCH for core 1609

login
register
mail settings
Submitter Jason Merrill
Date April 22, 2013, 6:50 p.m.
Message ID <5175866A.8040504@redhat.com>
Download mbox | patch
Permalink /patch/238629/
State New
Headers show

Comments

Jason Merrill - April 22, 2013, 6:50 p.m.
This is an odd testcase, but we were only rejecting it by accident.

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

Patch

commit d248b59f755fd2071a27209e034610396c947809
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 16 11:59:34 2013 +0100

    	Core 1609
    	* decl2.c (check_default_args): Check for pack expansion.

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 74e51a8..8d2385d 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -4463,7 +4463,7 @@  check_default_args (tree x)
     {
       if (TREE_PURPOSE (arg))
 	saw_def = true;
-      else if (saw_def)
+      else if (saw_def && !PACK_EXPANSION_P (TREE_VALUE (arg)))
 	{
 	  error ("default argument missing for parameter %P of %q+#D", i, x);
 	  TREE_PURPOSE (arg) = error_mark_node;
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic142.C b/gcc/testsuite/g++.dg/cpp0x/variadic142.C
new file mode 100644
index 0000000..83b2429
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic142.C
@@ -0,0 +1,9 @@ 
+// Core 1609
+// { dg-require-effective-target c++11 }
+
+template<typename... T>
+void f2(int a = 0, T... b, int c = 1);
+
+int main(){
+  f2<>(); // parameter a has the value 0 and parameter c has the value 1
+}