// Test that bind_c derived type results are not moved to a hidden argument // by the abstract-result pass. They will be dealt with according to the C // struct returning ABI for the target in the target-rewrite pass. // RUN: fir-opt %s --abstract-result | FileCheck %s !t = !fir.type !cptr = !fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}> func.func private @foo() -> !t attributes {fir.proc_attrs = #fir.proc_attrs} func.func @test_call(%x: !fir.ref) { %0 = fir.call @foo() proc_attrs : () -> !t fir.save_result %0 to %x : !t, !fir.ref return } func.func @test_addr_of() -> (() -> !t) { %0 = fir.address_of(@foo) : () -> !t return %0 : () -> !t } func.func @test_dispatch(%x: !fir.ref, %y : !fir.class>) { %0 = fir.dispatch "bar"(%y : !fir.class>) (%y : !fir.class>) -> !t proc_attrs {pass_arg_pos = 0 : i32} fir.save_result %0 to %x : !t, !fir.ref return } func.func private @return_cptr() -> !cptr attributes {fir.proc_attrs = #fir.proc_attrs} func.func @test_return_cptr(%x: !fir.ref) { %0 = fir.call @return_cptr() proc_attrs : () -> !cptr fir.save_result %0 to %x : !cptr, !fir.ref return } // CHECK-LABEL: func.func @test_call( // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref>) { // CHECK: %[[VAL_1:.*]] = fir.call @foo() proc_attrs : () -> !fir.type // CHECK: fir.store %[[VAL_1]] to %[[VAL_0]] : !fir.ref> // CHECK: return // CHECK: } // CHECK-LABEL: func.func @test_addr_of() -> (() -> !fir.type) { // CHECK: %[[VAL_0:.*]] = fir.address_of(@foo) : () -> !fir.type // CHECK: return %[[VAL_0]] : () -> !fir.type // CHECK: } // CHECK-LABEL: func.func @test_dispatch( // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref>, // CHECK-SAME: %[[VAL_1:.*]]: !fir.class>) { // CHECK: %[[VAL_2:.*]] = fir.dispatch "bar"(%[[VAL_1]] : !fir.class>) (%[[VAL_1]] : !fir.class>) -> !fir.type proc_attrs {pass_arg_pos = 0 : i32} // CHECK: fir.store %[[VAL_2]] to %[[VAL_0]] : !fir.ref> // CHECK: return // CHECK: } // CHECK-LABEL: func.func @test_return_cptr( // CHECK-SAME: %[[VAL_0:.*]]: !fir.ref>) { // CHECK: %[[VAL_1:.*]] = fir.call @return_cptr() : () -> !fir.ref // CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_0]], __address : (!fir.ref>) -> !fir.ref // CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_1]] : (!fir.ref) -> i64 // CHECK: fir.store %[[VAL_4]] to %[[VAL_3]] : !fir.ref