Skip to content

Commit d6ae4bd

Browse files
committed
[Clang][NFC] Add tests for llvm#56071
Theses tests were part of https://reviews.llvm.org/D140184, which is no longer necessary but preserving the tests seems useful. Thanks to Richard Trieu for providing these tests and the work on this PR.
1 parent f3c3e2f commit d6ae4bd

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unused-value -std=c++17
2+
// expected-no-diagnostics
3+
namespace test1 {
4+
5+
template <int num> int return_num() { return num; }
6+
7+
template <typename lambda> struct lambda_wrapper {
8+
lambda &outer_lambda;
9+
lambda_wrapper(lambda& outer_lambda) : outer_lambda(outer_lambda) {}
10+
template <typename T> auto operator+(T t) { outer_lambda(t); return 1; }
11+
};
12+
13+
template <int... nums, typename lambda>
14+
void bw(lambda& outer_lambda) {
15+
(lambda_wrapper(outer_lambda) + ... + return_num<nums>());
16+
}
17+
18+
template <typename lambda> auto check_return_type(lambda inner_lambda) {
19+
using inner_lambda_return_type = decltype(inner_lambda(5));
20+
}
21+
22+
void cs() {
23+
auto outer_lambda = [](auto param) {
24+
auto inner_lambda = [](auto o) -> decltype(param) {};
25+
check_return_type(inner_lambda);
26+
};
27+
bw<1,2>(outer_lambda);
28+
}
29+
30+
} // namespace test1
31+
32+
namespace test2 {
33+
34+
template <typename lambda>
35+
auto run_lambda_with_zero(lambda l) {
36+
l(0);
37+
}
38+
template <typename ... Ts, typename lambda>
39+
void run_lambda_once_per_type(lambda l) {
40+
((Ts{}, run_lambda_with_zero(l)), ...);
41+
}
42+
template <typename> void inner_function() {
43+
char c;
44+
[](auto param) -> decltype(c) { return param; }(0);
45+
}
46+
void run() {
47+
auto x = [](auto) -> void { inner_function<int>(); };
48+
run_lambda_once_per_type<int>(x);
49+
}
50+
51+
} // namespace test2

0 commit comments

Comments
 (0)