OSDN Git Service

2011-09-26 Janus Weil <janus@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / namelist_26.f90
1 ! { dg-do run }
2 ! PR30918 Failure to skip commented out NAMELIST
3 ! Before the patch, this read the commented out namelist and iuse would
4 ! equal 2 when done.  Test case from PR.
5 program gfcbug58
6   implicit none
7   integer            :: iuse = 0, ios
8   integer, parameter :: nmlunit = 10    ! Namelist unit
9   !------------------
10   ! Namelist 'REPORT'
11   !------------------
12   character(len=12) :: type, use
13   integer           :: max_proc
14   namelist /REPORT/ type, use, max_proc
15   !------------------
16   ! Set up the test file
17   !------------------
18   open(unit=nmlunit, status="scratch")
19   write(nmlunit, '(a)') "!================"
20   write(nmlunit, '(a)') "! Namelist REPORT"
21   write(nmlunit, '(a)') "!================"
22   write(nmlunit, '(a)') "!      &REPORT use      = 'ignore'   / ! Comment"
23   write(nmlunit, '(a)') "!"
24   write(nmlunit, '(a)') " &REPORT type     = 'SYNOP'"
25   write(nmlunit, '(a)') "         use      = 'active'"
26   write(nmlunit, '(a)') "         max_proc = 20"
27   write(nmlunit, '(a)') " /"
28   rewind(nmlunit)
29   !-------------------------------------
30   ! Loop to read namelist multiple times
31   !-------------------------------------
32   do
33      !----------------------------------------
34      ! Preset namelist variables with defaults
35      !----------------------------------------
36      type      = ''
37      use       = ''
38      max_proc  = -1
39      !--------------
40      ! Read namelist
41      !--------------
42      read (nmlunit, nml=REPORT, iostat=ios)
43      if (ios /= 0) exit
44      iuse = iuse + 1
45   end do
46   if (iuse /= 1) call abort()
47
48 end program gfcbug58