Debian Codegraph @

gcc/testsuite/gfortran.dg/alloc_comp_basics_2.f90

raw
1 ! { dg-do run }
2 ! Check "double" allocations of allocatable components (PR 20541).
3 !
4 ! Contributed by Erik Edelmann <[email protected]>
5 ! and Paul Thomas <[email protected]>
6 !
7 program 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) STOP 1
23
24 allocate (mol(1)%array(5))
25 allocate (mol(1)%array(5),stat=i)
26 !print *, i ! /= 0
27 if (i == 0) STOP 2
28
29 allocate (molp(1))
30 allocate (molp(1), stat=i)
31 !print *, i ! == 0
32 if (i /= 0) STOP 3
33
34 allocate (molp(1)%array(5))
35 allocate (molp(1)%array(5),stat=i)
36 !print *, i ! /= 0
37 if (i == 0) STOP 4
38
39 end program main