Skip to content

Commit 3affbce

Browse files
authored
[Clang] Fix a crash on invalid concept (#150186)
Fixes #149986
1 parent f992ae4 commit 3affbce

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clang/lib/Sema/SemaConcept.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,9 @@ static bool CheckConstraintSatisfaction(
588588
return true;
589589

590590
for (const AssociatedConstraint &AC : AssociatedConstraints) {
591+
if (AC.isNull())
592+
return true;
593+
591594
Sema::ArgPackSubstIndexRAII _(S, AC.ArgPackSubstIndex);
592595
ExprResult Res = calculateConstraintSatisfaction(
593596
S, Template, TemplateIDRange.getBegin(), TemplateArgsLists,

clang/test/SemaTemplate/concepts.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,3 +1250,11 @@ static_assert(!D<Priv>::has, "Private should be invisible.");
12501250
static_assert(!D<Prot>::has, "Protected should be invisible.");
12511251

12521252
}
1253+
1254+
1255+
namespace GH149986 {
1256+
template <typename T> concept PerfectSquare = [](){} // expected-note 2{{here}}
1257+
([](auto) { return true; }) < PerfectSquare <class T>;
1258+
// expected-error@-1 {{declaration of 'T' shadows template parameter}} \
1259+
// expected-error@-1 {{a concept definition cannot refer to itself}}
1260+
}

0 commit comments

Comments
 (0)