re PR c++/22153 (ICE on invalid template specialization)
authorJosh Conner <jconner@apple.com>
Fri, 28 Oct 2005 17:58:59 +0000 (17:58 +0000)
committerJosh Conner <jconner@gcc.gnu.org>
Fri, 28 Oct 2005 17:58:59 +0000 (17:58 +0000)
PR c++/22153
* cp/parser.c (cp_parser_member_declaration): Detect and handle
a template specialization.
* testsuite/g++.dg/template/crash38.C: New test.
* testsuite/g++.dg/parse/explicit1.C: Change expected errors.

From-SVN: r105944

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/crash38.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/explicit1.C

index d2ec158c9058c03b5876f4b54ef8f65036b1a5e1..fed864d7f08ef2528671a762a255341d28cd0567 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-28  Josh Conner  <jconner@apple.com>
+
+       PR c++/22153
+       * parser.c (cp_parser_member_declaration): Detect and handle
+       a template specialization.
+
 2005-10-28  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR C++/23426
index 25f25ce69ec67ebe5f49d4f7e200ba7a0fe02a28..a065c2569acb0eec045a50e6b8bc59455ddad9da 100644 (file)
@@ -13240,8 +13240,13 @@ cp_parser_member_declaration (cp_parser* parser)
   /* Check for a template-declaration.  */
   if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TEMPLATE))
     {
-      /* Parse the template-declaration.  */
-      cp_parser_template_declaration (parser, /*member_p=*/true);
+      /* An explicit specialization here is an error condition, and we
+        expect the specialization handler to detect and report this.  */
+      if (cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_LESS
+         && cp_lexer_peek_nth_token (parser->lexer, 3)->type == CPP_GREATER)
+       cp_parser_explicit_specialization (parser);
+      else
+       cp_parser_template_declaration (parser, /*member_p=*/true);
 
       return;
     }
index bd5ff267abcdfc1e1d73817591d9dbf04f207471..85a10d8381963e19b2def80fb915b4f4e5d22791 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-28  Josh Conner  <jconner@apple.com>
+
+       PR c++/22153
+       * g++.dg/template/crash38.C: New test.
+       * g++.dg/parse/explicit1.C: Change expected errors.
+
 2005-10-28  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR C++/23426
diff --git a/gcc/testsuite/g++.dg/crash38.C b/gcc/testsuite/g++.dg/crash38.C
new file mode 100644 (file)
index 0000000..d36ced4
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-do compile }
+
+// PR c++/22153
+
+template<int> void foo();
+
+template<int> struct A
+{
+    template<> friend void foo<0>(); // { dg-error "" }
+};
index ced2adc3dc091006a786e87ee014d4269d9d99b7..35358749e1d082e9e85d913627497ecaf9ac20fe 100644 (file)
@@ -7,5 +7,5 @@
 
 struct foo { 
         template<typename T> void bar (T &t) {}
-        template<> void bar<double>(double &t) {} // { dg-error "explicit|non-namespace|member" }
+        template<> void bar<double>(double &t) {} // { dg-error "non-namespace|template|function" }
 };