2 ! { dg-options "-fdump-tree-original" }
4 ! Test the fix for the second part of PR87359 in which the reallocation on
5 ! assignment for components of associate names was disallowed by r264358.
6 ! -fcheck-all exposed the mismatch in array shapes. The deallocations at
7 ! the end of the main program are there to make sure that valgrind does
8 ! not report an memory leaks.
10 ! Contributed by Juergen Reuter <juergen.reuter@desy.de>
15 public
:: phs_identifier_t
17 type :: phs_identifier_t
18 integer, dimension(:), allocatable
:: contributors
20 procedure
:: init
=> phs_identifier_init
21 end type phs_identifier_t
24 type(phs_identifier_t
), dimension(:), allocatable
:: phs_identifiers
28 subroutine phs_identifier_init
&
29 (phs_id
, contributors
)
30 class(phs_identifier_t
), intent(out
) :: phs_id
31 integer, intent(in
), dimension(:) :: contributors
32 allocate (phs_id
%contributors (size (contributors
)))
33 phs_id
%contributors
= contributors
34 end subroutine phs_identifier_init
44 public
:: process_instance_t
46 type :: nlo_event_deps_t
47 type(phs_identifier_t
), dimension(:), allocatable
:: phs_identifiers
48 end type nlo_event_deps_t
50 type :: process_instance_t
51 type(phs_fks_t
), pointer :: phs
=> null ()
52 type(nlo_event_deps_t
) :: event_deps
54 procedure
:: init
=> process_instance_init
55 procedure
:: setup_real_event_kinematics
=> pi_setup_real_event_kinematics
56 end type process_instance_t
60 subroutine process_instance_init (instance
)
61 class(process_instance_t
), intent(out
), target
:: instance
63 integer :: i_born
, i_real
64 allocate (instance
%phs
)
65 end subroutine process_instance_init
67 subroutine pi_setup_real_event_kinematics (process_instance
)
68 class(process_instance_t
), intent(inout
) :: process_instance
70 associate (event_deps
=> process_instance
%event_deps
)
72 associate (phs
=> process_instance
%phs
)
73 allocate (phs
%phs_identifiers (3))
74 call phs
%phs_identifiers(1)%init ([1])
75 call phs
%phs_identifiers(2)%init ([1,2])
76 call phs
%phs_identifiers(3)%init ([1,2,3])
77 process_instance
%event_deps
%phs_identifiers
= phs
%phs_identifiers
! Error: mismatch in array shapes.
80 end subroutine pi_setup_real_event_kinematics
87 use instances
, only
: process_instance_t
89 type(process_instance_t
), allocatable
, target
:: process_instance
90 allocate (process_instance
)
91 call process_instance
%init ()
92 call process_instance
%setup_real_event_kinematics ()
93 if (associated (process_instance
%phs
)) deallocate (process_instance
%phs
)
94 if (allocated (process_instance
)) deallocate (process_instance
)
96 ! { dg-final { scan-tree-dump-times "__builtin_realloc" 2 "original" } }