| 1 |
! RUN: bbc -emit-hlfir %s -o - | FileCheck %s |
| 2 |
|
| 3 |
! CHECK-LABEL: func.func @_QPall_args( |
| 4 |
! CHECK-SAME: %[[commandArg:.*]]: !fir.boxchar<1> {fir.bindc_name = "command"}, |
| 5 |
! CHECK-SAME: %[[exitstatArg:.*]]: !fir.ref<i32> {fir.bindc_name = "exitstat"}) { |
| 6 |
subroutine all_args(command, exitstat) |
| 7 |
CHARACTER(*) :: command |
| 8 |
INTEGER :: exitstat |
| 9 |
call system(command, exitstat) |
| 10 |
! CHECK-NEXT: %[[cmdstatVal:.*]] = fir.alloca i16 |
| 11 |
! CHECK-NEXT: %[[DSCOPE:.*]] = fir.dummy_scope : !fir.dscope |
| 12 |
! CHECK-NEXT: %[[commandUnbox:.*]]:2 = fir.unboxchar %[[commandArg]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index) |
| 13 |
! CHECK-NEXT: %[[commandDeclare:.*]]:2 = hlfir.declare %[[commandUnbox]]#0 typeparams %[[commandUnbox]]#1 dummy_scope %[[DSCOPE]] {uniq_name = "_QFall_argsEcommand"} : (!fir.ref<!fir.char<1,?>>, index, !fir.dscope) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>) |
| 14 |
! CHECK-NEXT: %[[exitstatDeclare:.*]]:2 = hlfir.declare %[[exitstatArg]] dummy_scope %[[DSCOPE]] {uniq_name = "_QFall_argsEexitstat"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 15 |
! CHECK-NEXT: %[[commandBox:.*]] = fir.embox %[[commandDeclare]]#1 typeparams %[[commandUnbox]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.box<!fir.char<1,?>> |
| 16 |
! CHECK-NEXT: %[[exitstatBox:.*]] = fir.embox %[[exitstatDeclare]]#1 : (!fir.ref<i32>) -> !fir.box<i32> |
| 17 |
! CHECK-NEXT: %[[true:.*]] = arith.constant true |
| 18 |
! CHECK-NEXT: %[[c0_i16:.*]] = arith.constant 0 : i16 |
| 19 |
! CHECK-NEXT: fir.store %[[c0_i16]] to %[[cmdstatVal]] : !fir.ref<i16> |
| 20 |
! CHECK-NEXT: %[[cmdstatBox:.*]] = fir.embox %[[cmdstatVal]] : (!fir.ref<i16>) -> !fir.box<i16> |
| 21 |
! CHECK-NEXT: %[[absentBox:.*]] = fir.absent !fir.box<none> |
| 22 |
! CHECK: %[[c9_i32:.*]] = arith.constant 9 : i32 |
| 23 |
! CHECK-NEXT: %[[command:.*]] = fir.convert %[[commandBox]] : (!fir.box<!fir.char<1,?>>) -> !fir.box<none> |
| 24 |
! CHECK-NEXT: %[[exitstat:.*]] = fir.convert %[[exitstatBox]] : (!fir.box<i32>) -> !fir.box<none> |
| 25 |
! CHECK-NEXT: %[[cmdstat:.*]] = fir.convert %[[cmdstatBox]] : (!fir.box<i16>) -> !fir.box<none> |
| 26 |
! CHECK: %[[VAL_13:.*]] = fir.call @_FortranAExecuteCommandLine(%[[command]], %[[true]], %[[exitstat]], %[[cmdstat]], %[[absentBox]], %[[VAL_12:.*]], %[[c9_i32]]) fastmath<contract> : (!fir.box<none>, i1, !fir.box<none>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> none |
| 27 |
! CHECK-NEXT: return |
| 28 |
! CHECK-NEXT: } |
| 29 |
end subroutine all_args |
| 30 |
|
| 31 |
! CHECK-LABEL: func.func @_QPonly_command( |
| 32 |
! CHECK-SAME: %[[commandArg:.*]]: !fir.boxchar<1> {fir.bindc_name = "command"}) { |
| 33 |
subroutine only_command(command) |
| 34 |
CHARACTER(*) :: command |
| 35 |
call system(command) |
| 36 |
! CHECK-NEXT: %[[cmdstatVal:.*]] = fir.alloca i16 |
| 37 |
! CHECK-NEXT: %[[DSCOPE:.*]] = fir.dummy_scope : !fir.dscope |
| 38 |
! CHECK-NEXT: %[[commandUnbox:.*]]:2 = fir.unboxchar %arg0 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index) |
| 39 |
! CHECK-NEXT: %[[commandDeclare:.*]]:2 = hlfir.declare %[[commandUnbox]]#0 typeparams %[[commandUnbox]]#1 dummy_scope %[[DSCOPE]] {uniq_name = "_QFonly_commandEcommand"} : (!fir.ref<!fir.char<1,?>>, index, !fir.dscope) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>) |
| 40 |
! CHECK-NEXT: %[[commandBox:.*]] = fir.embox %[[commandDeclare]]#1 typeparams %[[commandUnbox]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.box<!fir.char<1,?>> |
| 41 |
! CHECK-NEXT: %[[true:.*]] = arith.constant true |
| 42 |
! CHECK-NEXT: %[[absentBox:.*]] = fir.absent !fir.box<none> |
| 43 |
! CHECK-NEXT: %[[c0_i16:.*]] = arith.constant 0 : i16 |
| 44 |
! CHECK-NEXT: fir.store %[[c0_i16]] to %[[cmdstatVal]] : !fir.ref<i16> |
| 45 |
! CHECK-NEXT: %[[cmdstatBox:.*]] = fir.embox %[[cmdstatVal]] : (!fir.ref<i16>) -> !fir.box<i16> |
| 46 |
! CHECK-NEXT: %[[absentBox2:.*]] = fir.absent !fir.box<none> |
| 47 |
! CHECK: %[[c35_i32:.*]] = arith.constant {{[0-9]+}} : i32 |
| 48 |
! CHECK-NEXT: %[[command:.*]] = fir.convert %[[commandBox]] : (!fir.box<!fir.char<1,?>>) -> !fir.box<none> |
| 49 |
! CHECK-NEXT: %[[cmdstat:.*]] = fir.convert %[[cmdstatBox]] : (!fir.box<i16>) -> !fir.box<none> |
| 50 |
! CHECK: %[[VAL_12:.*]] = fir.call @_FortranAExecuteCommandLine(%[[command]], %[[true]], %[[absentBox]], %[[cmdstat]], %[[absentBox2]], %[[VAL_11:.*]], %[[c35_i32]]) fastmath<contract> : (!fir.box<none>, i1, !fir.box<none>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> none |
| 51 |
! CHECK-NEXT: return |
| 52 |
! CHECK-NEXT: } |
| 53 |
end subroutine only_command |