diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2016-05-26 12:55:34 +0000 |
---|---|---|
committer | Olivier Goffart <ogoffart@woboq.com> | 2016-05-26 12:55:34 +0000 |
commit | eeba9e406681850ce52ca52a7d056355197ab354 (patch) | |
tree | 90c79618288e4e8350d11c58df58d899abb778db | |
parent | a224de06bc816812a5918c146b351c92b05d6ed8 (diff) | |
download | bcm5719-llvm-eeba9e406681850ce52ca52a7d056355197ab354.tar.gz bcm5719-llvm-eeba9e406681850ce52ca52a7d056355197ab354.zip |
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
llvm-svn: 270845
-rw-r--r-- | clang/lib/Sema/SemaTemplateVariadic.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp index 52a1ad545a5..06afe87f515 100644 --- a/clang/lib/Sema/SemaTemplateVariadic.cpp +++ b/clang/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/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp index 1e5c98beb9c..496ae888732 100644 --- a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp +++ b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp @@ -458,3 +458,9 @@ namespace PR19169 { template<> int g<double>; // expected-error {{no variable template matches specialization; did you mean to use 'g' as function template instead?}} } +#ifndef PRECXX11 +template <typename... Args> struct Variadic_t { }; +template <typename... Args> Variadic_t<Args...> Variadic; +auto variadic1 = Variadic<>; +auto variadic2 = Variadic<int, int>; +#endif |