OSDN Git Service

2010-02-10 Tobias Burnus <burnus@net-b.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / alloc_comp_basics_5.f90
1 ! { dg-do run }
2 ! This checks the correct functioning of derived types with the SAVE
3 ! attribute and allocatable components - PR31163
4 !
5 ! Contributed by Salvatore Filippone  <salvatore.filippone@uniroma2.it>
6 !
7 Module bar_mod
8
9   type foo_type
10      integer, allocatable :: mv(:)
11   end type foo_type
12
13
14 contains
15
16
17   subroutine bar_foo_ab(info)
18
19     integer, intent(out)               :: info
20     Type(foo_type), save :: f_a
21     
22     if (allocated(f_a%mv)) then 
23       info = size(f_a%mv)
24     else
25       allocate(f_a%mv(10),stat=info)
26       if (info /= 0) then 
27         info = -1 
28       endif
29     end if
30   end subroutine bar_foo_ab
31
32
33 end module bar_mod
34
35 program tsave
36   use bar_mod
37
38   integer :: info
39   
40   call bar_foo_ab(info) 
41   if (info .ne. 0) call abort ()
42   call bar_foo_ab(info) 
43   if (info .ne. 10) call abort ()
44   
45 end program tsave
46
47 ! { dg-final { cleanup-modules "bar_mod" } }