|
| 1 | +! Test procedure pointers with the same name as generics. |
| 2 | +! RUN: bbc -emit-hlfir -o - %s | FileCheck %s |
| 3 | + |
| 4 | +module m_gen |
| 5 | + procedure(func), pointer :: foo |
| 6 | + interface foo |
| 7 | + procedure :: foo |
| 8 | + end interface |
| 9 | + interface |
| 10 | + real function func(x) |
| 11 | + real :: x |
| 12 | + end function |
| 13 | + end interface |
| 14 | +end |
| 15 | +!CHECK-LABEL: fir.global @_QMm_genEfoo : !fir.boxproc<(!fir.ref<f32>) -> f32> { |
| 16 | +!CHECK: %[[VAL_0:.*]] = fir.zero_bits (!fir.ref<f32>) -> f32 |
| 17 | +!CHECK: %[[VAL_1:.*]] = fir.emboxproc %[[VAL_0]] : ((!fir.ref<f32>) -> f32) -> !fir.boxproc<(!fir.ref<f32>) -> f32> |
| 18 | +!CHECK: fir.has_value %[[VAL_1]] : !fir.boxproc<(!fir.ref<f32>) -> f32> |
| 19 | + |
| 20 | +subroutine test1() |
| 21 | + use m_gen |
| 22 | + foo => func |
| 23 | +end subroutine |
| 24 | +!CHECK-LABEL: func.func @_QPtest1() { |
| 25 | +!CHECK: %[[VAL_0:.*]] = fir.address_of(@_QMm_genEfoo) : !fir.ref<!fir.boxproc<(!fir.ref<f32>) -> f32>> |
| 26 | +!CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {{.*}}"_QMm_genEfoo"{{.*}} : (!fir.ref<!fir.boxproc<(!fir.ref<f32>) -> f32>>) -> (!fir.ref<!fir.boxproc<(!fir.ref<f32>) -> f32>>, !fir.ref<!fir.boxproc<(!fir.ref<f32>) -> f32>>) |
| 27 | +!CHECK: %[[VAL_2:.*]] = fir.address_of(@_QPfunc) : (!fir.ref<f32>) -> f32 |
| 28 | +!CHECK: %[[VAL_3:.*]] = fir.emboxproc %[[VAL_2]] : ((!fir.ref<f32>) -> f32) -> !fir.boxproc<() -> ()> |
| 29 | +!CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.boxproc<() -> ()>) -> !fir.boxproc<(!fir.ref<f32>) -> f32> |
| 30 | +!CHECK: fir.store %[[VAL_4]] to %[[VAL_1]]#0 : !fir.ref<!fir.boxproc<(!fir.ref<f32>) -> f32>> |
| 31 | + |
| 32 | +subroutine test_local() |
| 33 | + use m_gen, only : func |
| 34 | + procedure(func), pointer :: foo |
| 35 | + interface foo |
| 36 | + procedure :: foo |
| 37 | + end interface |
| 38 | + foo => func |
| 39 | +end subroutine |
| 40 | +!CHECK-LABEL: func.func @_QPtest_local() { |
| 41 | +!CHECK: %[[VAL_0:.*]] = fir.alloca !fir.boxproc<(!fir.ref<f32>) -> f32> {bindc_name = "foo", uniq_name = "_QFtest_localEfoo"} |
| 42 | +!CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] {{.*}}"_QFtest_localEfoo"{{.*}} : (!fir.ref<!fir.boxproc<(!fir.ref<f32>) -> f32>>) -> (!fir.ref<!fir.boxproc<(!fir.ref<f32>) -> f32>>, !fir.ref<!fir.boxproc<(!fir.ref<f32>) -> f32>>) |
| 43 | +!CHECK: %[[VAL_4:.*]] = fir.address_of(@_QPfunc) : (!fir.ref<f32>) -> f32 |
| 44 | +!CHECK: %[[VAL_5:.*]] = fir.emboxproc %[[VAL_4]] : ((!fir.ref<f32>) -> f32) -> !fir.boxproc<() -> ()> |
| 45 | +!CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (!fir.boxproc<() -> ()>) -> !fir.boxproc<(!fir.ref<f32>) -> f32> |
| 46 | +!CHECK: fir.store %[[VAL_6]] to %[[VAL_3]]#0 : !fir.ref<!fir.boxproc<(!fir.ref<f32>) -> f32>> |
0 commit comments