erik.pilkington updated this revision to Diff 60908. erik.pilkington added a comment.
This new patch replaces the call to `RebuildPackExpansion` with a direct call to `getPackExpansionType`. Also use `None` instead of `NumExpansions` as argument. As far as the `assert(*NumExpansions == 1)`, I don't believe that is always the case. Consider: template<class T> struct Foo {}; template<class... Ts> using FooAlias = Foo<void(Ts...)>; template<class... Us> using FooAliasAlias = FooAlias<Us..., Us...>; Here, the `Ts` in `FooAlias` are expanded into 2 `Us` in `FooAliasAlias`, meaning that there are 2 expansions that need to be separately rebuilt. I added this case to the test file. Thanks for the review! http://reviews.llvm.org/D21030 Files: lib/Sema/TreeTransform.h test/CXX/temp/temp.decls/temp.variadic/p5.cpp Index: test/CXX/temp/temp.decls/temp.variadic/p5.cpp =================================================================== --- test/CXX/temp/temp.decls/temp.variadic/p5.cpp +++ test/CXX/temp/temp.decls/temp.variadic/p5.cpp @@ -437,3 +437,35 @@ template void g<>(); template void g<1, 2, 3>(); } + +template <class... Ts> +int var_expr(Ts... ts); + +template <class... Ts> +auto a_function(Ts... ts) -> decltype(var_expr(ts...)); + +template <class T> +using partial = decltype(a_function<int, T>); + +int use_partial() { partial<char> n; } + +namespace PR26017 { +template <class T> +struct Foo {}; +template <class... Ts> +using FooAlias = Foo<void(Ts...)>; + +template <class... Ts> +using FooAliasAlias = FooAlias<void(Ts..., Ts...)>; + +template <class... Ts> +void bar(const FooAlias<Ts...> &) {} + +int fn() { + FooAlias<> a; + bar(a); + + FooAlias<int> b; + bar(b); +} +} Index: lib/Sema/TreeTransform.h =================================================================== --- lib/Sema/TreeTransform.h +++ lib/Sema/TreeTransform.h @@ -3310,8 +3310,6 @@ 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); @@ -4780,6 +4778,14 @@ 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);
Index: test/CXX/temp/temp.decls/temp.variadic/p5.cpp =================================================================== --- test/CXX/temp/temp.decls/temp.variadic/p5.cpp +++ test/CXX/temp/temp.decls/temp.variadic/p5.cpp @@ -437,3 +437,35 @@ template void g<>(); template void g<1, 2, 3>(); } + +template <class... Ts> +int var_expr(Ts... ts); + +template <class... Ts> +auto a_function(Ts... ts) -> decltype(var_expr(ts...)); + +template <class T> +using partial = decltype(a_function<int, T>); + +int use_partial() { partial<char> n; } + +namespace PR26017 { +template <class T> +struct Foo {}; +template <class... Ts> +using FooAlias = Foo<void(Ts...)>; + +template <class... Ts> +using FooAliasAlias = FooAlias<void(Ts..., Ts...)>; + +template <class... Ts> +void bar(const FooAlias<Ts...> &) {} + +int fn() { + FooAlias<> a; + bar(a); + + FooAlias<int> b; + bar(b); +} +} Index: lib/Sema/TreeTransform.h =================================================================== --- lib/Sema/TreeTransform.h +++ lib/Sema/TreeTransform.h @@ -3310,8 +3310,6 @@ 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); @@ -4780,6 +4778,14 @@ 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);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits