[PATCH] D148330: [clang] Do not crash on undefined template partial specialization
Mariya Podchishchaeva via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 14 07:08:19 PDT 2023
Fznamznon updated this revision to Diff 513575.
Fznamznon added a comment.
Rebase, fix error message
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148330/new/
https://reviews.llvm.org/D148330
Files:
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaCXXScopeSpec.cpp
clang/test/SemaCXX/undefined-partial-specialization.cpp
Index: clang/test/SemaCXX/undefined-partial-specialization.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/undefined-partial-specialization.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+namespace GH61356 {
+
+template <typename T, bool b>
+class boo {void foo();};
+
+template <typename T>
+class boo<T, true>;
+
+template<typename T>
+void boo<T, true>::foo(){} // expected-error{{out-of-line definition of 'foo' from class 'boo<type-parameter-0-0, true>' without definition}}
+
+}
Index: clang/lib/Sema/SemaCXXScopeSpec.cpp
===================================================================
--- clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -131,7 +131,8 @@
// entering the context, and that can't happen in a SFINAE context.
assert(!isSFINAEContext() && "partial specialization scope "
"specifier in SFINAE context?");
- if (!hasReachableDefinition(PartialSpec))
+ if (PartialSpec->hasDefinition() &&
+ !hasReachableDefinition(PartialSpec))
diagnoseMissingImport(SS.getLastQualifierNameLoc(), PartialSpec,
MissingImportKind::PartialSpecialization,
true);
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -303,6 +303,8 @@
- Fix a failed assertion due to an invalid source location when trying to form
a coverage report for an unresolved constructor expression.
(`#62105 <https://github.com/llvm/llvm-project/issues/62105>`_)
+- Fix crash when handling undefined template partial specialization
+ (`#61356 <https://github.com/llvm/llvm-project/issues/61356>`_)
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148330.513575.patch
Type: text/x-patch
Size: 1966 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230414/d8fe7740/attachment.bin>
More information about the cfe-commits
mailing list