2 ! { dg-options "-fcheck=all" }
4 ! PR 50225: [OOP] The allocation status for polymorphic allocatable function results is not set properly
6 ! Contributed by Arjen Markus <arjen.markus895@gmail.com>
18 subroutine print( point )
19 class(point2d) :: point
20 write(*,'(2f10.4)') point%x, point%y
23 subroutine random_vector( point )
24 class(point2d) :: point
25 call random_number( point%x )
26 call random_number( point%y )
27 point%x = 2.0 * (point%x - 0.5)
28 point%y = 2.0 * (point%y - 0.5)
31 function add_vector( point, vector )
32 class(point2d), intent(in) :: point, vector
33 class(point2d), allocatable :: add_vector
34 allocate( add_vector )
35 add_vector%x = point%x + vector%x
36 add_vector%y = point%y + vector%y
47 type(point2d), target :: point_2d, vector_2d
48 class(point2d), pointer :: point, vector
55 call random_vector(point)
56 call random_vector(vector)
57 call print(add_vector(point, vector))
60 end program random_walk