[clang] 810794c - PR44992 Don't crash when a defaulted <=> is in a class declared in a
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 13 19:30:57 PDT 2020
Author: Richard Smith
Date: 2020-03-13T19:30:49-07:00
New Revision: 810794ce882850a11baca35aa4ef107ee8ee7f53
URL: https://github.com/llvm/llvm-project/commit/810794ce882850a11baca35aa4ef107ee8ee7f53
DIFF: https://github.com/llvm/llvm-project/commit/810794ce882850a11baca35aa4ef107ee8ee7f53.diff
LOG: 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.)
Added:
Modified:
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaCXX/compare-cxx2a.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 109b64921507..875eb2bfb940 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 46e38f787db4..a45955418c44 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;
+ };
+}
More information about the cfe-commits
mailing list