-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unused-value -std=c++17 | ||
// expected-no-diagnostics | ||
namespace test1 { | ||
|
||
template <int num> int return_num() { return num; } | ||
|
||
template <typename lambda> struct lambda_wrapper { | ||
lambda &outer_lambda; | ||
lambda_wrapper(lambda& outer_lambda) : outer_lambda(outer_lambda) {} | ||
template <typename T> auto operator+(T t) { outer_lambda(t); return 1; } | ||
}; | ||
|
||
template <int... nums, typename lambda> | ||
void bw(lambda& outer_lambda) { | ||
(lambda_wrapper(outer_lambda) + ... + return_num<nums>()); | ||
} | ||
|
||
template <typename lambda> auto check_return_type(lambda inner_lambda) { | ||
using inner_lambda_return_type = decltype(inner_lambda(5)); | ||
} | ||
|
||
void cs() { | ||
auto outer_lambda = [](auto param) { | ||
auto inner_lambda = [](auto o) -> decltype(param) {}; | ||
check_return_type(inner_lambda); | ||
}; | ||
bw<1,2>(outer_lambda); | ||
} | ||
|
||
} // namespace test1 | ||
|
||
namespace test2 { | ||
|
||
template <typename lambda> | ||
auto run_lambda_with_zero(lambda l) { | ||
l(0); | ||
} | ||
template <typename ... Ts, typename lambda> | ||
void run_lambda_once_per_type(lambda l) { | ||
((Ts{}, run_lambda_with_zero(l)), ...); | ||
} | ||
template <typename> void inner_function() { | ||
char c; | ||
[](auto param) -> decltype(c) { return param; }(0); | ||
} | ||
void run() { | ||
auto x = [](auto) -> void { inner_function<int>(); }; | ||
run_lambda_once_per_type<int>(x); | ||
} | ||
|
||
} // namespace test2 |