52 lines · plain
1! Test lowering of nullify-statement2! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s3 4 5! -----------------------------------------------------------------------------6! Test NULLIFY(p)7! -----------------------------------------------------------------------------8 9 10! CHECK-LABEL: func @_QPtest_scalar(11! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<f32>>>{{.*}})12subroutine test_scalar(p)13 real, pointer :: p14 ! 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)18end subroutine19 20! CHECK-LABEL: func @_QPtest_scalar_char(21! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>{{.*}})22subroutine test_scalar_char(p)23 character(:), pointer :: p24 ! 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)28end subroutine29 30! CHECK-LABEL: func @_QPtest_array(31! CHECK-SAME: %[[p:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>{{.*}})32subroutine 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)39end subroutine40 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>>>>{{.*}})43subroutine 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>>>47 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)51end subroutine52