|
| 1 | +! Test passing character array to unlimited polymorphic array pointer. |
| 2 | +! Regression test from https://github.com/llvm/llvm-project/issues/150749 |
| 3 | + |
| 4 | +! RUN: bbc -emit-hlfir -o - %s | FileCheck %s |
| 5 | + |
| 6 | +subroutine char_explicit_shape_array(a2) |
| 7 | +interface |
| 8 | +subroutine char_explicit_shape_array_uclass_callee(p) |
| 9 | + class(*), pointer, intent(in) :: p(:) |
| 10 | +end subroutine char_explicit_shape_array_uclass_callee |
| 11 | +end interface |
| 12 | +character(*), target :: a2(100) |
| 13 | +call char_explicit_shape_array_uclass_callee(a2) |
| 14 | +end subroutine char_explicit_shape_array |
| 15 | +! CHECK-LABEL: func.func @_QPchar_explicit_shape_array( |
| 16 | +! CHECK-SAME: %[[ARG0:.*]]: !fir.boxchar<1> {fir.bindc_name = "a2", fir.target}) { |
| 17 | +! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.class<!fir.ptr<!fir.array<?xnone>>> |
| 18 | +! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope |
| 19 | +! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[ARG0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index) |
| 20 | +! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,?>>> |
| 21 | +! CHECK: %[[VAL_4:.*]] = arith.constant 100 : index |
| 22 | +! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1> |
| 23 | +! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_3]](%[[VAL_5]]) typeparams %[[VAL_2]]#1 dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFchar_explicit_shape_arrayEa2"} : (!fir.ref<!fir.array<100x!fir.char<1,?>>>, !fir.shape<1>, index, !fir.dscope) -> (!fir.box<!fir.array<100x!fir.char<1,?>>>, !fir.ref<!fir.array<100x!fir.char<1,?>>>) |
| 24 | +! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1> |
| 25 | +! CHECK: %[[VAL_8:.*]] = fir.embox %[[VAL_6]]#1(%[[VAL_7]]) typeparams %[[VAL_2]]#1 : (!fir.ref<!fir.array<100x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.class<!fir.ptr<!fir.array<?xnone>>> |
| 26 | +! CHECK: fir.store %[[VAL_8]] to %[[VAL_0]] : !fir.ref<!fir.class<!fir.ptr<!fir.array<?xnone>>>> |
| 27 | +! CHECK: fir.call @_QPchar_explicit_shape_array_uclass_callee(%[[VAL_0]]) fastmath<contract> : (!fir.ref<!fir.class<!fir.ptr<!fir.array<?xnone>>>>) -> () |
| 28 | +! CHECK: return |
| 29 | +! CHECK: } |
0 commit comments