This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: PR c++/39425: [4.2/4.3/4.4 Regression] gcc loops after reporting template instantiation errors


When we skip the rest of the specialization on error, we may wind up in
a deeper hole.  This patch removes cp_parser_skip_to_end_of_block_or_statement
on error.  Tested on Linux/Intel64.  OK for trunk and 4.3?

Thanks.


H.J.
----
gcc/cp/

2009-03-11  H.J. Lu  <hongjiu.lu@intel.com>

	PR c++/39425
	* parser.c (cp_parser_explicit_specialization): Don't skip the
	rest of the specialization when begin_specialization returns
	false.

gcc/testsuite/

2009-03-11  H.J. Lu  <hongjiu.lu@intel.com>

	PR c++/39425
	* g++.dg/template/pr39425.C: New.

	* g++.dg/template/spec33.C: Updated.

--- gcc/cp/parser.c.pr39425	2009-03-09 07:38:58.000000000 -0700
+++ gcc/cp/parser.c	2009-03-11 12:11:01.000000000 -0700
@@ -10883,7 +10883,6 @@ cp_parser_explicit_specialization (cp_pa
   if (!begin_specialization ())
     {
       end_specialization ();
-      cp_parser_skip_to_end_of_block_or_statement (parser);
       return;
     }
 
--- gcc/testsuite/g++.dg/template/pr39425.C.pr39425	2009-03-11 11:46:24.000000000 -0700
+++ gcc/testsuite/g++.dg/template/pr39425.C	2009-03-11 11:46:01.000000000 -0700
@@ -0,0 +1,18 @@
+// PR c++/39425
+// { dg-do compile }
+
+class a {
+
+  template<unsigned int s>
+    struct _rec {
+      static const char size = _rec< (s >> 1) >::size;
+    };
+
+  template<>	// { dg-error "explicit" }
+  struct _rec <0> {
+    static const char size = 0;
+  };
+
+  static const unsigned int value = _rec < 1 >::size;
+
+}		// { dg-error "unqualified-id" }
--- gcc/testsuite/g++.dg/template/spec33.C.pr39425	2006-09-26 17:22:12.000000000 -0700
+++ gcc/testsuite/g++.dg/template/spec33.C	2009-03-11 12:13:51.000000000 -0700
@@ -3,5 +3,5 @@
 struct A
 {
     template<int> static void foo   () {}
-    template<>    static void foo<0>() {}  // { dg-error "explicit" }
+    template<>    static void foo<0>() {}  // { dg-error "explicit|template" }
 }; 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]