parser.c (cp_parser_direct_declarator): Move virt-specifier parsing after late-specif...
authorVille Voutilainen <ville.voutilainen@gmail.com>
Wed, 20 Jun 2012 01:18:08 +0000 (04:18 +0300)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 20 Jun 2012 01:18:08 +0000 (21:18 -0400)
* parser.c (cp_parser_direct_declarator): Move virt-specifier
parsing after late-specified return type parsing.

From-SVN: r188808

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

index 562f945be4350edf04650da389708b329c896050..794b39f7a649bec8bf211642e6ce46dd60ccf953 100644 (file)
@@ -1,3 +1,8 @@
+2012-06-16 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+       * parser.c (cp_parser_direct_declarator): Move virt-specifier
+       parsing after late-specified return type parsing.
+
 2012-06-14  Jason Merrill  <jason@redhat.com>
 
        PR c++/53651
index 1691f81e4298caea5ee9c092a1accabe3c382c0b..6bc6877c325a970f9ad872707fc1fd60770a1881 100644 (file)
@@ -16102,12 +16102,13 @@ cp_parser_direct_declarator (cp_parser* parser,
                  /* And the exception-specification.  */
                  exception_specification
                    = cp_parser_exception_specification_opt (parser);
-                 /* Parse the virt-specifier-seq.  */
-                 virt_specifiers = cp_parser_virt_specifier_seq_opt (parser);
 
                  late_return = (cp_parser_late_return_type_opt
                                 (parser, member_p ? cv_quals : -1));
 
+                 /* Parse the virt-specifier-seq.  */
+                 virt_specifiers = cp_parser_virt_specifier_seq_opt (parser);
+
                  /* Create the function-declarator.  */
                  declarator = make_call_declarator (declarator,
                                                     params,
index 07071a933c4e5eceb0f1038ed6349bd4f8c3ceb0..621ee9643ed1d021090bd9d2d44572a8aa5410d6 100644 (file)
@@ -1,3 +1,7 @@
+2012-06-16 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+        * g++.dg/cpp0x/override4.C: New.
+
 2012-06-14  Jason Merrill  <jason@redhat.com>
 
        PR c++/53651
diff --git a/gcc/testsuite/g++.dg/cpp0x/override4.C b/gcc/testsuite/g++.dg/cpp0x/override4.C
new file mode 100644 (file)
index 0000000..aec5c2c
--- /dev/null
@@ -0,0 +1,45 @@
+// { dg-options "-std=c++11" }
+// { dg-prune-output "expected ';'" }
+// { dg-prune-output "expected unqualified-id" }
+// { dg-prune-output "declaration does not declare anything" }
+
+struct B
+{
+  virtual auto f() -> void final;
+  virtual auto g() -> void;
+};
+
+struct B2
+{
+  virtual auto f() -> void final {}
+};
+
+struct B3
+{
+  virtual auto f() -> final void; // { dg-error "expected type-specifier" }
+};
+
+struct B4
+{
+  virtual auto f() -> final void {} // { dg-error "expected type-specifier" }
+};
+
+struct D : B
+{
+  virtual auto g() -> void override;
+};
+
+struct D2 : B
+{
+  virtual auto g() -> void override {}
+};
+
+struct D3 : B
+{
+  virtual auto g() -> override void; // { dg-error "expected type-specifier" }
+};
+
+struct D4 : B
+{
+  virtual auto g() -> override void {} // { dg-error "expected type-specifier" }
+};