diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index 1218720708fc6..87323b0f6e1a7 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -563,6 +563,10 @@ static bool calculateConstraintSatisfaction( ConstraintSatisfaction &Satisfaction, UnsignedOrNone PackSubstitutionIndex) { + Sema::ContextRAII CurContext( + S, Constraint.getConceptId()->getNamedConcept()->getDeclContext(), + /*NewThisContext=*/false); + llvm::SmallVector SubstitutedOuterMost; std::optional SubstitutedArgs = SubstitutionInTemplateArguments(S, Constraint, Template, MLTAL, diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index fd32d34cb8cce..1ad5b7652c621 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -4756,9 +4756,6 @@ ExprResult Sema::CheckConceptTemplateId( EnterExpressionEvaluationContext EECtx{ *this, ExpressionEvaluationContext::Unevaluated, CSD}; - ContextRAII CurContext(*this, CSD->getDeclContext(), - /*NewThisContext=*/false); - Error = CheckConstraintSatisfaction( NamedConcept, AssociatedConstraint(NamedConcept->getConstraintExpr()), MLTAL,