https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/91503
>From fd4172e64384379a7c976c4ce597eac629bc111f Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <sdkryst...@gmail.com> Date: Wed, 8 May 2024 12:59:24 -0400 Subject: [PATCH] [Clang][Sema] Fix lookup of dependent operator= named by using-declaration --- clang/lib/Sema/SemaDeclCXX.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 157d42c09cfcd..91c83564b567e 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -12963,14 +12963,15 @@ NamedDecl *Sema::BuildUsingDeclaration( return nullptr; } - DeclContext *LookupContext = computeDeclContext(SS); NestedNameSpecifierLoc QualifierLoc = SS.getWithLocInContext(Context); - if (!LookupContext || EllipsisLoc.isValid()) { - NamedDecl *D; + DeclContext *LookupContext = computeDeclContext(SS); + + auto BuildDependent = [&] { + NamedDecl *D = nullptr; // Dependent scope, or an unexpanded pack if (!LookupContext && CheckUsingDeclQualifier(UsingLoc, HasTypenameKeyword, SS, NameInfo, IdentLoc)) - return nullptr; + return D; if (HasTypenameKeyword) { // FIXME: not all declaration name kinds are legal here @@ -12987,7 +12988,7 @@ NamedDecl *Sema::BuildUsingDeclaration( CurContext->addDecl(D); ProcessDeclAttributeList(S, D, AttrList); return D; - } + }; auto Build = [&](bool Invalid) { UsingDecl *UD = @@ -13002,6 +13003,9 @@ NamedDecl *Sema::BuildUsingDeclaration( auto BuildInvalid = [&]{ return Build(true); }; auto BuildValid = [&]{ return Build(false); }; + if (!LookupContext || EllipsisLoc.isValid()) + return BuildDependent(); + if (RequireCompleteDeclContext(SS, LookupContext)) return BuildInvalid(); @@ -13024,6 +13028,9 @@ NamedDecl *Sema::BuildUsingDeclaration( LookupQualifiedName(R, LookupContext); + if (R.wasNotFoundInCurrentInstantiation()) + return BuildDependent(); + // Validate the context, now we have a lookup if (CheckUsingDeclQualifier(UsingLoc, HasTypenameKeyword, SS, NameInfo, IdentLoc, &R)) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits