[clang] [Clang][Sema] Fix lookup of dependent operator= named by using-declaration (PR #91503)
Krystian Stasiowski via cfe-commits
cfe-commits at lists.llvm.org
Wed May 8 12:25:40 PDT 2024
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 <sdkrystian at gmail.com>
Date: Wed, 8 May 2024 12:59:24 -0400
Subject: [PATCH 1/2] [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 73b26b8b9695a1a4aa52aff14ed8bbf7509253b7 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski <sdkrystian at gmail.com>
Date: Wed, 8 May 2024 15:25:30 -0400
Subject: [PATCH 2/2] [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 at -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 {
More information about the cfe-commits
mailing list