From: Richard Smith Date: Sat, 14 Mar 2020 02:29:44 +0000 (-0700) Subject: PR44992 Don't crash when a defaulted <=> is in a class declared in a X-Git-Tag: llvmorg-12-init~12095 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=810794ce882850a11baca35aa4ef107ee8ee7f53;p=platform%2Fupstream%2Fllvm.git PR44992 Don't crash when a defaulted <=> is in a class declared in a transparent context. (The same crash would happen if a class template with a friend was declared in an 'export' block, but there are more issues with that case.) --- diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 109b649..875eb2b 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 46e38f7..a459554 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; + }; +}