2014-07-12 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / namelist_26.f90
blob2c1b26062e1ca6a3c1d22baeb3cf1dec2e1d4da8
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 !-------------------------------------
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()
48 end program gfcbug58