https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/91503
>From 163c22df80a5e8c753ded0d5cf5e909553477059 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <sdkryst...@gmail.com> Date: Wed, 8 May 2024 12:59:24 -0400 Subject: [PATCH 1/3] [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)) >From c87423c9b99df81439f148f4953662927ff0cfb6 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <sdkryst...@gmail.com> Date: Wed, 8 May 2024 15:25:30 -0400 Subject: [PATCH 2/3] [FOLD] update test --- .../basic.lookup/basic.lookup.qual/class.qual/p2.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp index be07ab0a48b33..2a6bebb27bbeb 100644 --- a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp +++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp @@ -137,17 +137,16 @@ namespace InhCtor { int n = b.T(); // expected-error {{'T' is a protected member of 'InhCtor::A'}} // expected-note@-15 {{declared protected here}} - // FIXME: EDG and GCC reject this too, but it's not clear why it would be - // ill-formed. template<typename T> struct S : T { - struct U : S { // expected-note 6{{candidate}} + // FIXME: S is incomplete here and we should diagnose this! + struct U : S { using S::S; }; using T::T; }; - S<A>::U ua(0); // expected-error {{no match}} - S<B>::U ub(0); // expected-error {{no match}} + S<A>::U ua(0); + S<B>::U ub(0); template<typename T> struct X : T { >From 6cd97fd33659b66e2941c530d38878882433539f Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <sdkryst...@gmail.com> Date: Wed, 8 May 2024 15:29:10 -0400 Subject: [PATCH 3/3] [FOLD] add test --- .../CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp | 12 ++++++++++++ 1 file changed, 12 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 43053c18c5076..d5824d251c2a5 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 @@ -484,6 +484,18 @@ namespace N3 { template struct E<int>; // expected-note {{in instantiation of template class 'N3::E<int>' requested here}} + template<typename T> + struct F { + F& operator=(T); + struct G; + }; + + template<typename T> + struct F<T>::G : F<T> { + using F::operator=; + }; + + template struct F<int>; } // namespace N3 namespace N4 { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits