| 1 |
! Note: flang will issue warnings for the following subroutines. These |
| 2 |
! are accepted regardless to maintain backwards compatibility with |
| 3 |
! other Fortran implementations. |
| 4 |
|
| 5 |
! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s |
| 6 |
|
| 7 |
! CHECK-LABEL: func @_QPs1() { |
| 8 |
! CHECK: %[[cast:.*]] = fir.convert %{{.*}} : (!fir.ref<f32>) -> !fir.ref<!fir.char<1,?>> |
| 9 |
! CHECK: %[[undef:.*]] = fir.undefined index |
| 10 |
! CHECK: %[[box:.*]] = fir.emboxchar %[[cast]], %[[undef]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1> |
| 11 |
! CHECK: fir.call @_QPs3(%[[box]]) {{.*}}: (!fir.boxchar<1>) -> () |
| 12 |
|
| 13 |
! Pass a REAL by reference to a subroutine expecting a CHARACTER |
| 14 |
subroutine s1 |
| 15 |
call s3(r) |
| 16 |
end subroutine s1 |
| 17 |
|
| 18 |
! CHECK-LABEL: func @_QPs2( |
| 19 |
! CHECK: %[[ptr:.*]] = fir.box_addr %{{.*}} : (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32> |
| 20 |
! CHECK: %[[cast:.*]] = fir.convert %[[ptr]] : (!fir.ptr<f32>) -> !fir.ref<!fir.char<1,?>> |
| 21 |
! CHECK: %[[undef:.*]] = fir.undefined index |
| 22 |
! CHECK: %[[box:.*]] = fir.emboxchar %[[cast]], %[[undef]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1> |
| 23 |
! CHECK: fir.call @_QPs3(%[[box]]) {{.*}}: (!fir.boxchar<1>) -> () |
| 24 |
|
| 25 |
! Pass a REAL, POINTER data reference to a subroutine expecting a CHARACTER |
| 26 |
subroutine s2(p) |
| 27 |
real, pointer :: p |
| 28 |
call s3(p) |
| 29 |
end subroutine s2 |
| 30 |
|
| 31 |
! CHECK-LABEL: func @_QPs3( |
| 32 |
! CHECK-SAME: !fir.boxchar<1> |
| 33 |
subroutine s3(c) |
| 34 |
character(8) c |
| 35 |
end subroutine s3 |