1! { dg-do run }
2! Check "double" allocations of allocatable components (PR 20541).
3!
4! Contributed by Erik Edelmann  <eedelmann@gcc.gnu.org>
5!            and Paul Thomas  <pault@gcc.gnu.org>
6!
7program main
8
9  implicit none
10
11  type foo
12     integer, dimension(:), allocatable :: array
13  end type foo
14
15  type(foo),allocatable,dimension(:) :: mol
16  type(foo),pointer,dimension(:) :: molp
17  integer :: i
18
19  allocate (mol(1))
20  allocate (mol(1), stat=i)
21  !print *, i  ! /= 0
22  if (i == 0) call abort()
23
24  allocate (mol(1)%array(5))
25  allocate (mol(1)%array(5),stat=i)
26  !print *, i  ! /= 0
27  if (i == 0) call abort()
28
29  allocate (molp(1))
30  allocate (molp(1), stat=i)
31  !print *, i  ! == 0
32  if (i /= 0) call abort()
33
34  allocate (molp(1)%array(5))
35  allocate (molp(1)%array(5),stat=i)
36  !print *, i  ! /= 0
37  if (i == 0) call abort()
38
39end program main
40