Fix pack instantiation with function types.

Make sure we correctly expand packs which expand to another
pack in a function type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186728 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 34fdbad..4a41b60 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -4269,6 +4269,10 @@
           if (NewType.isNull())
             return true;
 
+          if (NewType->containsUnexpandedParameterPack())
+            NewType = getSema().Context.getPackExpansionType(NewType,
+                                                             NumExpansions);
+
           OutParamTypes.push_back(NewType);
           if (PVars)
             PVars->push_back(0);
diff --git a/test/SemaTemplate/alias-templates.cpp b/test/SemaTemplate/alias-templates.cpp
index eeb6b95..f495620 100644
--- a/test/SemaTemplate/alias-templates.cpp
+++ b/test/SemaTemplate/alias-templates.cpp
@@ -189,3 +189,10 @@
     }
   }
 }
+
+namespace VariadicAliasWithFunctionType {
+  template <class T> struct A { };
+  template <class ...Args> using B = A<int(Args ...x)>;
+  template <class ...Args> void f(B<A<int>, A<Args>...>) {}
+  void g() { f(A<int(A<int>,A<int>)>()); }
+}