[PATCH] D21030: [Sema] Fix rejects-valid where parameter pack was not expanded in type alias

Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 5 11:04:43 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL274566: [Sema] Fix a bug where pack expansion was not expanded in type alias (authored by epilk).

Changed prior to commit:
  http://reviews.llvm.org/D21030?vs=60908&id=62771#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21030

Files:
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp

Index: cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
===================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
+++ cfe/trunk/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<Ts..., Ts...>;
+
+template <class... Ts>
+void bar(const FooAlias<Ts...> &) {}
+
+int fn() {
+  FooAlias<> a;
+  bar(a);
+
+  FooAlias<int> b;
+  bar(b);
+}
+}
Index: cfe/trunk/lib/Sema/TreeTransform.h
===================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -3327,8 +3327,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);
@@ -4822,6 +4820,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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21030.62771.patch
Type: text/x-patch
Size: 1927 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160705/c6c0d1d9/attachment-0001.bin>


More information about the cfe-commits mailing list