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
) {
10 Functor
GetAFunctor() {
14 void call_static_subscript_operator() {
17 f
.operator[](201, 202);
19 Functor::operator[](401, 402);
20 GetAFunctor()[501, 502];
23 // CHECK: define {{.*}}call_static_subscript_operator{{.*}}
25 // CHECK: {{.*}} = call noundef i32 {{.*}}Functor{{.*}}(i32 noundef 101, i32 noundef 102)
26 // CHECK-NEXT: {{.*}} = call noundef i32 {{.*}}Functor{{.*}}(i32 noundef 201, i32 noundef 202)
27 // CHECK-NEXT: {{.*}} = call noundef i32 {{.*}}Functor{{.*}}(i32 noundef 301, i32 noundef 302)
28 // CHECK-NEXT: {{.*}} = call noundef i32 {{.*}}Functor{{.*}}(i32 noundef 401, i32 noundef 402)
29 // CHECK: {{.*}}call {{.*}}GetAFunctor{{.*}}()
30 // CHECK-NEXT: {{.*}} = call noundef i32 {{.*}}Functor{{.*}}(i32 noundef 501, i32 noundef 502)
31 // CHECK-NEXT: ret void
34 struct FunctorConsteval
{
35 consteval
static int operator[](int x
, int y
) {
40 struct FunctorConstexpr
{
41 constexpr static int operator[](int x
, int y
) {
46 void test_consteval_constexpr() {
48 int y
= FunctorConstexpr
{}[x
, 2];
49 constexpr int z1
= FunctorConsteval
{}[2, 2];
50 constexpr int z2
= FunctorConstexpr
{}[2, 2];
52 static_assert(z1
== 4);
53 static_assert(z2
== 4);
58 static int operator[](T t
) {
63 void test_dep_functors() {
64 int x
= DepFunctor
<float>{}[1.0f
];
65 int y
= DepFunctor
<bool>{}[true];
68 // CHECK: define {{.*}}test_dep_functors{{.*}}
70 // CHECK: {{.*}} = call noundef i32 {{.*}}DepFunctor{{.*}}(float noundef 1.000000e+00)
71 // CHECK: {{.*}} = call noundef i32 {{.*}}DepFunctor{{.*}}(i1 noundef zeroext true)