Skip to content

Commit 84bc0a9

Browse files
authored
[Clang] Fix parsing of invalid type-requirement (#98545)
A type-requirement cannot be an operator-function-id Fixes #51868
1 parent 2c2148d commit 84bc0a9

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ Bug Fixes to C++ Support
10351035
- Fixed a CTAD substitution bug involving type aliases that reference outer template parameters. (#GH94614).
10361036
- Clang now correctly handles unexpanded packs in the template parameter list of a generic lambda expression
10371037
(#GH48937)
1038+
- Fix a crash when parsing an invalid type-requirement in a requires expression. (#GH51868)
10381039

10391040
Bug Fixes to AST Handling
10401041
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11690,6 +11690,13 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
1169011690
// Construct a dependent template specialization type.
1169111691
assert(DTN && "dependent template has non-dependent name?");
1169211692
assert(DTN->getQualifier() == SS.getScopeRep());
11693+
11694+
if (!DTN->isIdentifier()) {
11695+
Diag(TemplateIILoc, diag::err_template_id_not_a_type) << Template;
11696+
NoteAllFoundTemplates(Template);
11697+
return true;
11698+
}
11699+
1169311700
QualType T = Context.getDependentTemplateSpecializationType(
1169411701
ElaboratedTypeKeyword::Typename, DTN->getQualifier(),
1169511702
DTN->getIdentifier(), TemplateArgs.arguments());

clang/test/Parser/cxx-concepts-requires-clause.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,12 @@ void F() {
195195
int a = []<int=0> requires requires { [](auto){}; } { return 0; }();
196196

197197
} // namespace GH78524
198+
199+
200+
namespace GH51868 {
201+
template<auto L>
202+
concept C = requires {
203+
typename decltype(L)::template operator()<int>;
204+
// expected-error@-1 {{template name refers to non-type template 'decltype(L)::template operator ()'}}
205+
};
206+
}

0 commit comments

Comments
 (0)