diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -1325,7 +1325,7 @@ } else { // We found something in this scope, we should not look at the // namespace scope - SearchNamespaceScope = false; + SearchNamespaceScope = Name.getCXXOverloadedOperator() == OO_Equal; } R.addDecl(ND); } diff --git a/clang/test/SemaCXX/nested-class-assignment-operator-overload.cpp b/clang/test/SemaCXX/nested-class-assignment-operator-overload.cpp new file mode 100644 --- /dev/null +++ b/clang/test/SemaCXX/nested-class-assignment-operator-overload.cpp @@ -0,0 +1,18 @@ +/// clang++ incorrectly rejected this program with the following error: +/// "No matching member function for call to 'operator='" +/// +/// Refer to github issue 59684 + +// RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics + +struct Outer { + void invokeAssign() { operator=({}); } + + struct Inner { + Inner &operator=(int); + void invokeAssign(int D) { operator=(D); } + }; +}; + +int main() {}