1 // RUN: %clang_cc1 -std=c++2b %s -emit-llvm -triple x86_64-linux -o - | FileCheck %s
2 // RUN: %clang_cc1 -std=c++2b %s -emit-llvm -triple x86_64-windows-msvc -o - | FileCheck %s
5 static int operator[](int x
, int y
) {
10 void call_static_subscript_operator() {
13 f
.operator[](201, 202);
15 Functor::operator[](401, 402);
18 // CHECK: define {{.*}}call_static_subscript_operator{{.*}}
20 // CHECK: {{.*}} = call noundef i32 {{.*}}Functor{{.*}}(i32 noundef 101, i32 noundef 102)
21 // CHECK-NEXT: {{.*}} = call noundef i32 {{.*}}Functor{{.*}}(i32 noundef 201, i32 noundef 202)
22 // CHECK-NEXT: {{.*}} = call noundef i32 {{.*}}Functor{{.*}}(i32 noundef 301, i32 noundef 302)
23 // CHECK-NEXT: {{.*}} = call noundef i32 {{.*}}Functor{{.*}}(i32 noundef 401, i32 noundef 402)
24 // CHECK-NEXT: ret void
27 struct FunctorConsteval
{
28 consteval
static int operator[](int x
, int y
) {
33 struct FunctorConstexpr
{
34 constexpr static int operator[](int x
, int y
) {
39 void test_consteval_constexpr() {
41 int y
= FunctorConstexpr
{}[x
, 2];
42 constexpr int z1
= FunctorConsteval
{}[2, 2];
43 constexpr int z2
= FunctorConstexpr
{}[2, 2];
45 static_assert(z1
== 4);
46 static_assert(z2
== 4);
51 static int operator[](T t
) {
56 void test_dep_functors() {
57 int x
= DepFunctor
<float>{}[1.0f
];
58 int y
= DepFunctor
<bool>{}[true];
61 // CHECK: define {{.*}}test_dep_functors{{.*}}
63 // CHECK: %call = call noundef i32 {{.*}}DepFunctor{{.*}}(float noundef 1.000000e+00)
64 // CHECK: %call1 = call noundef i32 {{.*}}DepFunctor{{.*}}(i1 noundef zeroext true)