| 1 |
! RUN: bbc -emit-hlfir %s -o - | FileCheck %s |
| 2 |
|
| 3 |
! Check that the lowering does not generate fir.box_addr for |
| 4 |
! the optional box. It will cause segfault during execution. |
| 5 |
|
| 6 |
! CHECK-LABEL: func.func @_QPtest( |
| 7 |
! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "ext_buf", fir.contiguous, fir.optional}) { |
| 8 |
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} {fortran_attrs = #fir.var_attrs<contiguous, optional>, uniq_name = "_QFtestEext_buf"} : (!fir.box<!fir.array<?xi32>>, !fir.dscope) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>) |
| 9 |
! CHECK: %[[VAL_2:.*]] = fir.is_present %[[VAL_1]]#1 : (!fir.box<!fir.array<?xi32>>) -> i1 |
| 10 |
! CHECK: cf.cond_br %[[VAL_2]], ^bb1, ^bb2 |
| 11 |
! CHECK: ^bb1: |
| 12 |
! CHECK: %[[VAL_3:.*]] = arith.constant 0 : i32 |
| 13 |
! CHECK: %[[VAL_4:.*]] = arith.constant false |
| 14 |
! CHECK: %[[VAL_5:.*]] = arith.constant false |
| 15 |
! CHECK: %[[VAL_6:.*]] = fir.call @_FortranAStopStatement(%[[VAL_3]], %[[VAL_4]], %[[VAL_5]]) fastmath<contract> : (i32, i1, i1) -> none |
| 16 |
! CHECK: fir.unreachable |
| 17 |
! CHECK: ^bb2: |
| 18 |
! CHECK: cf.br ^bb3 |
| 19 |
! CHECK: ^bb3: |
| 20 |
! CHECK: return |
| 21 |
! CHECK: } |
| 22 |
subroutine test(ext_buf) |
| 23 |
integer, contiguous, optional :: ext_buf(:) |
| 24 |
if (present(ext_buf)) then |
| 25 |
stop |
| 26 |
endif |
| 27 |
return |
| 28 |
end subroutine test |