2011-05-23 Tom de Vries <tom@codesourcery.com>
[official-gcc.git] / gcc / testsuite / gfortran.dg / allocate_with_source_1.f90
blobd386bb33b7c99f02c6570c31d03c46e766e95f42
1 ! { dg-do run }
2 ! Test the fix for PR47592, in which the SOURCE expression was
3 ! being called twice.
5 ! Contributed by Thomas Koenig <tkoenig@gcc.gnu.org>
7 module foo
8 implicit none
9 contains
10 function bar()
11 integer bar
12 integer :: i=9
13 i = i + 1
14 bar = i
15 end function bar
16 end module foo
18 program note7_35
19 use foo
20 implicit none
21 character(:), allocatable :: name
22 character(:), allocatable :: src
23 integer n
24 n = 10
25 allocate(name, SOURCE=repeat('x',bar()))
26 if (name .ne. 'xxxxxxxxxx') call abort
27 if (len (name) .ne. 10 ) call abort
28 end program note7_35
29 ! { dg-final { cleanup-modules "foo" } }