Skip to content

[clang] require arg list in type specifiers using template kw #94674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion clang/lib/Parse/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2060,9 +2060,19 @@ bool Parser::TryAnnotateTypeOrScopeToken(
return true;
}

bool TemplateKWPresent = false;
if (Tok.is(tok::kw_template)) {
ConsumeToken();
TemplateKWPresent = true;
}

TypeResult Ty;
if (Tok.is(tok::identifier)) {
// FIXME: check whether the next token is '<', first!
if (TemplateKWPresent && NextToken().isNot(tok::less)) {
Diag(Tok.getLocation(),
diag::missing_template_arg_list_after_template_kw);
return true;
}
Ty = Actions.ActOnTypenameType(getCurScope(), TypenameLoc, SS,
*Tok.getIdentifierInfo(),
Tok.getLocation());
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Parser/cxx2a-concepts-requires-expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool r23 = requires { typename identity<T>::temp<T>; };
template<typename T>
bool r24 = requires {
typename identity<T>::template temp<T>;
typename identity<T>::template temp; // expected-error{{expected an identifier or template-id after '::'}}
typename identity<T>::template temp; // expected-error{{template argument list is expected after a name prefixed by the template keyword}}
};

bool r25 = requires { ; };
Expand Down
Loading