From 8d1ab8a083d5613b24bbfd68bf02cd2a295dab22 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sun, 13 Oct 2013 22:12:28 +0000 Subject: [PATCH] Don't get confused by a virt-specifier after a trailing-return-type - it's not 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 | 15 ++++++++++----- test/Parser/cxx0x-decl.cpp | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index b71cced353..31349ce994 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -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)) { diff --git a/test/Parser/cxx0x-decl.cpp b/test/Parser/cxx0x-decl.cpp index 3d04bfe816..961896d8fc 100644 --- a/test/Parser/cxx0x-decl.cpp +++ b/test/Parser/cxx0x-decl.cpp @@ -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; + }; +} -- 2.40.0