Patchwork C++ PATCH for c++/47220 (accepts-invalid with ill-formed variadic argument list)

login
register
mail settings
Submitter Jason Merrill
Date April 16, 2012, 3:14 a.m.
Message ID <4F8B8EA5.3050901@redhat.com>
Download mbox | patch
Permalink /patch/152749/
State New
Headers show

Comments

Jason Merrill - April 16, 2012, 3:14 a.m.
For some reason, coerce_template_parameter_pack wasn't checking for and 
diagnosing error_mark_node like coerce_template_parms does.  Fixed.

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

Patch

commit 601d1dd536710d65054d6a24bbae2bbf7f1e466b
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Apr 15 20:58:07 2012 -0400

    	PR c++/47220
    	* pt.c (coerce_template_parameter_pack): Check for error_mark_node.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 42dc0a7..95d0aba 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -6697,7 +6697,12 @@  coerce_template_parameter_pack (tree parms,
             TREE_VEC_ELT (packed_types, arg_idx - parm_idx);
         }
 
-      if (arg != error_mark_node)
+      if (arg == error_mark_node)
+	{
+	  if (complain & tf_error)
+	    error ("template argument %d is invalid", arg_idx + 1);
+	}
+      else
 	arg = convert_template_argument (actual_parm, 
 					 arg, new_args, complain, parm_idx,
 					 in_decl);
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr39639.C b/gcc/testsuite/g++.dg/cpp0x/pr39639.C
index 4fd8b56..0838a0b 100644
--- a/gcc/testsuite/g++.dg/cpp0x/pr39639.C
+++ b/gcc/testsuite/g++.dg/cpp0x/pr39639.C
@@ -2,6 +2,7 @@ 
 // Origin: PR c++/39639
 // { dg-do compile }
 // { dg-options "-std=c++0x" }
+// { dg-prune-output "template argument 1 is invalid" }
 
 template <class... Types>
 struct S
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic126.C b/gcc/testsuite/g++.dg/cpp0x/variadic126.C
new file mode 100644
index 0000000..513c7e5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic126.C
@@ -0,0 +1,8 @@ 
+// PR c++/47220
+// { dg-do compile { target c++11 } }
+
+template < typename ... > struct A;
+
+struct B : A <			// { dg-error "invalid" }
+{
+};
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr52260.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr52260.C
index 9ab2589..024afc8 100644
--- a/gcc/testsuite/g++.dg/debug/dwarf2/pr52260.C
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr52260.C
@@ -22,7 +22,7 @@  namespace A
 {
   template <typename T>
   struct I : H <T> {};
-  template <typename ...> struct J;
+  template <typename ...> struct J {};
   template <typename> struct K;
   struct L
   {
@@ -36,7 +36,7 @@  namespace A
   template <typename T, typename B2, typename ... B4>
   struct N <T (B4 ...), B2> : L::M <B2> {};
   template <typename T, typename ... B4>
-  struct K <T (B4 ...)> :J <,>, L
+  struct K <T (B4 ...)> :J <>, L
   {
     typedef T O (B4 ...);
     struct P {};