[PATCH] D155705: [clang] Fix specialization of non-templated member classes of class templates
Mariya Podchishchaeva via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 24 05:09:42 PDT 2023
Fznamznon updated this revision to Diff 543478.
Fznamznon added a comment.
Rebase, extend the test a bit
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155705/new/
https://reviews.llvm.org/D155705
Files:
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/SemaTemplate/gh61159.cpp
Index: clang/test/SemaTemplate/gh61159.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaTemplate/gh61159.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
+// expected-no-diagnostics
+
+namespace GH61159 {
+template <typename T> struct X {
+ struct I;
+};
+
+template <> struct X<int>::I {
+ template <int ct> constexpr int f() { return ct; };
+
+ int data = 3;
+};
+
+template <typename T> struct X<T>::I {
+ template <T ct> constexpr T f() { return ct + 1; };
+ T data = 7;
+};
+
+static_assert(X<int>::I{}.f<17>() == 17);
+static_assert(X<int>::I{}.data == 3);
+static_assert(X<short>::I{}.data == 7);
+static_assert(X<short>::I{}.f<18>() == 19);
+
+template <typename T> struct Y {
+ struct I;
+};
+
+template <> struct Y<int> {
+ struct I {
+ template <int ct> constexpr int f() { return ct; };
+ int data = 3;
+ };
+};
+
+static_assert(Y<int>::I{}.f<17>() == 17);
+static_assert(Y<int>::I{}.data == 3);
+
+} // namespace GH61159
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===================================================================
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -258,6 +258,11 @@
/*Final=*/false);
}
+ if (const MemberSpecializationInfo *MSInfo =
+ Rec->getMemberSpecializationInfo())
+ if (MSInfo->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
+ return Response::Done();
+
bool IsFriend = Rec->getFriendObjectKind() ||
(Rec->getDescribedClassTemplate() &&
Rec->getDescribedClassTemplate()->getFriendObjectKind());
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -670,6 +670,8 @@
- Correcly diagnose jumps into statement expressions.
This ensures the behavior of Clang is consistent with GCC.
(`#63682 <https://github.com/llvm/llvm-project/issues/63682>`_)
+- Fix crash on nested templated class with template function call.
+ (`#61159 <https://github.com/llvm/llvm-project/issues/61159>_`)
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155705.543478.patch
Type: text/x-patch
Size: 2294 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230724/653558b3/attachment.bin>
More information about the cfe-commits
mailing list