]> granicus.if.org Git - clang/commitdiff
Don't get confused by a virt-specifier after a trailing-return-type - it's not
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 13 Oct 2013 22:12:28 +0000 (22:12 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 13 Oct 2013 22:12:28 +0000 (22:12 +0000)
an accidentally-included name for the declarator.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192559 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
test/Parser/cxx0x-decl.cpp

index b71cced3536b30e43b704e3aaf4cb91cd4e297c7..31349ce9946105639537892f3a113a53596e0da9 100644 (file)
@@ -4740,11 +4740,16 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
     ConsumeToken();
     goto PastIdentifier;
   } else if (Tok.is(tok::identifier) && D.diagnoseIdentifier()) {
-    Diag(Tok.getLocation(), diag::err_unexpected_unqualified_id)
-      << FixItHint::CreateRemoval(Tok.getLocation());
-    D.SetIdentifier(0, Tok.getLocation());
-    ConsumeToken();
-    goto PastIdentifier;
+    // A virt-specifier isn't treated as an identifier if it appears after a
+    // trailing-return-type.
+    if (D.getContext() != Declarator::TrailingReturnContext ||
+        !isCXX11VirtSpecifier(Tok)) {
+      Diag(Tok.getLocation(), diag::err_unexpected_unqualified_id)
+        << FixItHint::CreateRemoval(Tok.getLocation());
+      D.SetIdentifier(0, Tok.getLocation());
+      ConsumeToken();
+      goto PastIdentifier;
+    }
   }
 
   if (Tok.is(tok::l_paren)) {
index 3d04bfe81608c4360734ab7797bba888a219791b..961896d8fc8a0ec36877abce8338a0b76a1cbdc4 100644 (file)
@@ -80,3 +80,18 @@ namespace PR5066 {
   auto f() -> int (*f)(); // expected-error {{type-id cannot have a name}}
   auto g = []() -> int (*f)() {}; // expected-error {{type-id cannot have a name}}
 }
+
+namespace FinalOverride {
+  struct Base {
+    virtual void *f();
+    virtual void *g();
+    virtual void *h();
+    virtual void *i();
+  };
+  struct Derived : Base {
+    virtual auto f() -> void *final;
+    virtual auto g() -> void *override;
+    virtual auto h() -> void *final override;
+    virtual auto i() -> void *override final;
+  };
+}