2 ! { dg-options "-fdump-tree-original" }
6 ! Contributed by Kacper Kowalik
18 procedure(cg_ext
), nopass
, pointer :: init
19 procedure(cg_ext
), nopass
, pointer :: cleanup
26 end type ext_ptr_array
28 type(ext_ptr_array
) :: bar
31 subroutine epa_init(this
, init
, cleanup
)
33 class(ext_ptr_array
), intent(inout
) :: this
34 procedure(cg_ext
), pointer, intent(in
) :: init
35 procedure(cg_ext
), pointer, intent(in
) :: cleanup
37 this
%a
= ext_ptr(null(), null()) ! Wrong code
38 this
%a
= ext_ptr(init
, cleanup
) ! Wrong code
40 this
%a
%init
=> init
! OK
41 this
%a
%cleanup
=> cleanup
! OK
43 this
%a
= ext_ptr(this
%a
%init
,this
%a
%cleanup
) ! ICE in fold_convert_loc
44 end subroutine epa_init
51 integer :: count1
, count2
59 ! They should be called once
60 if (count1
/= 23 .or
. count2
/= 42) call abort ()
77 use foo
, only
: bar
, cg_ext
79 procedure(cg_ext
), pointer :: a_init
, a_clean
83 call bar
%epa_init(a_init
, a_clean
)
88 ! { dg-final { scan-tree-dump-times "ext_ptr.\[0-9\]+.init = 0B;" 1 "original" } }
89 ! { dg-final { scan-tree-dump-times "ext_ptr.\[0-9\]+.cleanup = 0B;" 1 "original" } }
90 ! { dg-final { scan-tree-dump-times "ext_ptr.1.init = \\*init;" 1 "original" } }
91 ! { dg-final { scan-tree-dump-times "ext_ptr.1.cleanup = \\*cleanup;" 1 "original" } }
92 ! { dg-final { scan-tree-dump-times "this->_data->a.init = \\*init;" 1 "original" } }
93 ! { dg-final { scan-tree-dump-times "this->_data->a.cleanup = \\*cleanup;" 1 "original" } }
94 ! { dg-final { scan-tree-dump-times "ext_ptr.\[0-9\]+.init = this->_data->a.init;" 1 "original" } }
95 ! { dg-final { scan-tree-dump-times "ext_ptr.\[0-9\]+.cleanup = this->_data->a.cleanup;" 1 "original" } }