|
| 1 | +! Test dummy procedure pointers that are not an argument in every entry. |
| 2 | +! This requires creating a mock value in the entries where it is not an |
| 3 | +! argument. |
| 4 | +! |
| 5 | +!RUN: %flang_fc1 -emit-hlfir %s -o - 2>&1 | FileCheck %s |
| 6 | + |
| 7 | +!CHECK-LABEL: func @_QPdummy_char_proc_ptr() -> !fir.boxproc<(!fir.ref<!fir.char<1>>, index) -> !fir.boxchar<1>> { |
| 8 | +!CHECK: %[[UNDEF:.*]] = fir.undefined !fir.ref<!fir.boxproc<() -> ()>> |
| 9 | +!CHECK: %{{.*}}:2 = hlfir.declare %[[UNDEF]] |
| 10 | +!CHECK-SAME: {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFdummy_char_proc_ptrEdummy"} |
| 11 | +!CHECK-SAME: : (!fir.ref<!fir.boxproc<() -> ()>>) |
| 12 | +!CHECK-SAME: -> (!fir.ref<!fir.boxproc<() -> ()>>, !fir.ref<!fir.boxproc<() -> ()>>) |
| 13 | + |
| 14 | +!CHECK-LABEL: func @_QPdummy_char_proc_ptr_entry( |
| 15 | +!CHECK-SAME: %[[ARG:.*]]: !fir.ref<!fir.boxproc<() -> ()>>) |
| 16 | +!CHECK-SAME: -> !fir.boxproc<(!fir.ref<!fir.char<1>>, index) -> !fir.boxchar<1>> { |
| 17 | +!CHECK: %{{.*}}:2 = hlfir.declare %[[ARG]] dummy_scope %{{[^ ]*}} |
| 18 | +!CHECK-SAME: {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFdummy_char_proc_ptrEdummy"} |
| 19 | +!CHECK-SAME: : (!fir.ref<!fir.boxproc<() -> ()>>, !fir.dscope) |
| 20 | +!CHECK-SAME: -> (!fir.ref<!fir.boxproc<() -> ()>>, !fir.ref<!fir.boxproc<() -> ()>>) |
| 21 | +function dummy_char_proc_ptr() result(fun) |
| 22 | + interface |
| 23 | + character function char_fun() |
| 24 | + end function |
| 25 | + end interface |
| 26 | + |
| 27 | + procedure (char_fun), pointer :: fun, dummy_char_proc_ptr_entry, dummy |
| 28 | + fun => null() |
| 29 | + return |
| 30 | + |
| 31 | + entry dummy_char_proc_ptr_entry(dummy) |
| 32 | +end function |
| 33 | + |
| 34 | +!CHECK-LABEL: func @_QPdummy_int_proc_ptr() |
| 35 | +!CHECK: %[[UNDEF:.*]] = fir.undefined !fir.ref<!fir.boxproc<() -> ()>> |
| 36 | +!CHECK: %{{.*}}:2 = hlfir.declare %[[UNDEF]] |
| 37 | +!CHECK-SAME: {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFdummy_int_proc_ptrEdummy"} |
| 38 | +!CHECK-SAME: : (!fir.ref<!fir.boxproc<() -> ()>>) |
| 39 | +!CHECK-SAME: -> (!fir.ref<!fir.boxproc<() -> ()>>, !fir.ref<!fir.boxproc<() -> ()>>) |
| 40 | + |
| 41 | +!CHECK-LABEL: func @_QPdummy_int_proc_ptr_entry( |
| 42 | +!CHECK-SAME: %[[ARG:.*]]: !fir.ref<!fir.boxproc<() -> ()>>) |
| 43 | +!CHECK-SAME: -> !fir.boxproc<() -> i32> { |
| 44 | +!CHECK: %{{.*}}:2 = hlfir.declare %[[ARG]] dummy_scope %{{[^ ]*}} |
| 45 | +!CHECK-SAME: {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFdummy_int_proc_ptrEdummy"} |
| 46 | +!CHECK-SAME: : (!fir.ref<!fir.boxproc<() -> ()>>, !fir.dscope) |
| 47 | +!CHECK-SAME: -> (!fir.ref<!fir.boxproc<() -> ()>>, !fir.ref<!fir.boxproc<() -> ()>>) |
| 48 | +function dummy_int_proc_ptr() result(fun) |
| 49 | + interface |
| 50 | + integer function int_fun() |
| 51 | + end function |
| 52 | + end interface |
| 53 | + |
| 54 | + procedure (int_fun), pointer :: fun, dummy_int_proc_ptr_entry, dummy |
| 55 | + fun => null() |
| 56 | + return |
| 57 | + |
| 58 | + entry dummy_int_proc_ptr_entry(dummy) |
| 59 | +end function |
0 commit comments