1! { dg-do run }
2! { dg-options "-fcoarray=single" }
3!
4! Contributed by Gerhard Steinmetz  <gerhard.steinmetz.fortran@t-online.de>
5!               Andre Vehreschild <vehre@gcc.gnu.org>
6! Check that PR fortran/69451 is fixed.
7
8program main
9
10implicit none
11
12type foo
13end type
14
15class(foo), allocatable :: p[:]
16class(foo), pointer :: r
17class(*), allocatable, target :: z
18
19allocate(p[*])
20
21call s(p, z)
22select type (z)
23  class is (foo) 
24        r => z
25  class default
26     call abort()
27end select
28
29if (.not. associated(r)) call abort()
30
31deallocate(r)
32deallocate(p)
33
34contains
35
36subroutine s(x, z) 
37   class(*) :: x[*]
38   class(*), allocatable:: z
39   allocate (z, source=x)
40end
41
42end
43
44