[Clang][Parser] Don't evaluate concept when its definition is invalid (#111179)
Since #103867, the nullness of the concept declaration has been turned to represent a state in which the concept definition is being parsed and used for self-reference checking. However, PR missed a case where such a definition could be invalid, and we shall inhibit making it into evaluation. Fixes https://github.com/llvm/llvm-project/issues/109780
This commit is contained in:
@@ -331,6 +331,8 @@ Parser::ParseConceptDefinition(const ParsedTemplateInfo &TemplateInfo,
|
||||
if (!TryConsumeToken(tok::equal)) {
|
||||
Diag(Tok.getLocation(), diag::err_expected) << tok::equal;
|
||||
SkipUntil(tok::semi);
|
||||
if (D)
|
||||
D->setInvalidDecl();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -338,6 +340,8 @@ Parser::ParseConceptDefinition(const ParsedTemplateInfo &TemplateInfo,
|
||||
Actions.CorrectDelayedTyposInExpr(ParseConstraintExpression());
|
||||
if (ConstraintExprResult.isInvalid()) {
|
||||
SkipUntil(tok::semi);
|
||||
if (D)
|
||||
D->setInvalidDecl();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -1151,3 +1151,17 @@ int test() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace GH109780 {
|
||||
|
||||
template <typename T>
|
||||
concept Concept; // expected-error {{expected '='}}
|
||||
|
||||
bool val = Concept<int>;
|
||||
|
||||
template <typename T>
|
||||
concept C = invalid; // expected-error {{use of undeclared identifier 'invalid'}}
|
||||
|
||||
bool val2 = C<int>;
|
||||
|
||||
} // namespace GH109780
|
||||
|
||||
Reference in New Issue
Block a user