[clang] [Clang][Sema] Revisit the fix for the lambda within a type alias template decl (PR #89934)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 26 11:17:31 PDT 2024


================
@@ -91,15 +91,60 @@ void bar() {
 
 namespace GH82104 {
 
-template <typename, typename...> int Zero = 0;
+template <typename, typename... D> int Value = sizeof...(D);
 
-template <typename T, typename...U>
-using T14 = decltype([]<int V = 0>() { return Zero<T, U...>; }());
+template <typename T, typename... U>
+using T14 = decltype([]<int V = 0>(auto Param) {
+  return Value<T, U...> + V + (int)sizeof(Param);
+}("hello"));
 
 template <typename T> using T15 = T14<T, T>;
 
 static_assert(__is_same(T15<char>, int));
 
+// FIXME: This still crashes because we can't extract template arguments T and U
+// outside of the instantiation context of T16.
+#if 0
+template <typename T, typename... U>
+using T16 = decltype([](auto Param) requires (sizeof(Param) != 1 && sizeof...(U) > 0) {
+  return Value<T, U...> + sizeof(Param);
+});
+static_assert(T16<int, char, float>()(42) == 2 + sizeof(42));
+#endif
----------------
mizvekov wrote:

This test case passes with my current WIP contextdecl patch.

By the way, `Value` needs to be constexpr in order for that `static_assert` to work.

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


More information about the cfe-commits mailing list