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)) {
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;
+ };
+}