|
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 |
|
@@ -128,3 +128,47 @@ subroutine forallPolymorphic3() |
128 | 128 | ! CHECK: } |
129 | 129 |
|
130 | 130 | end subroutine forallPolymorphic3 |
| 131 | + |
| 132 | + |
| 133 | +!! Test the LHS of a pointer assignment gets the isPointer flag from the |
| 134 | +!! RHS that is a reference to a function that returns a pointer. |
| 135 | +! CHECK-LABEL: c.func @_QPforallpointerassignment1 |
| 136 | + subroutine forallPointerAssignment1() |
| 137 | + type base |
| 138 | + real, pointer :: data => null() |
| 139 | + end type |
| 140 | + |
| 141 | + interface |
| 142 | + pure function makeData (i) |
| 143 | + real, pointer :: makeData |
| 144 | + integer*4, intent(in) :: i |
| 145 | + end function |
| 146 | + end interface |
| 147 | + |
| 148 | + type(base) :: co1(10) |
| 149 | + |
| 150 | + forall (i=1:10) |
| 151 | + co1(i)%data => makeData (i) |
| 152 | + end forall |
| 153 | + |
| 154 | +! CHECK: %[[V_3:[0-9]+]] = fir.alloca i64 |
| 155 | +! CHECK: %[[V_3:[0-9]+]] = fir.alloca i32 {bindc_name = "i"} |
| 156 | +! CHECK: %[[V_4:[0-9]+]] = fir.alloca !fir.box<!fir.ptr<f32>> {bindc_name = ".result"} |
| 157 | +! CHECK: %[[V_25:[0-9]+]] = fir.convert %c1_i32 : (i32) -> index |
| 158 | +! CHECK: %[[V_26:[0-9]+]] = fir.convert %c10_i32 : (i32) -> index |
| 159 | +! CHECK: %[[V_27:[0-9]+]] = fir.address_of(@{{_QQcl.*}}) : !fir.ref<!fir.char<1,{{.*}}>> |
| 160 | +! CHECK: %[[V_28:[0-9]+]] = fir.convert %[[V_27]] : (!fir.ref<!fir.char<1,{{.*}}>>) -> !fir.ref<i8> |
| 161 | +! CHECK: %[[V_29:[0-9]+]] = fir.call @_FortranACreateDescriptorStack(%[[V_28]], %c{{.*}}) : (!fir.ref<i8>, i32) -> !fir.llvm_ptr<i8> |
| 162 | +! CHECK: fir.do_loop %arg0 = %[[V_25]] to %[[V_26]] step %c1 |
| 163 | +! CHECK: { |
| 164 | +! CHECK: %[[V_32:[0-9]+]] = fir.convert %arg0 : (index) -> i32 |
| 165 | +! CHECK: fir.store %[[V_32]] to %[[V_3]] : !fir.ref<i32> |
| 166 | +! CHECK: %[[V_33:[0-9]+]] = fir.call @_QPmakedata(%[[V_3]]) proc_attrs<pure> fastmath<contract> : (!fir.ref<i32>) -> !fir.box<!fir.ptr<f32>> |
| 167 | +! CHECK: fir.save_result %[[V_33]] to %[[V_4]] : !fir.box<!fir.ptr<f32>>, !fir.ref<!fir.box<!fir.ptr<f32>>> |
| 168 | +! 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>>> |
| 169 | +! CHECK: %[[V_35:[0-9]+]] = fir.load %[[V_34]] : !fir.ref<!fir.box<!fir.ptr<f32>>> |
| 170 | +! CHECK: %[[V_36:[0-9]+]] = fir.convert %[[V_35]] : (!fir.box<!fir.ptr<f32>>) -> !fir.box<none> |
| 171 | +! CHECK: fir.call @_FortranAPushDescriptor(%[[V_29]], %[[V_36]]) : (!fir.llvm_ptr<i8>, !fir.box<none>) -> () |
| 172 | +! CHECK: } |
| 173 | + |
| 174 | + end subroutine forallPointerAssignment1 |
0 commit comments