Tested on X86-32 linux.

2011-10-21 Ville Voutilainen <ville.voutilai...@gmail.com>

           PR c++/50811
           * parser.c (cp_parser_class_head): Parse virt-specifiers regardless 
of whether an id is present

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index ea0c4dc..dd2357b 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -17576,8 +17576,8 @@ cp_parser_class_head (cp_parser* parser,
     {
       cp_parser_check_for_invalid_template_id (parser, id,
                                                type_start_token->location);
-      virt_specifiers = cp_parser_virt_specifier_seq_opt (parser);
     }
+  virt_specifiers = cp_parser_virt_specifier_seq_opt (parser);
 
   /* If it's not a `:' or a `{' then we can't really be looking at a
      class-head, since a class-head only appears as part of a
diff --git a/gcc/testsuite/g++.dg/cpp0x/override2.C 
b/gcc/testsuite/g++.dg/cpp0x/override2.C
index 7f17504..0d8871d 100644
--- a/gcc/testsuite/g++.dg/cpp0x/override2.C
+++ b/gcc/testsuite/g++.dg/cpp0x/override2.C
@@ -28,6 +28,13 @@ struct B6 final final {}; // { dg-error "duplicate 
virt-specifier" }
 
 struct B7 override {}; // { dg-error "cannot specify 'override' for a class" }
 
+namespace N
+{
+  struct C;
+}
+
+struct N::C final{};
+
 int main()
 {
   D3<B1> d;

Reply via email to