Skip to content

Commit 8beb2ee

Browse files
committed
[clang] Fixes #138823
Make sure to mark a concept decl as being invalid if the constraint is invalid.
1 parent 20becf3 commit 8beb2ee

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
2+
3+
template <typename T> void foo();
4+
template <class... Ts>
5+
concept ConceptA = requires { foo<Ts>(); };
6+
// expected-error@-1 {{expression contains unexpanded parameter pack 'Ts'}}
7+
8+
template <class>
9+
concept ConceptB = ConceptA<int>;
10+
11+
template <ConceptB Foo> void bar(Foo);
12+
13+
void test() { bar(1); }

0 commit comments

Comments
 (0)