Skip to content
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

[Clang] Fix parsing of invalid type-requirement #98545

Merged
merged 1 commit into from
Jul 12, 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
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ Bug Fixes to C++ Support
- Fixed a CTAD substitution bug involving type aliases that reference outer template parameters. (#GH94614).
- Clang now correctly handles unexpanded packs in the template parameter list of a generic lambda expression
(#GH48937)
- Fix a crash when parsing an invalid type-requirement in a requires expression. (#GH51868)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
7 changes: 7 additions & 0 deletions clang/lib/Sema/SemaTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11698,6 +11698,13 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
// Construct a dependent template specialization type.
assert(DTN && "dependent template has non-dependent name?");
assert(DTN->getQualifier() == SS.getScopeRep());

zyn0217 marked this conversation as resolved.
Show resolved Hide resolved
if (!DTN->isIdentifier()) {
Diag(TemplateIILoc, diag::err_template_id_not_a_type) << Template;
NoteAllFoundTemplates(Template);
return true;
}

QualType T = Context.getDependentTemplateSpecializationType(
ElaboratedTypeKeyword::Typename, DTN->getQualifier(),
DTN->getIdentifier(), TemplateArgs.arguments());
Expand Down
9 changes: 9 additions & 0 deletions clang/test/Parser/cxx-concepts-requires-clause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,12 @@ void F() {
int a = []<int=0> requires requires { [](auto){}; } { return 0; }();

} // namespace GH78524


namespace GH51868 {
template<auto L>
concept C = requires {
typename decltype(L)::template operator()<int>;
// expected-error@-1 {{template name refers to non-type template 'decltype(L)::template operator ()'}}
};
}
Loading