diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 109b6492150728..875eb2bfb94070 100755 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2039,7 +2039,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl( // Look only into the namespace where the friend would be declared to // find a previous declaration. This is the innermost enclosing namespace, // as described in ActOnFriendFunctionDecl. - SemaRef.LookupQualifiedName(Previous, DC); + SemaRef.LookupQualifiedName(Previous, DC->getRedeclContext()); // In C++, the previous declaration we find might be a tag type // (class or enum). In this case, the new declaration will hide the diff --git a/clang/test/SemaCXX/compare-cxx2a.cpp b/clang/test/SemaCXX/compare-cxx2a.cpp index 46e38f787db433..a45955418c446c 100644 --- a/clang/test/SemaCXX/compare-cxx2a.cpp +++ b/clang/test/SemaCXX/compare-cxx2a.cpp @@ -426,3 +426,9 @@ namespace Vector { (void)(v1 <=> v2); // expected-error {{three-way comparison between vectors is not supported}} } } + +namespace PR44992 { + extern "C++" struct s { + friend auto operator<=>(s const &, s const &) = default; + }; +}