r192559 - Don't get confused by a virt-specifier after a trailing-return-type - it's not

Richard Smith richard-llvm at metafoo.co.uk
Sun Oct 13 15:12:28 PDT 2013


Author: rsmith
Date: Sun Oct 13 17:12:28 2013
New Revision: 192559

URL: http://llvm.org/viewvc/llvm-project?rev=192559&view=rev
Log:
Don't get confused by a virt-specifier after a trailing-return-type - it's not
an accidentally-included name for the declarator.

Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/test/Parser/cxx0x-decl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=192559&r1=192558&r2=192559&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sun Oct 13 17:12:28 2013
@@ -4740,11 +4740,16 @@ void Parser::ParseDirectDeclarator(Decla
     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)) {

Modified: cfe/trunk/test/Parser/cxx0x-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-decl.cpp?rev=192559&r1=192558&r2=192559&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx0x-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-decl.cpp Sun Oct 13 17:12:28 2013
@@ -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;
+  };
+}





More information about the cfe-commits mailing list