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
15 // Test again with reduced BMI
18 // RUN: split-file %s %t
20 // RUN: %clang_cc1 -std=c++20 %t/template_lambdas.cppm -emit-reduced-module-interface \
21 // RUN: -o %t/lambdas.pcm
22 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -fsyntax-only \
25 // RUN: %clang_cc1 -std=c++20 %t/template_lambdas2.cppm -emit-reduced-module-interface \
26 // RUN: -o %t/lambdas2.pcm
27 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -fsyntax-only \
28 // RUN: -verify -DUSE_LAMBDA2
31 auto l1 = []<int I>() constexpr -> int {
35 auto l2 = []<auto I>() constexpr -> decltype(I) {
39 auto l3 = []<class T>(auto i) constexpr -> T {
43 auto l4 = []<template<class> class T, class U>(T<U>, auto i) constexpr -> U {
47 //--- template_lambdas.cppm
50 export module lambdas;
56 //--- template_lambdas2.cppm
57 export module lambdas2;
63 // expected-no-diagnostics
70 static_assert(l1.operator()<5>() == 5);
71 static_assert(l1.operator()<6>() == 6);
73 static_assert(l2.operator()<7>() == 7);
74 static_assert(l2.operator()<nullptr>() == nullptr);
76 static_assert(l3.operator()<int>(8.4) == 8);
77 static_assert(l3.operator()<int>(9.9) == 9);
80 struct DummyTemplate { };
82 static_assert(l4(DummyTemplate<float>(), 12) == 12.0);
83 static_assert(l4(DummyTemplate<int>(), 19.8) == 19);