Patchwork [C++] PR 50811 (rejects class-virt-specifier if class-head-name includes nested-name-specifier)

login
register
mail settings
Submitter ville
Date Oct. 21, 2011, 12:38 a.m.
Message ID <878vof89gd.wl%ville@ville-laptop>
Download mbox | patch
Permalink /patch/120917/
State New
Headers show

Comments

ville - Oct. 21, 2011, 12:38 a.m.
Tested on X86-32 linux.

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

           PR c++/50811
           * parser.c (cp_parser_class_head): Parse virt-specifiers regardless of whether an id is present
Jason Merrill - Oct. 21, 2011, 1:31 p.m.
Applied, thanks.

Jason

Patch

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;