70 lines · plain
1! Test character_pointer => NULL()2! The main point is to check that non deferred length parameter is preserved3! inside the descriptor, and that the length is otherwise set to zero.4! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s5 6subroutine test_deferred(p)7 character(:), pointer :: p8 p => null()9end subroutine10subroutine test_cst(p)11 character(10), pointer :: p12 p => null()13end subroutine14subroutine test_explicit(p, n)15 integer(8) :: n16 character(n), pointer :: p17 p => null()18end subroutine19subroutine test_assumed(p)20 character(*), pointer :: p21 p => null()22end subroutine23subroutine test_deferred_comp(p)24 type t25 character(:), pointer :: p26 end type27 type(t) :: x28 x%p => null()29end subroutine30subroutine test_explicit_comp(p)31 type t32 character(10), pointer :: p33 end type34 type(t) :: x35 x%p => null()36end subroutine37 38! CHECK-LABEL: func.func @_QPtest_deferred(39! CHECK: %[[ZERO_BITS_0:.*]] = fir.zero_bits !fir.ptr<!fir.char<1,?>>40! CHECK: %[[CONSTANT_0:.*]] = arith.constant 0 : index41! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[ZERO_BITS_0]] typeparams %[[CONSTANT_0]] : (!fir.ptr<!fir.char<1,?>>, index) -> !fir.box<!fir.ptr<!fir.char<1,?>>>42 43! CHECK-LABEL: func.func @_QPtest_cst(44! CHECK: %[[ZERO_BITS_0:.*]] = fir.zero_bits !fir.ptr<!fir.char<1,10>>45! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[ZERO_BITS_0]] : (!fir.ptr<!fir.char<1,10>>) -> !fir.box<!fir.ptr<!fir.char<1,10>>>46 47! CHECK-LABEL: func.func @_QPtest_explicit(48! CHECK: %[[LOAD_0:.*]] = fir.load %{{.*}} : !fir.ref<i64>49! CHECK: %[[SELECT_0:.*]] = arith.select %{{.*}}, %[[LOAD_0]], %c0{{.*}} : i6450! CHECK: %[[ZERO_BITS_0:.*]] = fir.zero_bits !fir.ptr<!fir.char<1,?>>51! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[ZERO_BITS_0]] typeparams %[[SELECT_0]] : (!fir.ptr<!fir.char<1,?>>, i64) -> !fir.box<!fir.ptr<!fir.char<1,?>>>52 53! CHECK-LABEL: func.func @_QPtest_assumed(54! CHECK: %[[LOAD_0:.*]] = fir.load %[[ARG0:.*]] : !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>55! CHECK: %[[BOX_ELESIZE_0:.*]] = fir.box_elesize %[[LOAD_0]] : (!fir.box<!fir.ptr<!fir.char<1,?>>>) -> index56! CHECK: %[[DECLARE_0:.*]]:2 = hlfir.declare %[[ARG0]]57! CHECK: %[[ZERO_BITS_0:.*]] = fir.zero_bits !fir.ptr<!fir.char<1,?>>58! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[ZERO_BITS_0]] typeparams %[[BOX_ELESIZE_0]] : (!fir.ptr<!fir.char<1,?>>, index) -> !fir.box<!fir.ptr<!fir.char<1,?>>>59 60! CHECK-LABEL: func.func @_QPtest_deferred_comp(61! CHECK: %[[ZERO_BITS_0:.*]] = fir.zero_bits !fir.ptr<!fir.char<1,?>>62! CHECK: %[[CONSTANT_0:.*]] = arith.constant 0 : index63! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[ZERO_BITS_0]] typeparams %[[CONSTANT_0]] : (!fir.ptr<!fir.char<1,?>>, index) -> !fir.box<!fir.ptr<!fir.char<1,?>>>64! CHECK: fir.store %[[EMBOX_0]] to %{{.*}} : !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>65 66! CHECK-LABEL: func.func @_QPtest_explicit_comp(67! CHECK: %[[ZERO_BITS_0:.*]] = fir.zero_bits !fir.ptr<!fir.char<1,10>>68! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[ZERO_BITS_0]] : (!fir.ptr<!fir.char<1,10>>) -> !fir.box<!fir.ptr<!fir.char<1,10>>>69! CHECK: fir.store %[[EMBOX_0]] to %{{.*}} : !fir.ref<!fir.box<!fir.ptr<!fir.char<1,10>>>>70