1 // RUN: %clang_cc1 -std=c++23 %s -emit-llvm -triple x86_64-linux -o - | FileCheck %s
2 // RUN: %clang_cc1 -std=c++23 %s -emit-llvm -triple x86_64-windows-msvc -o - | FileCheck %s
5 static int operator()(int x
, int y
) {
11 return [](int x
, int y
) static {
16 void CallsTheLambda() {
20 // CHECK: define {{.*}}CallsTheLambda{{.*}}
22 // CHECK-NEXT: %call = call noundef i32 {{.*}}(i32 noundef 1, i32 noundef 2)
23 // CHECK-NEXT: ret void
26 void call_static_call_operator() {
29 f
.operator()(201, 202);
31 Functor::operator()(401, 402);
34 // CHECK: define {{.*}}call_static_call_operator{{.*}}
36 // CHECK: {{.*}} = call noundef i32 {{.*}}Functor{{.*}}(i32 noundef 101, i32 noundef 102)
37 // CHECK-NEXT: {{.*}} = call noundef i32 {{.*}}Functor{{.*}}(i32 noundef 201, i32 noundef 202)
38 // CHECK-NEXT: {{.*}} = call noundef i32 {{.*}}Functor{{.*}}(i32 noundef 301, i32 noundef 302)
39 // CHECK-NEXT: {{.*}} = call noundef i32 {{.*}}Functor{{.*}}(i32 noundef 401, i32 noundef 402)
40 // CHECK-NEXT: ret void
43 struct FunctorConsteval
{
44 consteval
static int operator()(int x
, int y
) {
49 struct FunctorConstexpr
{
50 constexpr static int operator()(int x
, int y
) {
55 constexpr auto my_lambda
= []() constexpr {
59 void test_consteval_constexpr() {
61 int y
= FunctorConstexpr
{}(x
, 2);
62 constexpr int z1
= FunctorConsteval
{}(2, 2);
63 constexpr int z2
= FunctorConstexpr
{}(2, 2);
65 static_assert(z1
== 4);
66 static_assert(z2
== 4);
68 constexpr auto my_lambda
= []() constexpr static {
71 constexpr int (*f
)(void) = my_lambda
;
72 constexpr int k
= f();
73 static_assert(k
== 3);
78 static int operator()(T t
) {
85 return [](T t
) static -> int {
91 return [](auto t
) static -> int {
96 void test_dep_functors() {
97 int x
= DepFunctor
<float>{}(1.0f
);
98 int y
= DepFunctor
<bool>{}(true);
100 int a
= dep_lambda1
<float>()(1.0f
);
101 int b
= dep_lambda1
<bool>()(true);
103 int h
= dep_lambda2()(1.0f
);
104 int i
= dep_lambda2()(true);
107 // CHECK: define {{.*}}test_dep_functors{{.*}}
108 // CHECK-NEXT: entry:
109 // CHECK: %call = call noundef i32 {{.*}}DepFunctor{{.*}}(float noundef 1.000000e+00)
110 // CHECK: %call1 = call noundef i32 {{.*}}DepFunctor{{.*}}(i1 noundef zeroext true)
111 // CHECK: %call2 = call noundef i32 {{.*}}dep_lambda1{{.*}}(float noundef 1.000000e+00)
112 // CHECK: %call3 = call noundef i32 {{.*}}dep_lambda1{{.*}}(i1 noundef zeroext true)
113 // CHECK: %call4 = call noundef i32 {{.*}}dep_lambda2{{.*}}(float noundef 1.000000e+00)
114 // CHECK: %call5 = call noundef i32 {{.*}}dep_lambda2{{.*}}(i1 noundef zeroext true)
120 static constexpr auto operator()() { return 4; };
123 constexpr operator P
*() { return operator(); }
129 // Checks that overload resolution works.