[clang] [Sema] Preserve ContainsUnexpandedParameterPack in TransformLambdaExpr (PR #86265)

via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 5 07:41:22 PDT 2024


================
@@ -0,0 +1,181 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+
+namespace GH85667 {
+
+template <class T>
+struct identity {
+  using type = T;
+};
+
+template <class = void> void f() {
+
+  static_assert([]<class... Is>(Is... x) {
+    return ([I(x)] {
+      return I;
+    }() + ...);
+  }(1, 2) == 3);
+
+  []<class... Is>(Is... x) {
+    return ([](auto y = Is()) { return y + 1; }() + ...); // expected-error {{no matching function}}                     \
+                                                          // expected-note {{couldn't infer template argument 'y:auto'}} \
+                                                          // expected-note at -1 {{requested here}}
+                                                          // expected-note@#instantiate-f {{requested here}}
+  }(1);
+
+  []<class... Is>() {
+    ([]<class = Is>(Is)
+       noexcept(bool(Is()))
+     {}(Is()),
+     ...);
+  }.template operator()<char, int, float>();
+
+  static_assert(__is_same(decltype([]<class... Is>() {
+                            return ([]() -> decltype(Is()) { return {}; }(),
+                                    ...);
+                          }.template operator()<int, char>()),
+                          char));
+
+  []<class... Is>() {
+    return ([]<class... Ts>() -> decltype(Is()) { return Ts(); }() + ...);
+    // expected-error at -1 {{unexpanded parameter pack 'Ts'}}
+  }.template operator()<int, int>();
+
+  // https://github.com/llvm/llvm-project/issues/56852
+  []<class... Is>(Is...) {
+    ([] {
+      using T = identity<Is>::type;
+    }(), ...);
+  }(1, 2);
+
+  [](auto ...y) {
+    ([y] { }(), ...);
+  }();
+
+  [](auto ...x) {
+    ([&](auto ...y) {
+      ([x..., y] { }(), ...);
+    })(1);
+  }(2, 'b');
+
+#if 0
+  // https://github.com/llvm/llvm-project/issues/18873
----------------
cor3ntin wrote:

```suggestion
  // FIXME: https://github.com/llvm/llvm-project/issues/18873
```

https://github.com/llvm/llvm-project/pull/86265


More information about the cfe-commits mailing list