48 lines · c
1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir2// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR3// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll4// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM5// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll6// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG7 8void f(void);9 10void f1() {11 (void (*)())f;12}13 14void f2() {15 (*(void (*)(void))f)();16}17 18void 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> : !s32i33// CIR: cir.call %[[S1]](%[[S2]]) : (!cir.ptr<!cir.func<(!s32i)>>, !s32i) -> ()34 35// LLVM-LABEL: define{{.*}} void @f1()36// LLVM: ret void37// 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 void44// OGCG: define{{.*}} void @f2()45// OGCG: call void @f()46// OGCG: define{{.*}} void @test_lvalue_cast()47// OGCG: call void @f(i32 noundef 42)48