From beec840822867079b829f35cbd4b360aa8971438 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 18 Jul 2025 15:23:32 +0800 Subject: [Clang] Ensure correct parameters are in the scope for constraint equivalence checking (#149264) This is another case where untransformed constraint expressions led to inconsistent transforms. We did fix some of those issues by looking at parent scopes, however the parent instantiation scope is not always available because we could also reach here after the parents get instantiated. Fixes #146614 --- clang/lib/Sema/SemaConcept.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'clang/lib/Sema/SemaConcept.cpp') diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index 834417f..5205ca0b 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -925,7 +925,12 @@ static const Expr *SubstituteConstraintExpressionWithoutSatisfaction( ND && ND->isFunctionOrFunctionTemplate()) { ScopeForParameters.emplace(S, /*CombineWithOuterScope=*/true); const FunctionDecl *FD = ND->getAsFunction(); + if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate(); + Template && Template->getInstantiatedFromMemberTemplate()) + FD = Template->getInstantiatedFromMemberTemplate()->getTemplatedDecl(); for (auto *PVD : FD->parameters()) { + if (ScopeForParameters->getInstantiationOfIfExists(PVD)) + continue; if (!PVD->isParameterPack()) { ScopeForParameters->InstantiatedLocal(PVD, PVD); continue; -- cgit v1.1