Fix PR c++/77639 (ICE during error recovery)
authorPatrick Palka <ppalka@gcc.gnu.org>
Mon, 19 Sep 2016 18:12:36 +0000 (18:12 +0000)
committerPatrick Palka <ppalka@gcc.gnu.org>
Mon, 19 Sep 2016 18:12:36 +0000 (18:12 +0000)
gcc/cp/ChangeLog:

PR c++/77639
* parser.c (cp_parser_class_head): When
processing_template_parmlist, don't assume that the
class-head may start an explicit specialization.

gcc/testsuite/ChangeLog:

PR c++/77639
* g++.dg/template/error-recovery4.C: New test.

From-SVN: r240245

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/error-recovery4.C [new file with mode: 0644]

index 9d74bdbb8ba7fd41ee684fa8fd808c83a948f000..e4bd392e953679f1504787705d9c7987da5f2875 100644 (file)
@@ -1,3 +1,10 @@
+2016-09-16  Patrick Palka  <ppalka@gcc.gnu.org>
+
+       PR c++/77639
+       * parser.c (cp_parser_class_head): When
+       processing_template_parmlist, don't assume that the
+       class-head may start an explicit specialization.
+
 2016-09-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/77482
index fb88021e23763eb428fe9cc8f7694e2f79e22966..c03b9c2e5e3d4ea91f98280fb98db0cd82b256c3 100644 (file)
@@ -22025,6 +22025,7 @@ cp_parser_class_head (cp_parser* parser,
      it is not, try to recover gracefully.  */
   if (at_namespace_scope_p ()
       && parser->num_template_parameter_lists == 0
+      && !processing_template_parmlist
       && template_id_p)
     {
       /* Build a location of this form:
index 68d3973dcde4aab8427a450285a6f2af3a8243ae..f7d004807432e11e8cebea18649a8d5dd18bcb39 100644 (file)
@@ -1,3 +1,8 @@
+2016-09-19  Patrick Palka  <ppalka@gcc.gnu.org>
+
+       PR c++/77639
+       * g++.dg/template/error-recovery4.C: New test.
+
 2016-09-19  Bin Cheng  <bin.cheng@arm.com>
 
        * gcc.dg/vect/pr57558-1.c: Use unsigned int instead of unsigned long.
diff --git a/gcc/testsuite/g++.dg/template/error-recovery4.C b/gcc/testsuite/g++.dg/template/error-recovery4.C
new file mode 100644 (file)
index 0000000..1e52c6a
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/77639
+
+template <class, int, class, int> struct B {};
+template <class T, int a, class U struct B<T, a, U, 1> {}; // { dg-error "" }
+B<int, 2, char, 1> i;