| 1 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir |
| 2 |
// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR |
| 3 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll |
| 4 |
// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM |
| 5 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll |
| 6 |
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG |
| 7 |
|
| 8 |
void f(void); |
| 9 |
|
| 10 |
void f1() { |
| 11 |
(void (*)())f; |
| 12 |
} |
| 13 |
|
| 14 |
void f2() { |
| 15 |
(*(void (*)(void))f)(); |
| 16 |
} |
| 17 |
|
| 18 |
void test_lvalue_cast() { |
| 19 |
(*(void (*)(int))f)(42); |
| 20 |
} |
| 21 |
|
| 22 |
// CIR-LABEL: cir.func{{.*}} @f() |
| 23 |
// CIR: cir.func{{.*}} @f1() |
| 24 |
// CIR: cir.return{{.*}} |
| 25 |
|
| 26 |
// CIR-LABEL: cir.func{{.*}} @f2() |
| 27 |
// CIR: cir.call @f() : () -> () |
| 28 |
|
| 29 |
// CIR-LABEL: cir.func{{.*}} @test_lvalue_cast() |
| 30 |
// CIR: %[[S0:.+]] = {{.*}}@f : !cir.ptr<!cir.func<()>>{{.*}} |
| 31 |
// CIR: %[[S1:.+]] = cir.cast{{.*}}%[[S0]] : !cir.ptr<!cir.func<()>>{{.*}} |
| 32 |
// CIR: %[[S2:.+]] = cir.const #cir.int<42> : !s32i |
| 33 |
// CIR: cir.call %[[S1]](%[[S2]]) : (!cir.ptr<!cir.func<(!s32i)>>, !s32i) -> () |
| 34 |
|
| 35 |
// LLVM-LABEL: define{{.*}} void @f1() |
| 36 |
// LLVM: ret void |
| 37 |
// LLVM: define{{.*}} void @f2() |
| 38 |
// LLVM: call void @f() |
| 39 |
// LLVM: define{{.*}} void @test_lvalue_cast() |
| 40 |
// LLVM: call void @f(i32 42) |
| 41 |
|
| 42 |
// OGCG-LABEL: define{{.*}} void @f1() |
| 43 |
// OGCG: ret void |
| 44 |
// OGCG: define{{.*}} void @f2() |
| 45 |
// OGCG: call void @f() |
| 46 |
// OGCG: define{{.*}} void @test_lvalue_cast() |
| 47 |
// OGCG: call void @f(i32 noundef 42) |