1 ! RUN: bbc -polymorphic-type -emit-fir %s -o - | FileCheck %s
8 procedure
, nopass
:: proc1
=> proc1_p1
11 type, extends(p1
) :: p2
14 procedure
, nopass
:: proc1
=> proc1_p2
20 print*, 'call proc1_p1'
24 print*, 'call proc1_p2'
27 subroutine test_nullify()
28 class(p1
), pointer :: c
33 nullify(c
) ! c dynamic type must be reset to p1
44 ! CHECK-LABEL: func.func @_QMpolyPtest_nullify()
45 ! CHECK: %[[C_DESC:.*]] = fir.alloca !fir.class<!fir.ptr<!fir.type<_QMpolyTp1{a:i32,b:i32}>>> {bindc_name = "c", uniq_name = "_QMpolyFtest_nullifyEc"}
46 ! CHECK: %{{.*}} = fir.call @_FortranAPointerAllocate(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32
47 ! CHECK: %[[DECLARED_TYPE:.*]] = fir.address_of(@_QMpolyE.dt.p1) : !fir.ref<!fir.type<{{.*}}>>
48 ! CHECK: %[[C_DESC_CAST:.*]] = fir.convert %[[C_DESC]] : (!fir.ref<!fir.class<!fir.ptr<!fir.type<_QMpolyTp1{a:i32,b:i32}>>>>) -> !fir.ref<!fir.box<none>>
49 ! CHECK: %[[TYPE_DESC_CAST:.*]] = fir.convert %[[DECLARED_TYPE]] : (!fir.ref<!fir.type<{{.*}}>>) -> !fir.ref<none>
50 ! CHECK: %[[RANK:.*]] = arith.constant 0 : i32
51 ! CHECK: %[[CORANK:.*]] = arith.constant 0 : i32
52 ! CHECK: %{{.*}} = fir.call @_FortranAPointerNullifyDerived(%[[C_DESC_CAST]], %[[TYPE_DESC_CAST]], %[[RANK]], %[[CORANK]]) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.ref<none>, i32, i32) -> none