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

don hinton via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 10 11:51:49 PST 2016


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

- Added test for PR26077


http://reviews.llvm.org/D16971

Files:
  lib/Sema/SemaTemplate.cpp
  test/SemaCXX/pr26077-crash-on-invalid.cpp

Index: test/SemaCXX/pr26077-crash-on-invalid.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/pr26077-crash-on-invalid.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// Don't crash (PR26077).
+
+class DB {};
+
+template <typename T> class RemovePolicy : public T {};
+
+template <typename T, typename Policy = RemovePolicy<T>>
+  class Crash : T, Policy {};
+
+template <typename Policy>
+class Crash<DB> : public DB, public Policy { // expected-error {{partial specialization of 'Crash' does not use any of its template parameters}}
+public:
+  Crash(){}
+};
Index: lib/Sema/SemaTemplate.cpp
===================================================================
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -2542,7 +2542,7 @@
             InstantiationDependent)) {
       Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
           << VarTemplate->getDeclName();
-      IsPartialSpecialization = false;
+      return true;
     }
 
     if (isSameAsPrimaryTemplate(VarTemplate->getTemplateParameters(),
@@ -6286,7 +6286,7 @@
                                                      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.47499.patch
Type: text/x-patch
Size: 1411 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160210/0080ebd1/attachment.bin>


More information about the cfe-commits mailing list