summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/namelist_20.f90
blob: 155cf6f8ed2eab2dc236c3dd948f3dc1dba51262 (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
29
30
31
32
33
34
35
!{ dg-do run }
! Tests namelist io for an explicit shape array with negative bounds
! provided by Paul Thomas - pault@gcc.gnu.org

program namelist_20
  integer, dimension (-4:-2) :: x
  integer                    :: i, ier
  namelist /a/ x

  open (10, status = "scratch")
  write (10, '(A)') "&a x(-5)=0 /"            !-ve index below lbound
  write (10, '(A)') "&a x(-1)=0 /"            !-ve index above ubound
  write (10, '(A)') "&a x(1:2)=0 /"           !+ve indices
  write (10, '(A)') "&a x(-4:-2)= -4,-3,-2 /" !correct
  write (10, '(A)') " "
  rewind (10)

  ier=0
  read(10, a, iostat=ier)
  if (ier == 0) call abort ()
  ier=0
  read(10, a, iostat=ier)
  if (ier == 0) call abort ()
  ier=0
  read(10, a, iostat=ier)
  if (ier == 0) call abort ()

  ier=0
  read(10, a, iostat=ier)
  if (ier /= 0) call abort ()
  do i = -4,-2
    if (x(i) /= i) call abort ()
  end do

end program namelist_20