|
1 | | -! Test lower of FORALL polymorphic pointer assignment |
| 1 | +! Test lower of FORALL pointer assignment |
2 | 2 | ! RUN: bbc -emit-fir %s -o - | FileCheck %s |
3 | 3 |
|
4 | 4 | !! Test when LHS is polymorphic and RHS is not polymorphic |
@@ -87,3 +87,45 @@ subroutine forallPolymorphic2(Tar1) |
87 | 87 |
|
88 | 88 | end subroutine forallPolymorphic2 |
89 | 89 |
|
| 90 | +!! Test the LHS of a pointer assignment gets the isAllocatable flag from the |
| 91 | +!! RHS that is a function reference. |
| 92 | +! CHECK-LABEL: c.func @_QPforallpointerassignment1 |
| 93 | + subroutine forallPointerAssignment1() |
| 94 | + type base |
| 95 | + real, pointer :: data => null() |
| 96 | + end type |
| 97 | + |
| 98 | + interface |
| 99 | + pure function makeData (i) |
| 100 | + real, pointer :: makeData |
| 101 | + integer*4, intent(in) :: i |
| 102 | + end function |
| 103 | + end interface |
| 104 | + |
| 105 | + type(base) :: co1(10) |
| 106 | + |
| 107 | + forall (i=1:10) |
| 108 | + co1(i)%data => makeData (i) |
| 109 | + end forall |
| 110 | + |
| 111 | +! CHECK: %[[V_3:[0-9]+]] = fir.alloca i64 |
| 112 | +! CHECK: %[[V_3:[0-9]+]] = fir.alloca i32 {bindc_name = "i"} |
| 113 | +! CHECK: %[[V_4:[0-9]+]] = fir.alloca !fir.box<!fir.ptr<f32>> {bindc_name = ".result"} |
| 114 | +! CHECK: %[[V_25:[0-9]+]] = fir.convert %c1_i32 : (i32) -> index |
| 115 | +! CHECK: %[[V_26:[0-9]+]] = fir.convert %c10_i32 : (i32) -> index |
| 116 | +! CHECK: %[[V_27:[0-9]+]] = fir.address_of( |
| 117 | +! CHECK: %[[V_28:[0-9]+]] = fir.convert %[[V_27]] : (!fir.ref<!fir.char<1,82>>) -> !fir.ref<i8> |
| 118 | +! CHECK: %[[V_29:[0-9]+]] = fir.call @_FortranACreateDescriptorStack(%[[V_28]], %c{{.*}}) : (!fir.ref<i8>, i32) -> !fir.llvm_ptr<i8> |
| 119 | +! CHECK: fir.do_loop %arg0 = %[[V_25]] to %[[V_26]] step %c1 |
| 120 | +! CHECK: { |
| 121 | +! CHECK: %[[V_32:[0-9]+]] = fir.convert %arg0 : (index) -> i32 |
| 122 | +! CHECK: fir.store %[[V_32]] to %[[V_3]] : !fir.ref<i32> |
| 123 | +! CHECK: %[[V_33:[0-9]+]] = fir.call @_QPmakedata(%[[V_3]]) proc_attrs<pure> fastmath<contract> : (!fir.ref<i32>) -> !fir.box<!fir.ptr<f32>> |
| 124 | +! CHECK: fir.save_result %[[V_33]] to %[[V_4]] : !fir.box<!fir.ptr<f32>>, !fir.ref<!fir.box<!fir.ptr<f32>>> |
| 125 | +! CHECK: %[[V_34:[0-9]+]] = fir.declare %[[V_4]] {uniq_name = ".tmp.func_result"} : (!fir.ref<!fir.box<!fir.ptr<f32>>>) -> !fir.ref<!fir.box<!fir.ptr<f32>>> |
| 126 | +! CHECK: %[[V_35:[0-9]+]] = fir.load %[[V_34]] : !fir.ref<!fir.box<!fir.ptr<f32>>> |
| 127 | +! CHECK: %[[V_36:[0-9]+]] = fir.convert %[[V_35]] : (!fir.box<!fir.ptr<f32>>) -> !fir.box<none> |
| 128 | +! CHECK: fir.call @_FortranAPushDescriptor(%[[V_29]], %[[V_36]]) : (!fir.llvm_ptr<i8>, !fir.box<none>) -> () |
| 129 | +! CHECK: } |
| 130 | + |
| 131 | + end subroutine forallPointerAssignment1 |
0 commit comments