! Test lowering of NULL(MOLD) to HLFIR. ! RUN: bbc -emit-hlfir -o - %s | FileCheck %s subroutine test1(mold) integer, pointer :: mold(:) interface subroutine takes_ptr(p) integer, pointer :: p(:) end subroutine end interface call takes_ptr(null(mold)) end subroutine ! CHECK-LABEL: func.func @_QPtest1( ! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box>> ! CHECK: %[[VAL_3:.*]] = fir.zero_bits !fir.ptr> ! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index ! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1> ! CHECK: %[[VAL_6:.*]] = fir.embox %[[VAL_3]](%[[VAL_5]]) : (!fir.ptr>, !fir.shape<1>) -> !fir.box>> ! CHECK: fir.store %[[VAL_6]] to %[[VAL_1]] : !fir.ref>>> ! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_1]] {uniq_name = ".tmp.intrinsic_result"} : (!fir.ref>>>) -> (!fir.ref>>>, !fir.ref>>>) ! CHECK: fir.call @_QPtakes_ptr(%[[VAL_7]]#0) fastmath : (!fir.ref>>>) -> () subroutine test2 integer, pointer :: i logical :: l l = associated(null(),i) end subroutine test2 ! CHECK-LABEL: func.func @_QPtest2() { ! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.box> ! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box> {bindc_name = "i", uniq_name = "_QFtest2Ei"} ! CHECK: %[[VAL_2:.*]] = fir.zero_bits !fir.ptr ! CHECK: %[[VAL_3:.*]] = fir.embox %[[VAL_2]] : (!fir.ptr) -> !fir.box> ! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref>> ! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_1]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFtest2Ei"} : (!fir.ref>>) -> (!fir.ref>>, !fir.ref>>) ! CHECK: %[[VAL_5:.*]] = fir.alloca !fir.logical<4> {bindc_name = "l", uniq_name = "_QFtest2El"} ! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_5]] {uniq_name = "_QFtest2El"} : (!fir.ref>) -> (!fir.ref>, !fir.ref>) ! CHECK: %[[VAL_7:.*]] = fir.zero_bits !fir.ptr ! CHECK: %[[VAL_8:.*]] = fir.embox %[[VAL_7]] : (!fir.ptr) -> !fir.box> ! CHECK: fir.store %[[VAL_8]] to %[[VAL_0]] : !fir.ref>> ! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = ".tmp.null_box"} : (!fir.ref>>) -> (!fir.ref>>, !fir.ref>>) ! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_4]]#1 : !fir.ref>> ! CHECK: %[[VAL_11:.*]] = fir.load %[[VAL_9]]#1 : !fir.ref>> ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (!fir.box>) -> !fir.box ! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_10]] : (!fir.box>) -> !fir.box ! CHECK: %[[VAL_14:.*]] = fir.call @_FortranAPointerIsAssociatedWith(%[[VAL_12]], %[[VAL_13]]) fastmath : (!fir.box, !fir.box) -> i1 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (i1) -> !fir.logical<4> ! CHECK: hlfir.assign %[[VAL_15]] to %[[VAL_6]]#0 : !fir.logical<4>, !fir.ref> ! CHECK: return ! CHECK: }