| 1 |
! RUN: bbc -hlfir=false %s -o - | FileCheck %s |
| 2 |
|
| 3 |
module components_test |
| 4 |
type t1 |
| 5 |
integer :: i(6) |
| 6 |
real :: r(5) |
| 7 |
end type t1 |
| 8 |
|
| 9 |
type t2 |
| 10 |
type(t1) :: g1(3,3), g2(4,4,4) |
| 11 |
integer :: g3(5) |
| 12 |
end type t2 |
| 13 |
|
| 14 |
type t3 |
| 15 |
type(t1) :: h1(3) |
| 16 |
type(t2) :: h2(4) |
| 17 |
end type t3 |
| 18 |
|
| 19 |
type(t3) :: instance |
| 20 |
|
| 21 |
contains |
| 22 |
|
| 23 |
! CHECK-LABEL: func @_QMcomponents_testPs1( |
| 24 |
subroutine s1(i,j) |
| 25 |
! CHECK-DAG: %[[VAL_0:.*]] = arith.constant 1 : i32 |
| 26 |
! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 6 : i32 |
| 27 |
! CHECK-DAG: %[[VAL_2:.*]] = arith.constant 0 : i64 |
| 28 |
! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 1 : i64 |
| 29 |
! CHECK-DAG: %[[VAL_4:.*]] = arith.constant 2 : i64 |
| 30 |
! CHECK: %[[VAL_5:.*]] = fir.address_of(@_QMcomponents_testEinstance) : !fir.ref<!fir.type<_QMcomponents_testTt3{h1:!fir.array<3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,h2:!fir.array<4x!fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}>>}>> |
| 31 |
! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_7:.*]] : !fir.ref<i32> |
| 32 |
! CHECK: %[[VAL_8:.*]] = arith.cmpi sge, %[[VAL_6]], %[[VAL_0]] : i32 |
| 33 |
! CHECK: %[[VAL_9:.*]] = arith.cmpi sle, %[[VAL_6]], %[[VAL_1]] : i32 |
| 34 |
! CHECK: %[[VAL_10:.*]] = arith.andi %[[VAL_8]], %[[VAL_9]] : i1 |
| 35 |
! CHECK: cond_br %[[VAL_10]], ^bb1, ^bb2 |
| 36 |
! CHECK: ^bb1: |
| 37 |
! CHECK: %[[VAL_11:.*]] = fir.field_index h2, !fir.type<_QMcomponents_testTt3{h1:!fir.array<3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,h2:!fir.array<4x!fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}>>}> |
| 38 |
! CHECK: %[[VAL_12:.*]] = fir.coordinate_of %[[VAL_5]], %[[VAL_11]] : (!fir.ref<!fir.type<_QMcomponents_testTt3{h1:!fir.array<3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,h2:!fir.array<4x!fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}>>}>>, !fir.field) -> !fir.ref<!fir.array<4x!fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}>>> |
| 39 |
! CHECK: %[[VAL_13:.*]] = fir.coordinate_of %[[VAL_12]], %[[VAL_3]] : (!fir.ref<!fir.array<4x!fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}>>>, i64) -> !fir.ref<!fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}>> |
| 40 |
! CHECK: %[[VAL_14:.*]] = fir.field_index g2, !fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}> |
| 41 |
! CHECK: %[[VAL_15:.*]] = fir.coordinate_of %[[VAL_13]], %[[VAL_14]] : (!fir.ref<!fir.type<_QMcomponents_testTt2{g1:!fir.array<3x3x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g2:!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>,g3:!fir.array<5xi32>}>>, !fir.field) -> !fir.ref<!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>> |
| 42 |
! CHECK: %[[VAL_16:.*]] = fir.coordinate_of %[[VAL_15]], %[[VAL_2]], %[[VAL_3]], %[[VAL_4]] : (!fir.ref<!fir.array<4x4x4x!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>>, i64, i64, i64) -> !fir.ref<!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>> |
| 43 |
! CHECK: %[[VAL_17:.*]] = fir.field_index i, !fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}> |
| 44 |
! CHECK: %[[VAL_18:.*]] = fir.coordinate_of %[[VAL_16]], %[[VAL_17]] : (!fir.ref<!fir.type<_QMcomponents_testTt1{i:!fir.array<6xi32>,r:!fir.array<5xf32>}>>, !fir.field) -> !fir.ref<!fir.array<6xi32>> |
| 45 |
! CHECK: %[[VAL_19:.*]] = fir.load %[[VAL_7]] : !fir.ref<i32> |
| 46 |
! CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_19]] : (i32) -> i64 |
| 47 |
! CHECK: %[[VAL_20_ADJ:.*]] = arith.subi %[[VAL_20]], %[[VAL_3]] : i64 |
| 48 |
! CHECK: %[[VAL_21:.*]] = fir.coordinate_of %[[VAL_18]], %[[VAL_20_ADJ]] : (!fir.ref<!fir.array<6xi32>>, i64) -> !fir.ref<i32> |
| 49 |
! CHECK: %[[VAL_22:.*]] = fir.load %[[VAL_21]] : !fir.ref<i32> |
| 50 |
! CHECK: fir.store %[[VAL_22]] to %[[VAL_23:.*]] : !fir.ref<i32> |
| 51 |
! CHECK: br ^bb2 |
| 52 |
! CHECK: ^bb2: |
| 53 |
! CHECK: return |
| 54 |
if (j >= 1 .and. j <= 6) then |
| 55 |
i = instance%h2(2)%g2(1,2,3)%i(j) |
| 56 |
end if |
| 57 |
end subroutine s1 |
| 58 |
|
| 59 |
end module components_test |
| 60 |
|
| 61 |
! CHECK-LABEL: func @_QPsliced_base() { |
| 62 |
! CHECK-DAG: %[[VAL_0:.*]] = arith.constant 50 : index |
| 63 |
! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 1 : index |
| 64 |
! CHECK-DAG: %[[VAL_2:.*]] = arith.constant 42 : i32 |
| 65 |
! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : index |
| 66 |
! CHECK-DAG: %[[VAL_4:.*]] = arith.constant 100 : index |
| 67 |
! CHECK: %[[VAL_5:.*]] = fir.alloca !fir.array<100x!fir.type<_QFsliced_baseTt{x:f32,y:i32}>> {bindc_name = "a", uniq_name = "_QFsliced_baseEa"} |
| 68 |
! CHECK: %[[VAL_6:.*]] = fir.field_index y, !fir.type<_QFsliced_baseTt{x:f32,y:i32}> |
| 69 |
! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1> |
| 70 |
! CHECK: %[[VAL_8:.*]] = fir.slice %[[VAL_1]], %[[VAL_0]], %[[VAL_1]] path %[[VAL_6]] : (index, index, index, !fir.field) -> !fir.slice<1> |
| 71 |
! CHECK: br ^bb1(%[[VAL_3]], %[[VAL_0]] : index, index) |
| 72 |
! CHECK: ^bb1(%[[VAL_9:.*]]: index, %[[VAL_10:.*]]: index): |
| 73 |
! CHECK: %[[VAL_11:.*]] = arith.cmpi sgt, %[[VAL_10]], %[[VAL_3]] : index |
| 74 |
! CHECK: cond_br %[[VAL_11]], ^bb2, ^bb3 |
| 75 |
! CHECK: ^bb2: |
| 76 |
! CHECK: %[[VAL_12:.*]] = arith.addi %[[VAL_9]], %[[VAL_1]] : index |
| 77 |
! CHECK: %[[VAL_13:.*]] = fir.array_coor %[[VAL_5]](%[[VAL_7]]) {{\[}}%[[VAL_8]]] %[[VAL_12]] : (!fir.ref<!fir.array<100x!fir.type<_QFsliced_baseTt{x:f32,y:i32}>>>, !fir.shape<1>, !fir.slice<1>, index) -> !fir.ref<i32> |
| 78 |
! CHECK: fir.store %[[VAL_2]] to %[[VAL_13]] : !fir.ref<i32> |
| 79 |
! CHECK: %[[VAL_14:.*]] = arith.subi %[[VAL_10]], %[[VAL_1]] : index |
| 80 |
! CHECK: br ^bb1(%[[VAL_12]], %[[VAL_14]] : index, index) |
| 81 |
! CHECK: ^bb3: |
| 82 |
! CHECK: %[[VAL_15:.*]] = fir.embox %[[VAL_5]](%[[VAL_7]]) {{\[}}%[[VAL_8]]] : (!fir.ref<!fir.array<100x!fir.type<_QFsliced_baseTt{x:f32,y:i32}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<50xi32>> |
| 83 |
! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_15]] : (!fir.box<!fir.array<50xi32>>) -> !fir.box<!fir.array<?xi32>> |
| 84 |
! CHECK: fir.call @_QPtakes_int_array(%[[VAL_16]]) {{.*}}: (!fir.box<!fir.array<?xi32>>) -> () |
| 85 |
! CHECK: return |
| 86 |
! CHECK: } |
| 87 |
|
| 88 |
subroutine sliced_base() |
| 89 |
interface |
| 90 |
subroutine takes_int_array(i) |
| 91 |
integer :: i(:) |
| 92 |
end subroutine |
| 93 |
end interface |
| 94 |
type t |
| 95 |
real :: x |
| 96 |
integer :: y |
| 97 |
end type |
| 98 |
type(t) :: a(100) |
| 99 |
a(1:50)%y = 42 |
| 100 |
call takes_int_array(a(1:50)%y) |
| 101 |
end subroutine |
| 102 |
|
| 103 |
! CHECK-LABEL: issue772 |
| 104 |
subroutine issue772(a, x) |
| 105 |
! Verify that sub-expressions inside a component reference are |
| 106 |
! only evaluated once. |
| 107 |
type t |
| 108 |
real :: b(100) |
| 109 |
end type |
| 110 |
real :: x(100) |
| 111 |
type(t) :: a(100) |
| 112 |
! CHECK: fir.call @_QPifoo() |
| 113 |
! CHECK-NOT: fir.call @_QPifoo() |
| 114 |
x = a(ifoo())%b(1:100:1) |
| 115 |
! CHECK: fir.call @_QPibar() |
| 116 |
! CHECK-NOT: fir.call @_QPibar() |
| 117 |
print *, a(20)%b(1:ibar():1) |
| 118 |
! CHECK return |
| 119 |
end subroutine |
| 120 |
|
| 121 |
! ----------------------------------------------------------------------------- |
| 122 |
! Test array%character array sections |
| 123 |
! ----------------------------------------------------------------------------- |
| 124 |
|
| 125 |
! CHECK-LABEL: func @_QPlhs_char_section( |
| 126 |
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x!fir.type<_QFlhs_char_sectionTt{c:!fir.char<1,5>}>>>{{.*}}) { |
| 127 |
subroutine lhs_char_section(a) |
| 128 |
! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 5 : index |
| 129 |
! CHECK-DAG: %[[VAL_2:.*]] = arith.constant false |
| 130 |
! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 10 : index |
| 131 |
! CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index |
| 132 |
! CHECK-DAG: %[[VAL_5:.*]] = arith.constant 1 : index |
| 133 |
! CHECK: %[[VAL_6:.*]] = fir.field_index c, !fir.type<_QFlhs_char_sectionTt{c:!fir.char<1,5>}> |
| 134 |
! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1> |
| 135 |
! CHECK: %[[VAL_8:.*]] = fir.slice %[[VAL_5]], %[[VAL_3]], %[[VAL_5]] path %[[VAL_6]] : (index, index, index, !fir.field) -> !fir.slice<1> |
| 136 |
! CHECK: %[[VAL_9:.*]] = fir.address_of(@_QQclX{{.*}}) : !fir.ref<!fir.char<1,5>> |
| 137 |
! CHECK: br ^bb1(%[[VAL_4]], %[[VAL_3]] : index, index) |
| 138 |
! CHECK: ^bb1(%[[VAL_10:.*]]: index, %[[VAL_11:.*]]: index): |
| 139 |
! CHECK: %[[VAL_12:.*]] = arith.cmpi sgt, %[[VAL_11]], %[[VAL_4]] : index |
| 140 |
! CHECK: cond_br %[[VAL_12]], ^bb2, ^bb3 |
| 141 |
! CHECK: ^bb2: |
| 142 |
! CHECK: %[[VAL_13:.*]] = arith.addi %[[VAL_10]], %[[VAL_5]] : index |
| 143 |
! CHECK: %[[VAL_14:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_7]]) {{\[}}%[[VAL_8]]] %[[VAL_13]] : (!fir.ref<!fir.array<10x!fir.type<_QFlhs_char_sectionTt{c:!fir.char<1,5>}>>>, !fir.shape<1>, !fir.slice<1>, index) -> !fir.ref<!fir.char<1,5>> |
| 144 |
! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_1]] : (index) -> i64 |
| 145 |
! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_14]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8> |
| 146 |
! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_9]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8> |
| 147 |
! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_16]], %[[VAL_17]], %[[VAL_15]], %[[VAL_2]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> () |
| 148 |
! CHECK: %[[VAL_18:.*]] = arith.subi %[[VAL_11]], %[[VAL_5]] : index |
| 149 |
! CHECK: br ^bb1(%[[VAL_13]], %[[VAL_18]] : index, index) |
| 150 |
|
| 151 |
type t |
| 152 |
character(5) :: c |
| 153 |
end type |
| 154 |
type(t) :: a(10) |
| 155 |
a%c = "hello" |
| 156 |
! CHECK: return |
| 157 |
! CHECK: } |
| 158 |
end subroutine |
| 159 |
|
| 160 |
! CHECK-LABEL: func @_QPrhs_char_section( |
| 161 |
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x!fir.type<_QFrhs_char_sectionTt{c:!fir.char<1,10>}>>>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}) { |
| 162 |
subroutine rhs_char_section(a, c) |
| 163 |
! CHECK-DAG: %[[VAL_2:.*]] = arith.constant false |
| 164 |
! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 10 : index |
| 165 |
! CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index |
| 166 |
! CHECK-DAG: %[[VAL_5:.*]] = arith.constant 1 : index |
| 167 |
! CHECK: %[[VAL_6:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index) |
| 168 |
! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,10>>> |
| 169 |
! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1> |
| 170 |
! CHECK: %[[VAL_9:.*]] = fir.field_index c, !fir.type<_QFrhs_char_sectionTt{c:!fir.char<1,10>}> |
| 171 |
! CHECK: %[[VAL_10:.*]] = fir.slice %[[VAL_5]], %[[VAL_3]], %[[VAL_5]] path %[[VAL_9]] : (index, index, index, !fir.field) -> !fir.slice<1> |
| 172 |
! CHECK: br ^bb1(%[[VAL_4]], %[[VAL_3]] : index, index) |
| 173 |
! CHECK: ^bb1(%[[VAL_11:.*]]: index, %[[VAL_12:.*]]: index): |
| 174 |
! CHECK: %[[VAL_13:.*]] = arith.cmpi sgt, %[[VAL_12]], %[[VAL_4]] : index |
| 175 |
! CHECK: cond_br %[[VAL_13]], ^bb2, ^bb3 |
| 176 |
! CHECK: ^bb2: |
| 177 |
! CHECK: %[[VAL_14:.*]] = arith.addi %[[VAL_11]], %[[VAL_5]] : index |
| 178 |
! CHECK: %[[VAL_15:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_8]]) {{\[}}%[[VAL_10]]] %[[VAL_14]] : (!fir.ref<!fir.array<10x!fir.type<_QFrhs_char_sectionTt{c:!fir.char<1,10>}>>>, !fir.shape<1>, !fir.slice<1>, index) -> !fir.ref<!fir.char<1,10>> |
| 179 |
! CHECK: %[[VAL_16:.*]] = fir.array_coor %[[VAL_7]](%[[VAL_8]]) %[[VAL_14]] : (!fir.ref<!fir.array<10x!fir.char<1,10>>>, !fir.shape<1>, index) -> !fir.ref<!fir.char<1,10>> |
| 180 |
! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_3]] : (index) -> i64 |
| 181 |
! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_16]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8> |
| 182 |
! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_15]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8> |
| 183 |
! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_18]], %[[VAL_19]], %[[VAL_17]], %[[VAL_2]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> () |
| 184 |
! CHECK: %[[VAL_20:.*]] = arith.subi %[[VAL_12]], %[[VAL_5]] : index |
| 185 |
! CHECK: br ^bb1(%[[VAL_14]], %[[VAL_20]] : index, index) |
| 186 |
|
| 187 |
type t |
| 188 |
character(10) :: c |
| 189 |
end type |
| 190 |
type(t) :: a(10) |
| 191 |
character(10) :: c(10) |
| 192 |
c = a%c |
| 193 |
! CHECK: return |
| 194 |
! CHECK: } |
| 195 |
end subroutine |
| 196 |
|
| 197 |
! CHECK-LABEL: func @_QPelemental_char_section( |
| 198 |
! CHECK-SAME: %[[A:.*]]: !fir.ref<!fir.array<{{.*}}>>{{.*}}, %[[I:.*]]: !fir.ref<!fir.array<10xi32>>{{.*}}) { |
| 199 |
subroutine elemental_char_section(a, i) |
| 200 |
type t |
| 201 |
character(10) :: c |
| 202 |
end type |
| 203 |
type(t) :: a(10) |
| 204 |
integer :: i(10) |
| 205 |
! CHECK-DAG: %[[VAL_34:.*]] = arith.constant 5 : index |
| 206 |
! CHECK-DAG: %[[VAL_35:.*]] = arith.constant false |
| 207 |
! CHECK-DAG: %[[VAL_36:.*]] = arith.constant 10 : index |
| 208 |
! CHECK-DAG: %[[VAL_37:.*]] = arith.constant 0 : index |
| 209 |
! CHECK-DAG: %[[VAL_38:.*]] = arith.constant 1 : index |
| 210 |
! CHECK: %[[VAL_39:.*]] = fir.shape %[[VAL_36]] : (index) -> !fir.shape<1> |
| 211 |
! CHECK: %[[VAL_40:.*]] = fir.field_index c, !fir.type<_QFelemental_char_sectionTt{c:!fir.char<1,10>}> |
| 212 |
! CHECK: %[[VAL_41:.*]] = fir.slice %[[VAL_38]], %[[VAL_36]], %[[VAL_38]] path %[[VAL_40]] : (index, index, index, !fir.field) -> !fir.slice<1> |
| 213 |
! CHECK: %[[VAL_42:.*]] = fir.address_of(@{{.*}}) : !fir.ref<!fir.char<1,5>> |
| 214 |
! CHECK: br ^bb1(%[[VAL_37]], %[[VAL_36]] : index, index) |
| 215 |
! CHECK:^bb1(%[[VAL_43:.*]]: index, %[[VAL_44:.*]]: index): |
| 216 |
! CHECK: %[[VAL_45:.*]] = arith.cmpi sgt, %[[VAL_44]], %[[VAL_37]] : index |
| 217 |
! CHECK: cond_br %[[VAL_45]], ^bb2, ^bb3 |
| 218 |
! CHECK:^bb2: |
| 219 |
! CHECK: %[[VAL_46:.*]] = arith.addi %[[VAL_43]], %[[VAL_38]] : index |
| 220 |
! CHECK: %[[VAL_47:.*]] = fir.array_coor %[[A]](%[[VAL_39]]) {{\[}}%[[VAL_41]]] %[[VAL_46]] : (!fir.ref<!fir.array<10x!fir.type<_QFelemental_char_sectionTt{c:!fir.char<1,10>}>>>, !fir.shape<1>, !fir.slice<1>, index) -> !fir.ref<!fir.char<1,10>> |
| 221 |
! CHECK: %[[VAL_49:.*]] = fir.convert %[[VAL_47]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8> |
| 222 |
! CHECK: %[[VAL_50:.*]] = fir.convert %[[VAL_36]] : (index) -> i64 |
| 223 |
! CHECK: %[[VAL_51:.*]] = fir.convert %[[VAL_42]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8> |
| 224 |
! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_34]] : (index) -> i64 |
| 225 |
! CHECK: %[[VAL_53:.*]] = fir.call @_FortranAScan1(%[[VAL_49]], %[[VAL_50]], %[[VAL_51]], %[[VAL_52]], %[[VAL_35]]) {{.*}}: (!fir.ref<i8>, i64, !fir.ref<i8>, i64, i1) -> i64 |
| 226 |
! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_53]] : (i64) -> i32 |
| 227 |
! CHECK: %[[VAL_55:.*]] = fir.array_coor %[[I]](%[[VAL_39]]) %[[VAL_46]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32> |
| 228 |
! CHECK: fir.store %[[VAL_54]] to %[[VAL_55]] : !fir.ref<i32> |
| 229 |
! CHECK: %[[VAL_57:.*]] = arith.subi %[[VAL_44]], %[[VAL_38]] : index |
| 230 |
! CHECK: br ^bb1(%[[VAL_46]], %[[VAL_57]] : index, index) |
| 231 |
i = scan(a%c, "hello") |
| 232 |
end subroutine |
| 233 |
|
| 234 |
! CHECK-LABEL: extended_type_components |
| 235 |
subroutine extended_type_components |
| 236 |
type t1 |
| 237 |
integer :: t1i = 1 |
| 238 |
end type t1 |
| 239 |
type, extends(t1) :: t2 |
| 240 |
integer :: t2i = 2 |
| 241 |
end type t2 |
| 242 |
type, extends(t2) :: t3 |
| 243 |
integer :: t3i = 3 |
| 244 |
end type t3 |
| 245 |
type, extends(t3) :: t4 |
| 246 |
integer :: t4i = 4 |
| 247 |
end type t4 |
| 248 |
|
| 249 |
type u1 |
| 250 |
integer :: u1i = 11 |
| 251 |
end type u1 |
| 252 |
type, extends(u1) :: u2 |
| 253 |
integer :: u2i = 22 |
| 254 |
type(t3) :: u2t3 |
| 255 |
type(t3) :: u2t4 |
| 256 |
end type u2 |
| 257 |
type, extends(u2) :: u3 |
| 258 |
integer :: u3i = 33 |
| 259 |
end type u3 |
| 260 |
|
| 261 |
! CHECK: %[[u3v:.*]] = fir.alloca !fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}> {bindc_name = "u3v", uniq_name = "_QFextended_type_componentsEu3v"} |
| 262 |
type(u3) :: u3v |
| 263 |
! CHECK: %[[u3va:.*]] = fir.alloca !fir.array<5x!fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>> {bindc_name = "u3va", uniq_name = "_QFextended_type_componentsEu3va"} |
| 264 |
type(u3) :: u3va(5) |
| 265 |
|
| 266 |
! CHECK: %[[VAL_10:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8> |
| 267 |
! CHECK: %[[VAL_11:.*]] = fir.field_index u2t3, !fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}> |
| 268 |
! CHECK: %[[VAL_12:.*]] = fir.field_index t1i, !fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}> |
| 269 |
! CHECK: %[[VAL_13:.*]] = fir.coordinate_of %[[u3v]], %[[VAL_11]], %[[VAL_12]] : (!fir.ref<!fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>>, !fir.field, !fir.field) -> !fir.ref<i32> |
| 270 |
! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_13]] : !fir.ref<i32> |
| 271 |
! CHECK: %[[VAL_15:.*]] = fir.call @_FortranAioOutputInteger32(%[[VAL_10]], %[[VAL_14]]) {{.*}}: (!fir.ref<i8>, i32) -> i1 |
| 272 |
print*, u3v%u2t3%t1i |
| 273 |
|
| 274 |
! CHECK: %[[VAL_20:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8> |
| 275 |
! CHECK: %[[VAL_21:.*]] = fir.load %[[VAL_13]] : !fir.ref<i32> |
| 276 |
! CHECK: %[[VAL_22:.*]] = fir.call @_FortranAioOutputInteger32(%[[VAL_20]], %[[VAL_21]]) {{.*}}: (!fir.ref<i8>, i32) -> i1 |
| 277 |
print*, u3v%u2%u2t3%t2%t1%t1i ! different syntax for the previous value |
| 278 |
|
| 279 |
! CHECK: %[[VAL_30:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8> |
| 280 |
! CHECK: %[[VAL_31:.*]] = fir.field_index u2t4, !fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}> |
| 281 |
! CHECK: %[[VAL_32:.*]] = fir.coordinate_of %[[u3v]], %[[VAL_31]], %[[VAL_12]] : (!fir.ref<!fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>>, !fir.field, !fir.field) -> !fir.ref<i32> |
| 282 |
! CHECK: %[[VAL_33:.*]] = fir.load %[[VAL_32]] : !fir.ref<i32> |
| 283 |
! CHECK: %[[VAL_34:.*]] = fir.call @_FortranAioOutputInteger32(%[[VAL_30]], %[[VAL_33]]) {{.*}}: (!fir.ref<i8>, i32) -> i1 |
| 284 |
print*, u3v%u2t4%t1i |
| 285 |
|
| 286 |
! CHECK: %[[VAL_40:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8> |
| 287 |
! CHECK: %[[VAL_41:.*]] = fir.field_index t2i, !fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}> |
| 288 |
! CHECK: %[[VAL_42:.*]] = fir.coordinate_of %[[u3v]], %[[VAL_31]], %[[VAL_41]] : (!fir.ref<!fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>>, !fir.field, !fir.field) -> !fir.ref<i32> |
| 289 |
! CHECK: %[[VAL_43:.*]] = fir.load %[[VAL_42]] : !fir.ref<i32> |
| 290 |
! CHECK: %[[VAL_44:.*]] = fir.call @_FortranAioOutputInteger32(%[[VAL_40]], %[[VAL_43]]) {{.*}}: (!fir.ref<i8>, i32) -> i1 |
| 291 |
print*, u3v%u2t4%t2i |
| 292 |
|
| 293 |
! CHECK: %[[VAL_50:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8> |
| 294 |
! CHECK: %[[VAL_51:.*]] = fir.slice %c1{{.*}}, %c5{{.*}}, %c1{{.*}} path %{{.*}}, %{{.*}} : (index, index, index, !fir.field, !fir.field) -> !fir.slice<1> |
| 295 |
! CHECK: %[[VAL_52:.*]] = fir.embox %[[u3va]](%{{.*}}) [%[[VAL_51]]] : (!fir.ref<!fir.array<5x!fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>>>, |
| 296 |
! CHECK: %[[VAL_53:.*]] = fir.convert %[[VAL_52]] : (!fir.box<!fir.array<5xi32>>) -> !fir.box<none> |
| 297 |
! CHECK: %[[VAL_54:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_50]], %[[VAL_53]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i1 |
| 298 |
print*, u3va%u2t3%t1i |
| 299 |
|
| 300 |
! CHECK: %[[VAL_60:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8> |
| 301 |
! CHECK: %[[VAL_61:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_60]], %[[VAL_53]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i1 |
| 302 |
print*, u3va%u2%u2t3%t2%t1%t1i ! different syntax for the previous value |
| 303 |
|
| 304 |
! CHECK: %[[VAL_70:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8> |
| 305 |
! CHECK: %[[VAL_71:.*]] = fir.slice %c1{{.*}}, %c5{{.*}}, %c1{{.*}} path %{{.*}}, %{{.*}} : (index, index, index, !fir.field, !fir.field) -> !fir.slice<1> |
| 306 |
! CHECK: %[[VAL_72:.*]] = fir.embox %[[u3va]](%{{.*}}) [%[[VAL_71]]] : (!fir.ref<!fir.array<5x!fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<5xi32>> |
| 307 |
! CHECK: %[[VAL_73:.*]] = fir.convert %[[VAL_72]] : (!fir.box<!fir.array<5xi32>>) -> !fir.box<none> |
| 308 |
! CHECK: %[[VAL_74:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_70]], %[[VAL_73]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i1 |
| 309 |
print*, u3va%u2t4%t1i |
| 310 |
|
| 311 |
! CHECK: %[[VAL_80:.*]] = fir.call @_FortranAioBeginExternalListOutput(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8> |
| 312 |
! CHECK: %[[VAL_81:.*]] = fir.slice %c1{{.*}}, %c5{{.*}}, %c1{{.*}} path %{{.*}}, %{{.*}} : (index, index, index, !fir.field, !fir.field) -> !fir.slice<1> |
| 313 |
! CHECK: %[[VAL_82:.*]] = fir.embox %[[u3va]](%{{.*}}) [%[[VAL_81]]] : (!fir.ref<!fir.array<5x!fir.type<_QFextended_type_componentsTu3{u1i:i32,u2i:i32,u2t3:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u2t4:!fir.type<_QFextended_type_componentsTt3{t1i:i32,t2i:i32,t3i:i32}>,u3i:i32}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<5xi32>> |
| 314 |
! CHECK: %[[VAL_83:.*]] = fir.convert %[[VAL_82]] : (!fir.box<!fir.array<5xi32>>) -> !fir.box<none> |
| 315 |
! CHECK: %[[VAL_84:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_80]], %[[VAL_83]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i1 |
| 316 |
print*, u3va%u2t4%t2i |
| 317 |
end subroutine extended_type_components |