[PATCH] D16971: [Sema] PR26077 Fixed crash when partial specialization is missing required parameters

don hinton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 12 21:01:04 PDT 2017


hintonda updated this revision to Diff 102292.
hintonda added a comment.

Rebase, fix test, and add FIXME note.


https://reviews.llvm.org/D16971

Files:
  lib/Sema/SemaTemplate.cpp
  test/SemaTemplate/partial-spec-fully-specified.cpp


Index: test/SemaTemplate/partial-spec-fully-specified.cpp
===================================================================
--- /dev/null
+++ test/SemaTemplate/partial-spec-fully-specified.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template <class T>
+struct Base{};
+
+template <class A, class B>
+class Test {};
+
+template <class T>
+class Test<void, void> : Base<T> { // expected-error{{partial specialization of 'Test' does not use any of its template parameters}}
+  Test() {}
+};
Index: lib/Sema/SemaTemplate.cpp
===================================================================
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -3418,7 +3418,9 @@
             InstantiationDependent)) {
       Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
           << VarTemplate->getDeclName();
-      IsPartialSpecialization = false;
+      // FIXME: Can this ever get triggered?  If so, we need test.  If not,
+      // should this if be removed?
+      return true;
     }
 
     if (isSameAsPrimaryTemplate(VarTemplate->getTemplateParameters(),
@@ -7276,7 +7278,7 @@
             TemplateArgs.arguments(), InstantiationDependent)) {
       Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
         << ClassTemplate->getDeclName();
-      isPartialSpecialization = false;
+      return true;
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16971.102292.patch
Type: text/x-patch
Size: 1447 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170613/d9576ad7/attachment.bin>


More information about the cfe-commits mailing list