Skip to content

Commit 34a1daa

Browse files
authored
[Clang] Mark a concept as being invalid if the constraint is invalid (#147938)
Make sure to mark a concept decl as being invalid if the constraint is invalid. Fixes #138823
1 parent eba5130 commit 34a1daa

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8968,8 +8968,10 @@ Sema::ActOnFinishConceptDefinition(Scope *S, ConceptDecl *C,
89688968
Expr *ConstraintExpr,
89698969
const ParsedAttributesView &Attrs) {
89708970
assert(!C->hasDefinition() && "Concept already defined");
8971-
if (DiagnoseUnexpandedParameterPack(ConstraintExpr))
8971+
if (DiagnoseUnexpandedParameterPack(ConstraintExpr)) {
8972+
C->setInvalidDecl();
89728973
return nullptr;
8974+
}
89738975
C->setDefinition(ConstraintExpr);
89748976
ProcessDeclAttributeList(S, C, Attrs);
89758977

clang/test/SemaCXX/concept-crash-on-diagnostic.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,17 @@ concept atomicish = requires() {
6060
};
6161
atomicish<int> f(); // expected-error {{expected 'auto' or 'decltype(auto)' after concept name}}
6262
} // namespace GH138820
63+
64+
namespace GH138823 {
65+
template <typename T> void foo();
66+
template <class... Ts>
67+
concept ConceptA = requires { foo<Ts>(); };
68+
// expected-error@-1 {{expression contains unexpanded parameter pack 'Ts'}}
69+
70+
template <class>
71+
concept ConceptB = ConceptA<int>;
72+
73+
template <ConceptB Foo> void bar(Foo);
74+
75+
void test() { bar(1); }
76+
}

0 commit comments

Comments
 (0)