3 // RUN: split-file %s %t
5 // RUN: %clang_cc1 -std=c++20 %t/template_lambdas.cppm -emit-module-interface \
6 // RUN: -o %t/lambdas.pcm
7 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -fsyntax-only \
10 // RUN: %clang_cc1 -std=c++20 %t/template_lambdas2.cppm -emit-module-interface \
11 // RUN: -o %t/lambdas2.pcm
12 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -fsyntax-only \
13 // RUN: -verify -DUSE_LAMBDA2
16 auto l1 = []<int I>() constexpr -> int {
20 auto l2 = []<auto I>() constexpr -> decltype(I) {
24 auto l3 = []<class T>(auto i) constexpr -> T {
28 auto l4 = []<template<class> class T, class U>(T<U>, auto i) constexpr -> U {
32 //--- template_lambdas.cppm
35 export module lambdas;
41 //--- template_lambdas2.cppm
42 export module lambdas2;
48 // expected-no-diagnostics
55 static_assert(l1.operator()<5>() == 5);
56 static_assert(l1.operator()<6>() == 6);
58 static_assert(l2.operator()<7>() == 7);
59 static_assert(l2.operator()<nullptr>() == nullptr);
61 static_assert(l3.operator()<int>(8.4) == 8);
62 static_assert(l3.operator()<int>(9.9) == 9);
65 struct DummyTemplate { };
67 static_assert(l4(DummyTemplate<float>(), 12) == 12.0);
68 static_assert(l4(DummyTemplate<int>(), 19.8) == 19);