|
| 1 | +! RUN: bbc -emit-hlfir %s -o - | FileCheck %s |
| 2 | + |
| 3 | +subroutine test_chdir() |
| 4 | + implicit none |
| 5 | +! CHECK-LABEL: func.func @_QPtest_chdir() { |
| 6 | + |
| 7 | + call chdir("..") |
| 8 | +! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QQclX2E2E) : !fir.ref<!fir.char<1,2>> |
| 9 | +! CHECK: %[[C_2:.*]] = arith.constant 2 : index |
| 10 | +! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[C_2]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQclX2E2E"} : (!fir.ref<!fir.char<1,2>>, index) -> (!fir.ref<!fir.char<1,2>>, !fir.ref<!fir.char<1,2>>) |
| 11 | +! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]]#1 : (!fir.ref<!fir.char<1,2>>) -> !fir.ref<i8> |
| 12 | +! CHECK: %[[VAL_3:.*]] = fir.call @_FortranAChdir(%[[VAL_2]]) fastmath<contract> : (!fir.ref<i8>) -> i32 |
| 13 | +end subroutine |
| 14 | + |
| 15 | +subroutine test_chdir_subroutine_status_i4() |
| 16 | + implicit none |
| 17 | + integer(4) :: stat |
| 18 | +! CHECK-LABEL: func.func @_QPtest_chdir_subroutine_status_i4() { |
| 19 | + |
| 20 | + call chdir("..", STATUS=stat) |
| 21 | +! CHECK: %[[VAL_0:.*]] = fir.alloca i32 {bindc_name = "stat", uniq_name = "_QFtest_chdir_subroutine_status_i4Estat"} |
| 22 | +! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFtest_chdir_subroutine_status_i4Estat"} : (!fir.ref<i32>) -> |
| 23 | +! (!fir.ref<i32>, !fir.ref<i32>) |
| 24 | +! CHECK: %[[VAL_2:.*]] = fir.address_of(@_QQclX2E2E) : !fir.ref<!fir.char<1,2>> |
| 25 | +! CHECK: %[[C_2:.*]] = arith.constant 2 : index |
| 26 | +! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] typeparams %[[C_2]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = {{.*}} : (!fir.ref<!fir.char<1,2>>, index) -> (!fir.ref<!fir.char<1,2>>, !fir.ref<!fir.char<1,2>>) |
| 27 | +! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]]#1 : (!fir.ref<!fir.char<1,2>>) -> !fir.ref<i8> |
| 28 | +! CHECK: %[[VAL_5:.*]] = fir.call @_FortranAChdir(%[[VAL_4]]) fastmath<contract> : (!fir.ref<i8>) -> i32 |
| 29 | +! CHECK: %[[VAL_6:.*]] = fir.convert %{{.*}} : (!fir.ref<i32>) -> i64 |
| 30 | +! CHECK: %[[C_0_I64:.*]] = arith.constant 0 : i64 |
| 31 | +! CHECK: %[[VAL_7:.*]] = arith.cmpi ne, %[[VAL_6]], %[[C_0_I64]] : i64 |
| 32 | +! CHECK: fir.if %[[VAL_7]] { |
| 33 | +! CHECK: fir.store %[[VAL_5]] to %[[VAL_1]]#1 : !fir.ref<i32> |
| 34 | +! CHECK: } |
| 35 | +end subroutine |
| 36 | + |
| 37 | +subroutine test_chdir_function_status_i4() |
| 38 | + implicit none |
| 39 | + integer(4) :: stat |
| 40 | +! CHECK-LABEL: func.func @_QPtest_chdir_function_status_i4() { |
| 41 | + |
| 42 | + stat = chdir("..") |
| 43 | +! CHECK: %[[VAL_0:.*]] = fir.alloca i32 {bindc_name = "stat", uniq_name = "_QFtest_chdir_function_status_i4Estat"} |
| 44 | +! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFtest_chdir_function_status_i4Estat"} : (!fir.ref<i32>) -> |
| 45 | +! (!fir.ref<i32>, !fir.ref<i32>) |
| 46 | +! CHECK: %[[VAL_2:.*]] = fir.address_of(@_QQclX2E2E) : !fir.ref<!fir.char<1,2>> |
| 47 | +! CHECK: %[[C_2:.*]] = arith.constant 2 : index |
| 48 | +! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] typeparams %[[C_2]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = {{.*}} : (!fir.ref<!fir.char<1,2>>, index) -> (!fir.ref<!fir.char<1,2>>, !fir.ref<!fir.char<1,2>>) |
| 49 | +! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]]#1 : (!fir.ref<!fir.char<1,2>>) -> !fir.ref<i8> |
| 50 | +! CHECK: %[[VAL_5:.*]] = fir.call @_FortranAChdir(%[[VAL_4]]) fastmath<contract> : (!fir.ref<i8>) -> i32 |
| 51 | +! CHECK: hlfir.assign %[[VAL_5]] to %[[VAL_1]]#0 : i32, !fir.ref<i32> |
| 52 | +end subroutine |
| 53 | + |
| 54 | +subroutine test_chdir_subroutine_status_i8() |
| 55 | + implicit none |
| 56 | + integer(8) :: stat |
| 57 | +! CHECK-LABEL: func.func @_QPtest_chdir_subroutine_status_i8() { |
| 58 | + |
| 59 | + call chdir("..", STATUS=stat) |
| 60 | +! CHECK: %[[VAL_0:.*]] = fir.alloca i64 {bindc_name = "stat", uniq_name = "_QFtest_chdir_subroutine_status_i8Estat"} |
| 61 | +! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFtest_chdir_subroutine_status_i8Estat"} : (!fir.ref<i64>) -> |
| 62 | +! (!fir.ref<i64>, !fir.ref<i64>) |
| 63 | +! CHECK: %[[VAL_2:.*]] = fir.address_of(@_QQclX2E2E) : !fir.ref<!fir.char<1,2>> |
| 64 | +! CHECK: %[[C_2:.*]] = arith.constant 2 : index |
| 65 | +! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] typeparams %[[C_2]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = {{.*}} : (!fir.ref<!fir.char<1,2>>, index) -> (!fir.ref<!fir.char<1,2>>, !fir.ref<!fir.char<1,2>>) |
| 66 | +! CHECK: %[[VAL_4:.*]] = fir.convert %{{.*}} : (!fir.ref<!fir.char<1,2>>) -> !fir.ref<i8> |
| 67 | +! CHECK: %[[VAL_5:.*]] = fir.call @_FortranAChdir(%[[VAL_4]]) fastmath<contract> : (!fir.ref<i8>) -> i32 |
| 68 | +! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_1]]#1 : (!fir.ref<i64>) -> i64 |
| 69 | +! CHECK: %[[C_0_I64:.*]] = arith.constant 0 : i64 |
| 70 | +! CHECK: %[[VAL_7:.*]] = arith.cmpi ne, %[[VAL_6]], %[[C_0_I64]] : i64 |
| 71 | +! CHECK: fir.if %[[VAL_7]] { |
| 72 | +! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_5]] : (i32) -> i64 |
| 73 | +! CHECK: fir.store %[[VAL_8]] to %[[VAL_1]]#1 : !fir.ref<i64> |
| 74 | +! CHECK: } |
| 75 | +end subroutine |
| 76 | + |
| 77 | +subroutine test_chdir_function_status_i8() |
| 78 | + implicit none |
| 79 | + integer(8) :: stat |
| 80 | +! CHECK-LABEL: func.func @_QPtest_chdir_function_status_i8() { |
| 81 | + |
| 82 | + stat = chdir("..") |
| 83 | +! CHECK: %[[VAL_0:.*]] = fir.alloca i64 {bindc_name = "stat", uniq_name = "_QFtest_chdir_function_status_i8Estat"} |
| 84 | +! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFtest_chdir_function_status_i8Estat"} : (!fir.ref<i64>) -> |
| 85 | +! (!fir.ref<i64>, !fir.ref<i64>) |
| 86 | +! CHECK: %[[VAL_2:.*]] = fir.address_of(@_QQclX2E2E) : !fir.ref<!fir.char<1,2>> |
| 87 | +! CHECK: %[[C_2:.*]] = arith.constant 2 : index |
| 88 | +! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] typeparams %[[C_2]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = {{.*}} : (!fir.ref<!fir.char<1,2>>, index) -> (!fir.ref<!fir.char<1,2>>, !fir.ref<!fir.char<1,2>>) |
| 89 | +! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]]#1 : (!fir.ref<!fir.char<1,2>>) -> !fir.ref<i8> |
| 90 | +! CHECK: %[[VAL_5:.*]] = fir.call @_FortranAChdir(%[[VAL_4]]) fastmath<contract> : (!fir.ref<i8>) -> i32 |
| 91 | +! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i32) -> i64 |
| 92 | +! CHECK: hlfir.assign %[[VAL_6]] to %[[VAL_1]]#0 : i64, !fir.ref<i64> |
| 93 | +end subroutine |
| 94 | + |
0 commit comments