[PATCH] D148330: [clang] Do not crash on undefined template partial specialization

Mariya Podchishchaeva via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 27 02:42:36 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG7c97dc20ab61: [clang] Do not crash on undefined template partial specialization (authored by Fznamznon).

Changed prior to commit:
  https://reviews.llvm.org/D148330?vs=513581&id=517496#toc

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,15 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s
+// 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
@@ -325,6 +325,8 @@
   member pointer as an invalid expression.
 - Fix crash when member function contains invalid default argument.
   (`#62122 <https://github.com/llvm/llvm-project/issues/62122>`_)
+- 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.517496.patch
Type: text/x-patch
Size: 1978 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230427/d7415cd5/attachment.bin>


More information about the cfe-commits mailing list