From: Olivier Goffart Date: Thu, 26 May 2016 12:55:34 +0000 (+0000) Subject: Fix crash while parsing variable template with variadic template arguments X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1dcb4b9133fe4a2f370969ac64cef511e4feb135;p=clang Fix crash while parsing variable template with variadic template arguments It is only a crash if the compiler optimize for this!=nullptr because LocalInstantiationScope::getPartiallySubstitutedPack checks if 'this' is null (This is crashing when clang is compiled with GCC6) Differential Revision: http://reviews.llvm.org/D20511 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270845 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateVariadic.cpp b/lib/Sema/SemaTemplateVariadic.cpp index 52a1ad545a..06afe87f51 100644 --- a/lib/Sema/SemaTemplateVariadic.cpp +++ b/lib/Sema/SemaTemplateVariadic.cpp @@ -604,7 +604,7 @@ bool Sema::CheckParameterPacksForExpansion( // Template argument deduction can extend the sequence of template // arguments corresponding to a template parameter pack, even when the // sequence contains explicitly specified template arguments. - if (!IsFunctionParameterPack) { + if (!IsFunctionParameterPack && CurrentInstantiationScope) { if (NamedDecl *PartialPack = CurrentInstantiationScope->getPartiallySubstitutedPack()){ unsigned PartialDepth, PartialIndex; diff --git a/test/SemaCXX/cxx1y-variable-templates_top_level.cpp b/test/SemaCXX/cxx1y-variable-templates_top_level.cpp index 1e5c98beb9..496ae88873 100644 --- a/test/SemaCXX/cxx1y-variable-templates_top_level.cpp +++ b/test/SemaCXX/cxx1y-variable-templates_top_level.cpp @@ -458,3 +458,9 @@ namespace PR19169 { template<> int g; // expected-error {{no variable template matches specialization; did you mean to use 'g' as function template instead?}} } +#ifndef PRECXX11 +template struct Variadic_t { }; +template Variadic_t Variadic; +auto variadic1 = Variadic<>; +auto variadic2 = Variadic; +#endif