->getTypeConstraint();
}
+// Search through the requirements, and see if any have a RecoveryExpr in it,
+// which means this RequiresExpr ALSO needs to be invalid.
+static bool RequirementContainsError(concepts::Requirement *R) {
+ if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(R))
+ return ExprReq->getExpr() && ExprReq->getExpr()->containsErrors();
+
+ if (auto *NestedReq = dyn_cast<concepts::NestedRequirement>(R))
+ return !NestedReq->hasInvalidConstraint() &&
+ NestedReq->getConstraintExpr() &&
+ NestedReq->getConstraintExpr()->containsErrors();
+ return false;
+}
+
RequiresExpr::RequiresExpr(ASTContext &C, SourceLocation RequiresKWLoc,
RequiresExprBodyDecl *Body,
ArrayRef<ParmVarDecl *> LocalParameters,
if (!RequiresExprBits.IsSatisfied)
break;
}
+
+ if (RequirementContainsError(R))
+ setDependence(getDependence() | ExprDependence::Error);
}
std::copy(LocalParameters.begin(), LocalParameters.end(),
getTrailingObjects<ParmVarDecl *>());
// expected-error@-1{{constraints not satisfied for class template 'VariadicStruct'}}
// expected-note@#VSREQ{{because 'Variadic<void, int, char, double>' evaluated to false}}
// expected-note@#VC{{because 'b' would be invalid: argument may not have 'void' type}}
+
+ template<typename T>
+ // expected-error@+1 {{unknown type name 'ErrorRequires'}}
+ concept ErrorRequires = requires (ErrorRequires auto x) {
+ x;
+ };
+ static_assert(ErrorRequires<int>);
+ // expected-error@-1{{static assertion failed}}
+ // expected-note@-2{{because substituted constraint expression is ill-formed: constraint depends on a previously diagnosed expression}}
+
+ template<typename T>
+ // expected-error@+2 {{unknown type name 'NestedErrorInRequires'}}
+ concept NestedErrorInRequires = requires (T x) {
+ requires requires (NestedErrorInRequires auto y) {
+ y;
+ };
+ };
+ static_assert(NestedErrorInRequires<int>);
+ // expected-error@-1{{static assertion failed}}
+ // expected-note@-2{{because substituted constraint expression is ill-formed: constraint depends on a previously diagnosed expression}}
+
}