aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/allocate_with_source_1.f90
blob: 0069092f6b8b3ac9aa942c0acff567cc3336e2db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
! { dg-do run }
! Test the fix for PR47592, in which the SOURCE expression was
! being called twice.
!
! Contributed by Thomas Koenig  <tkoenig@gcc.gnu.org>
!
module foo
  implicit none
contains
  function bar()
    integer bar
    integer :: i=9
    i = i + 1
    bar = i
  end function bar
end module foo

program note7_35
  use foo
  implicit none
  character(:), allocatable :: name
  character(:), allocatable :: src
  integer n
  n = 10
  allocate(name, SOURCE=repeat('x',bar()))
  if (name .ne. 'xxxxxxxxxx') call abort
  if (len (name) .ne. 10 ) call abort
end program note7_35