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

an accidentally-included name for the declarator.

llvm-svn: 192559
This commit is contained in:
Richard Smith 2013-10-13 22:12:28 +00:00
parent 5357df6290
commit f39720b26e
2 changed files with 25 additions and 5 deletions

View 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)) {

View 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;
};
}