From 9f88348b3e5a8bf7292841a52a79d68f37ffe6c1 Mon Sep 17 00:00:00 2001 From: Erik Pilkington Date: Tue, 5 Jul 2016 17:57:24 +0000 Subject: [PATCH] [Sema] Fix a bug where pack expansion was not expanded in type alias The problem is that the parameter pack in a function type type alias is not reexpanded after being transformed. Also remove an incorrect comment in a similar function. Fixes PR26017. Differential Revision: http://reviews.llvm.org/D21030 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274566 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/TreeTransform.h | 10 ++++-- test/CXX/temp/temp.decls/temp.variadic/p5.cpp | 32 +++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index b13dc34377..88acc20600 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -3327,8 +3327,6 @@ bool TreeTransform::TransformExprs(Expr *const *Inputs, if (Out.isInvalid()) return true; - // FIXME: Can this happen? We should not try to expand the pack - // in this case. if (Out.get()->containsUnexpandedParameterPack()) { Out = getDerived().RebuildPackExpansion( Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions); @@ -4822,6 +4820,14 @@ bool TreeTransform::TransformFunctionTypeParams( if (NewType.isNull()) return true; + if (NewType->containsUnexpandedParameterPack()) { + NewType = + getSema().getASTContext().getPackExpansionType(NewType, None); + + if (NewType.isNull()) + return true; + } + if (ParamInfos) PInfos.set(OutParamTypes.size(), ParamInfos[i]); OutParamTypes.push_back(NewType); diff --git a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp index 4f9368f6b6..206e9f73e9 100644 --- a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp +++ b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp @@ -437,3 +437,35 @@ namespace PR21289 { template void g<>(); template void g<1, 2, 3>(); } + +template +int var_expr(Ts... ts); + +template +auto a_function(Ts... ts) -> decltype(var_expr(ts...)); + +template +using partial = decltype(a_function); + +int use_partial() { partial n; } + +namespace PR26017 { +template +struct Foo {}; +template +using FooAlias = Foo; + +template +using FooAliasAlias = FooAlias; + +template +void bar(const FooAlias &) {} + +int fn() { + FooAlias<> a; + bar(a); + + FooAlias b; + bar(b); +} +} -- 2.40.0