https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/90999
>From 0e013635fe6cf665cf8a928e0df2b0c451e60b89 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <sdkryst...@gmail.com> Date: Fri, 3 May 2024 15:27:02 -0400 Subject: [PATCH 1/2] [Clang][Sema] Fix template name lookup for operator= --- clang/lib/Sema/SemaLookup.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 2f6ad49fc08b61..e63da5875d2c91 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -1300,7 +1300,8 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) { for (Scope *PreS = S; PreS; PreS = PreS->getParent()) if (DeclContext *DC = PreS->getEntity()) { if (DC->isDependentContext() && isa<CXXRecordDecl>(DC) && - Name.getCXXOverloadedOperator() == OO_Equal) { + Name.getCXXOverloadedOperator() == OO_Equal && + !R.isTemplateNameLookup()) { R.setNotFoundInCurrentInstantiation(); return false; } @@ -2471,10 +2472,8 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, } } QL(LookupCtx); + bool TemplateNameLookup = R.isTemplateNameLookup(); CXXRecordDecl *LookupRec = dyn_cast<CXXRecordDecl>(LookupCtx); - // FIXME: Per [temp.dep.general]p2, an unqualified name is also dependent - // if it's a dependent conversion-function-id or operator= where the current - // class is a templated entity. This should be handled in LookupName. if (!InUnqualifiedLookup && !R.isForRedeclaration()) { // C++23 [temp.dep.type]p5: // A qualified name is dependent if @@ -2488,7 +2487,7 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, (Name.getNameKind() == DeclarationName::CXXConversionFunctionName && Name.getCXXNameType()->isDependentType()) || (Name.getCXXOverloadedOperator() == OO_Equal && LookupRec && - LookupRec->isDependentContext())) { + LookupRec->isDependentContext() && !TemplateNameLookup)) { R.setNotFoundInCurrentInstantiation(); return false; } @@ -2584,8 +2583,6 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, return true; }; - bool TemplateNameLookup = R.isTemplateNameLookup(); - // Determine whether two sets of members contain the same members, as // required by C++ [class.member.lookup]p6. auto HasSameDeclarations = [&](DeclContext::lookup_iterator A, >From 7524943fd45bafd36608db279b742cfbc4167a87 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <sdkryst...@gmail.com> Date: Fri, 3 May 2024 15:42:14 -0400 Subject: [PATCH 2/2] [FOLD] add tests --- .../temp.res/temp.dep/temp.dep.type/p4.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp b/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp index 0f24d716a7b749..46dd52f8c4c133 100644 --- a/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp +++ b/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp @@ -453,6 +453,24 @@ namespace N3 { this->A::operator=(*this); } }; + + template<typename T> + struct C { + template<typename U> + void operator=(int); + + void not_instantiated() { + operator=<int>(0); + C::operator=<int>(0); + this->operator=<int>(0); + this->C::operator=<int>(0); + + operator=(*this); + C::operator=(*this); + this->operator=(*this); + this->C::operator=(*this); + } + }; } // namespace N3 namespace N4 { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits