From 0f2be186027c844e6427c240cf29ad19c0501bae Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 2 Jun 2017 22:53:06 +0000 Subject: [PATCH] Fix assertion failure if we can't deduce a template argument for a variable template partial specialization. In passing, fix the deduction-crash.cpp test to actually run all the tests. Due to a typo, the last third of the file was being skipped by the parser and some of the tests were not actually testing anything as a result. Switch from FileCheck to -verify to make the problem more obvious and prevent this happening again. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304604 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaTemplateDeduction.cpp | 3 ++- test/SemaTemplate/deduction-crash.cpp | 36 ++++++++++++++------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index ebdf6dd57f..7467ce40a8 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -2383,7 +2383,8 @@ static Sema::TemplateDeductionResult ConvertDeducedTemplateArguments( bool HasDefaultArg = false; TemplateDecl *TD = dyn_cast(Template); if (!TD) { - assert(isa(Template)); + assert(isa(Template) || + isa(Template)); return Sema::TDK_Incomplete; } diff --git a/test/SemaTemplate/deduction-crash.cpp b/test/SemaTemplate/deduction-crash.cpp index c94c9db94e..74a25865aa 100644 --- a/test/SemaTemplate/deduction-crash.cpp +++ b/test/SemaTemplate/deduction-crash.cpp @@ -1,14 +1,10 @@ -// RUN: not %clang_cc1 -fsyntax-only %s -std=c++11 2>&1| FileCheck %s - -// Note that the error count below doesn't matter. We just want to -// make sure that the parser doesn't crash. -// CHECK: 17 errors +// RUN: %clang_cc1 -fsyntax-only %s -std=c++1z -verify // PR7511 -template +template // expected-error +{{}} struct int_; -template +template // expected-error +{{}} template struct ac { @@ -17,7 +13,7 @@ struct ac templatestruct aaa { - typedef ac<1,int,int>::ae ae + typedef ac<1,int,int>::ae ae // expected-error +{{}} }; template @@ -36,19 +32,19 @@ struct state_machine struct In; template - struct In,my>; + struct In,my>; // expected-error +{{}} template int process(Event) { - In > a; + In > a; // expected-error +{{}} } - } + } // expected-error +{{}} template int ant(Event) { region_processing_helper* helper; - helper->process(0) + helper->process(0) // expected-error +{{}} } }; @@ -81,21 +77,21 @@ void endl( ) ; extern basic_ostream cout; -int operator<<( basic_ostream , pair ) ; +int operator<<( basic_ostream , pair ) ; // expected-note +{{}} void register_object_imp ( ) { -cout << endl<1>; +cout << endl<1>; // expected-error +{{}} } // PR12933 -namespacae PR12933 { - template +namespace PR12933 { + template // expected-error +{{}} template void function(S a, T b) {} int main() { - function(0, 1); + function(0, 1); // expected-error +{{}} return 0; } } @@ -142,3 +138,9 @@ namespace PR14281_part3 { template struct B {}; A, &some_decl>::type x; } + +namespace var_template_partial_spec_incomplete { + template int n; + template int n; // expected-error +{{}} expected-note {{}} + int k = n; +} -- 2.50.1