From 2282976b05c99c73fff7d23cb1af92b07113f078 Mon Sep 17 00:00:00 2001
From: Simon Martin <simartin@users.sourceforge.net>
Date: Fri, 20 Nov 2009 21:37:23 +0000
Subject: [PATCH] re PR c++/38646 (ICE with invalid specialization of variadic
 template)

gcc/cp/

2009-11-20  Simon Martin  <simartin@users.sourceforge.net>

	PR c++/38646
	* pt.c (process_partial_specialization): Do not turn wrongly located
	parameter pack arguments into error_mark_node.
	Split too long lines into two.

gcc/testsuite/

2009-11-20  Simon Martin  <simartin@users.sourceforge.net>

	PR c++/38646
	* g++.dg/cpp0x/pr38646.C: New test.

From-SVN: r154378
---
 gcc/cp/ChangeLog                     |  7 +++++++
 gcc/cp/pt.c                          |  9 ++++-----
 gcc/testsuite/ChangeLog              |  5 +++++
 gcc/testsuite/g++.dg/cpp0x/pr38646.C | 12 ++++++++++++
 4 files changed, 28 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr38646.C

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a4024ef51552..520262e21fe0 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2009-11-20  Simon Martin  <simartin@users.sourceforge.net>
+
+	PR c++/38646
+	* pt.c (process_partial_specialization): Do not turn wrongly located
+	parameter pack arguments into error_mark_node.
+	Split too long lines into two.
+
 2009-11-20  Paolo Carlini  <paolo.carlini@oracle.com>
 
 	PR c++/42060
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index c3b0f0e668f3..0a194440ae69 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -3795,12 +3795,11 @@ process_partial_specialization (tree decl)
                   || (!packed_args && i < nargs - 1))
                 {
                   if (TREE_CODE (arg) == EXPR_PACK_EXPANSION)
-                    error ("parameter pack argument %qE must be at the end of the template argument list", arg);
+                    error ("parameter pack argument %qE must be at the "
+			   "end of the template argument list", arg);
                   else
-                    error ("parameter pack argument %qT must be at the end of the template argument list", arg);
-
-		  if (packed_args)
-		    TREE_VEC_ELT (packed_args, j) = error_mark_node;
+                    error ("parameter pack argument %qT must be at the "
+			   "end of the template argument list", arg);
                 }
             }
 
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ecedddc6f9d8..51d1d328067d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-11-20  Simon Martin  <simartin@users.sourceforge.net>
+
+	PR c++/38646
+	* g++.dg/cpp0x/pr38646.C: New test.
+
 2009-11-20  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
 	* gcc.dg/c99-stdint-6.c: Set dg-options for alpha*-dec-osf5*.
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr38646.C b/gcc/testsuite/g++.dg/cpp0x/pr38646.C
new file mode 100644
index 000000000000..3ef74cd48666
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr38646.C
@@ -0,0 +1,12 @@
+/* PR c++/38646 */
+/* { dg-do "compile" } */
+/* { dg-options "-std=c++0x" } */
+
+template<int...> struct A;
+
+template<int... N> struct A<N..., N...> /* { dg-error "must be at the end" } */
+{
+  template<typename> struct B;
+
+  template<typename T> struct B<T*> {};
+};
-- 
GitLab