From c528571847d2d2c4b6478dac883951b540b18a9c Mon Sep 17 00:00:00 2001
From: Paolo Carlini <paolo.carlini@oracle.com>
Date: Sun, 8 Jun 2008 21:25:49 +0000
Subject: [PATCH] re PR c++/35242 (ICE with invalid specialization of variadic
 template)

/cp
2008-06-08  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/35242
        * pt.c (maybe_process_partial_specialization): Check the tree
	returned by push_template_decl for error_mark_node.
	* parser.c (cp_parser_class_head): Likewise, check the tree
	returned by the latter.

/testsuite
2008-06-08  Paolo Carlini  <paolo.carlini@oracle.com>

        PR c++/35242
        * g++.dg/cpp0x/vt-35242.C: New.

From-SVN: r136569
---
 gcc/cp/ChangeLog                      | 8 ++++++++
 gcc/cp/parser.c                       | 8 +++++++-
 gcc/cp/pt.c                           | 6 +++++-
 gcc/testsuite/ChangeLog               | 5 +++++
 gcc/testsuite/g++.dg/cpp0x/vt-35242.C | 7 +++++++
 5 files changed, 32 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/vt-35242.C

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index fb79f4770c51..74ae4ae4d98d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2008-06-08  Paolo Carlini  <paolo.carlini@oracle.com>
+
+        PR c++/35242
+        * pt.c (maybe_process_partial_specialization): Check the tree
+	returned by push_template_decl for error_mark_node.
+	* parser.c (cp_parser_class_head): Likewise, check the tree
+	returned by the latter. 
+
 2008-06-07  Paolo Carlini  <paolo.carlini@oracle.com>
 
         PR c++/35327
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 5ca1bd7e5334..12d1a2d8ad98 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -14832,7 +14832,13 @@ cp_parser_class_head (cp_parser* parser,
 	    }
 	}
 
-      maybe_process_partial_specialization (TREE_TYPE (type));
+      if (maybe_process_partial_specialization (TREE_TYPE (type))
+	  == error_mark_node)
+	{
+	  type = NULL_TREE;
+	  goto done;
+	}
+
       class_type = current_class_type;
       /* Enter the scope indicated by the nested-name-specifier.  */
       pushed_scope = push_scope (nested_name_specifier);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index f141b74a6fd4..eb4a7b7ed34b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -772,7 +772,11 @@ maybe_process_partial_specialization (tree type)
 	  check_specialization_namespace (CLASSTYPE_TI_TEMPLATE (type));
 	  SET_CLASSTYPE_TEMPLATE_SPECIALIZATION (type);
 	  if (processing_template_decl)
-	    push_template_decl (TYPE_MAIN_DECL (type));
+	    {
+	      if (push_template_decl (TYPE_MAIN_DECL (type))
+		  == error_mark_node)
+		return error_mark_node;
+	    }
 	}
       else if (CLASSTYPE_TEMPLATE_INSTANTIATION (type))
 	error ("specialization of %qT after instantiation", type);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 84ee84ca0a93..ee3af09b7142 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-06-08  Paolo Carlini  <paolo.carlini@oracle.com>
+
+        PR c++/35242
+        * g++.dg/cpp0x/vt-35242.C: New.
+
 2008-06-08  Janus Weil  <janus@gcc.gnu.org>
 
 	PR fortran/36459
diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-35242.C b/gcc/testsuite/g++.dg/cpp0x/vt-35242.C
new file mode 100644
index 000000000000..9cc859b875e4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/vt-35242.C
@@ -0,0 +1,7 @@
+// { dg-options "-std=c++0x" }
+struct A
+{
+  template<typename... T> struct B;
+};
+
+template<typename... T> struct A::B<T*> {}; // { dg-error "parameter packs|T" }
-- 
GitLab