Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / nullify.f90
bloba192dc64e84e4940cf7e6470dfb9797c4d41f385
1 ! Test lowering of nullify-statement
2 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
5 ! -----------------------------------------------------------------------------
6 ! Test NULLIFY(p)
7 ! -----------------------------------------------------------------------------
10 ! CHECK-LABEL: func @_QPtest_scalar(
11 ! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<f32>>>{{.*}})
12 subroutine test_scalar(p)
13 real, pointer :: p
14 ! CHECK: %[[null:.*]] = fir.zero_bits !fir.ptr<f32>
15 ! CHECK: %[[box:.*]] = fir.embox %[[null]] : (!fir.ptr<f32>) -> !fir.box<!fir.ptr<f32>>
16 ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<f32>>>
17 nullify(p)
18 end subroutine
20 ! CHECK-LABEL: func @_QPtest_scalar_char(
21 ! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>{{.*}})
22 subroutine test_scalar_char(p)
23 character(:), pointer :: p
24 ! CHECK: %[[null:.*]] = fir.zero_bits !fir.ptr<!fir.char<1,?>>
25 ! CHECK: %[[box:.*]] = fir.embox %[[null]] typeparams %c0{{.*}} : (!fir.ptr<!fir.char<1,?>>, index) -> !fir.box<!fir.ptr<!fir.char<1,?>>>
26 ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>
27 nullify(p)
28 end subroutine
30 ! CHECK-LABEL: func @_QPtest_array(
31 ! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>{{.*}})
32 subroutine test_array(p)
33 real, pointer :: p(:)
34 ! CHECK: %[[null:.*]] = fir.zero_bits !fir.ptr<!fir.array<?xf32>>
35 ! CHECK: %[[shape:.*]] = fir.shape %c0{{.*}}
36 ! CHECK: %[[box:.*]] = fir.embox %[[null]](%[[shape]]) : (!fir.ptr<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.box<!fir.ptr<!fir.array<?xf32>>>
37 ! CHECK: fir.store %[[box]] to %[[p]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
38 nullify(p)
39 end subroutine
41 ! CHECK-LABEL: func @_QPtest_list(
42 ! CHECK-SAME: %[[p1:.*]]: !fir.ref<!fir.box<!fir.ptr<f32>>>{{.*}}, %[[p2:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>{{.*}})
43 subroutine test_list(p1, p2)
44 real, pointer :: p1, p2(:)
45 ! CHECK: fir.zero_bits !fir.ptr<f32>
46 ! CHECK: fir.store %{{.*}} to %[[p1]] : !fir.ref<!fir.box<!fir.ptr<f32>>>
48 ! CHECK: fir.zero_bits !fir.ptr<!fir.array<?xf32>>
49 ! CHECK: fir.store %{{.*}} to %[[p2]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
50 nullify(p1, p2)
51 end subroutine