Debian Codegraph @

gcc/testsuite/gfortran.dg/coarray/move_alloc_2.f90

raw
1 !{ dg-do run }
2
3 ! Check gimplify with checking works. [PR86468]
4 ! This rather complicated code is needed to produce two "different"
5 ! types in the move_alloc.
6
7 ! Contributed by Juergen Reuter <[email protected]>
8
9 module classes
10 implicit none
11 private
12 public :: wrapped_coarray
13
14 type :: wrapped_point
15 integer, allocatable :: point(:)
16 contains
17 procedure :: add => wrapped_point_add
18 end type wrapped_point
19
20 type :: wrapped_coarray
21 type(wrapped_point), allocatable :: caf(:)[:]
22 end type wrapped_coarray
23
24 contains
25
26 subroutine wrapped_point_add(self, to_add)
27 class(wrapped_point), intent(inout) :: self
28 integer, intent(in) :: to_add
29 integer, allocatable :: point(:)
30 integer :: points_number
31
32 if (allocated(self%point)) then
33 points_number = size(self%point, dim=1)
34 allocate(point(1:points_number+1))
35 point(1:points_number) = self%point
36 point(points_number+1) = to_add
37 call move_alloc(from=point, to=self%point)
38 else
39 allocate(self%point(1))
40 self%point(1) = to_add
41 end if
42 end subroutine wrapped_point_add
43 end module classes
44
45 program test
46 use classes
47 implicit none
48
49 type(wrapped_coarray) :: foo
50 allocate(foo%caf(99)[*])
51 call foo%caf(32)%add(this_image())
52 call foo%caf(32)%add(this_image())
53 if (any (foo%caf(32)%point /= [this_image(), this_image()])) stop 1
54 end program test
55