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; } }
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; } }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits