@@ -32,6 +32,23 @@ subroutine test_with_attrs(x)
32
32
real , target , optional :: x(..)
33
33
call takes_real(x)
34
34
end subroutine
35
+
36
+ subroutine test_simple_allocatable (x )
37
+ real , allocatable :: x(..)
38
+ end subroutine
39
+
40
+ subroutine test_simple_pointer (x )
41
+ real , pointer :: x(..)
42
+ end subroutine
43
+
44
+ subroutine test_intentout (x )
45
+ real , intent (out ), allocatable :: x(..)
46
+ end subroutine
47
+
48
+ subroutine test_assumed_length_alloc (x )
49
+ character (* ), allocatable :: x(..)
50
+ end subroutine
51
+
35
52
! CHECK-LABEL: func.func @_QMassumed_rank_testsPtest_intrinsic(
36
53
! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x"}) {
37
54
! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
@@ -67,4 +84,45 @@ subroutine test_with_attrs(x)
67
84
! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
68
85
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<optional, target>, uniq_name = "_QMassumed_rank_testsFtest_with_attrsEx"} : (!fir.box<!fir.array<*:f32>>, !fir.dscope) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
69
86
! CHECK: fir.call @_QPtakes_real(%[[VAL_2]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
87
+
88
+ ! CHECK-LABEL: func.func @_QMassumed_rank_testsPtest_simple_allocatable(
89
+ ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>> {fir.bindc_name = "x"}) {
90
+ ! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
91
+ ! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMassumed_rank_testsFtest_simple_allocatableEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>)
92
+ ! CHECK: return
93
+ ! CHECK: }
94
+
95
+ ! CHECK-LABEL: func.func @_QMassumed_rank_testsPtest_simple_pointer(
96
+ ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<*:f32>>>> {fir.bindc_name = "x"}) {
97
+ ! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
98
+ ! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QMassumed_rank_testsFtest_simple_pointerEx"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<*:f32>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.ptr<!fir.array<*:f32>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<*:f32>>>>)
99
+ ! CHECK: return
100
+ ! CHECK: }
101
+
102
+ ! CHECK-LABEL: func.func @_QMassumed_rank_testsPtest_intentout(
103
+ ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>> {fir.bindc_name = "x"}) {
104
+ ! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
105
+ ! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<allocatable, intent_out>, uniq_name = "_QMassumed_rank_testsFtest_intentoutEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>)
106
+ ! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_2]]#1 : !fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>
107
+ ! CHECK: %[[VAL_4:.*]] = fir.box_addr %[[VAL_3]] : (!fir.box<!fir.heap<!fir.array<*:f32>>>) -> !fir.heap<!fir.array<*:f32>>
108
+ ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.heap<!fir.array<*:f32>>) -> i64
109
+ ! CHECK: %[[VAL_6:.*]] = arith.constant 0 : i64
110
+ ! CHECK: %[[VAL_7:.*]] = arith.cmpi ne, %[[VAL_5]], %[[VAL_6]] : i64
111
+ ! CHECK: fir.if %[[VAL_7]] {
112
+ ! CHECK: %[[VAL_8:.*]] = arith.constant false
113
+ ! CHECK: %[[VAL_9:.*]] = fir.absent !fir.box<none>
114
+ ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_2]]#1 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>) -> !fir.ref<!fir.box<none>>
115
+ ! CHECK: %[[VAL_14:.*]] = fir.call @_FortranAAllocatableDeallocate(%[[VAL_12]], %[[VAL_8]], %[[VAL_9]], %{{.*}}, %{{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32
116
+ ! CHECK: }
117
+ ! CHECK: return
118
+ ! CHECK: }
119
+
120
+ ! CHECK-LABEL: func.func @_QMassumed_rank_testsPtest_assumed_length_alloc(
121
+ ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>> {fir.bindc_name = "x"}) {
122
+ ! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
123
+ ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>
124
+ ! CHECK: %[[VAL_3:.*]] = fir.box_elesize %[[VAL_2]] : (!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>) -> index
125
+ ! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_3]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMassumed_rank_testsFtest_assumed_length_allocEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>, index, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>)
126
+ ! CHECK: return
127
+ ! CHECK: }
70
128
end module
0 commit comments