From: Richard Smith Date: Wed, 12 Nov 2014 01:43:45 +0000 (+0000) Subject: PR21536: Fix a corner case where we'd get confused by a pack expanding into the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b6ff5628bec83cb58cdb9724584eeaf0a51fe81b;p=clang PR21536: Fix a corner case where we'd get confused by a pack expanding into the penultimate parameter of a template parameter list, where the last parameter is itself a pack, and build a bogus empty final pack argument. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221748 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 1bddfe2184..50a4298333 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -3749,7 +3749,7 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template, } // Push the argument pack onto the list of converted arguments. - if (InFinalParameterPack) { + if (InFinalParameterPack && !ArgumentPack.empty()) { Converted.push_back( TemplateArgument::CreatePackCopy(Context, ArgumentPack.data(), diff --git a/test/SemaTemplate/deduction.cpp b/test/SemaTemplate/deduction.cpp index 59162b74cc..797f7f8261 100644 --- a/test/SemaTemplate/deduction.cpp +++ b/test/SemaTemplate/deduction.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 // Template argument deduction with template template parameters. template class A> @@ -162,3 +162,19 @@ namespace test14 { foo(a); } } + +namespace PR21536 { + template struct X; + template struct S { + static_assert(sizeof...(B) == 1, ""); + void f() { + using T = A; + using T = int; + + using U = X; + using U = X; + } + }; + template void f(S); + void g() { f(S()); } +}