]> granicus.if.org Git - clang/commitdiff
Fix crash while parsing variable template with variadic template arguments
authorOlivier Goffart <ogoffart@woboq.com>
Thu, 26 May 2016 12:55:34 +0000 (12:55 +0000)
committerOlivier Goffart <ogoffart@woboq.com>
Thu, 26 May 2016 12:55:34 +0000 (12:55 +0000)
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

lib/Sema/SemaTemplateVariadic.cpp
test/SemaCXX/cxx1y-variable-templates_top_level.cpp

index 52a1ad545a5fcb3f6b1170608ced20e16743eae1..06afe87f515ee89e0bc8920d2c4b466a4a3c6c3b 100644 (file)
@@ -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;
index 1e5c98beb9cb47519098cd9eb083c447e0c53578..496ae888732f16017802a168f1df8727558400a4 100644 (file)
@@ -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