cpplearner updated this revision to Diff 265683.
cpplearner added a comment.

rebase & ping @rsmith


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65050/new/

https://reviews.llvm.org/D65050

Files:
  clang/lib/AST/Type.cpp
  clang/test/SemaTemplate/alias-templates.cpp


Index: clang/test/SemaTemplate/alias-templates.cpp
===================================================================
--- clang/test/SemaTemplate/alias-templates.cpp
+++ clang/test/SemaTemplate/alias-templates.cpp
@@ -265,3 +265,34 @@
     int z = Bar(); // expected-error {{use of template template parameter 
'Bar' requires template arguments}}
   }
 }
+
+namespace PR42654 {
+  template<typename> struct function { };
+
+  template<typename...T>
+  struct thing {
+    void f(function<void(T...)>) { }
+  };
+
+  template<typename ...Ts>
+  struct Environment
+  {
+    template<typename T>
+    using Integer = int;
+
+    using Function = function<void(Integer<Ts>...)>;
+    using MyTuple = thing<Integer<Ts>...>;
+
+    void run(Function func)
+    {
+      MyTuple t;
+      t.f(func);
+    }
+  };
+
+  void f()
+  {
+    Environment<int, double> env;
+    env.run({});
+  }
+}
Index: clang/lib/AST/Type.cpp
===================================================================
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3110,6 +3110,11 @@
   for (unsigned i = 0; i != getNumParams(); ++i) {
     addDependence(params[i]->getDependence() &
                   ~TypeDependence::VariablyModified);
+    // A pack expansion with a non-dependent pattern affects the number of
+    // parameters, thus we mark such function type as dependent, even though
+    // this isn't listed in N4861 [temp.dep.type].
+    if (params[i]->getAs<PackExpansionType>())
+      addDependence(TypeDependence::Dependent);
     argSlot[i] = params[i];
   }
 


Index: clang/test/SemaTemplate/alias-templates.cpp
===================================================================
--- clang/test/SemaTemplate/alias-templates.cpp
+++ clang/test/SemaTemplate/alias-templates.cpp
@@ -265,3 +265,34 @@
     int z = Bar(); // expected-error {{use of template template parameter 'Bar' requires template arguments}}
   }
 }
+
+namespace PR42654 {
+  template<typename> struct function { };
+
+  template<typename...T>
+  struct thing {
+    void f(function<void(T...)>) { }
+  };
+
+  template<typename ...Ts>
+  struct Environment
+  {
+    template<typename T>
+    using Integer = int;
+
+    using Function = function<void(Integer<Ts>...)>;
+    using MyTuple = thing<Integer<Ts>...>;
+
+    void run(Function func)
+    {
+      MyTuple t;
+      t.f(func);
+    }
+  };
+
+  void f()
+  {
+    Environment<int, double> env;
+    env.run({});
+  }
+}
Index: clang/lib/AST/Type.cpp
===================================================================
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3110,6 +3110,11 @@
   for (unsigned i = 0; i != getNumParams(); ++i) {
     addDependence(params[i]->getDependence() &
                   ~TypeDependence::VariablyModified);
+    // A pack expansion with a non-dependent pattern affects the number of
+    // parameters, thus we mark such function type as dependent, even though
+    // this isn't listed in N4861 [temp.dep.type].
+    if (params[i]->getAs<PackExpansionType>())
+      addDependence(TypeDependence::Dependent);
     argSlot[i] = params[i];
   }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to