Fortran: Revise a namelist test case.

PR fortran/109662

gcc/testsuite/ChangeLog:

	* gfortran.dg/pr109662-a.f90: Add a section to verify that
	a short namelist read does not modify the variable.
This commit is contained in:
Jerry DeLisle 2023-05-12 13:38:25 -07:00
parent cf3b032b8f
commit 96cc09dea4

View file

@ -3,13 +3,26 @@
! PR109662-a semi-colon after namelist name accepted on input.
program testnmlread
implicit none
character(16) :: list = '&stuff; n = 759/'
character(16) :: line = '&stuff; n = 759/'
character(100)::message
integer :: n, ioresult
integer :: n, i, ioresult
namelist/stuff/n
message = ""
ioresult = 0
n = 99
read(list,nml=stuff,iostat=ioresult)
if (ioresult == 0) STOP 13
read(line,nml=stuff,iostat=ioresult)
if (ioresult == 0) STOP 13 ! Should error with the semi-colon in there.
! Intentional short input (-> EOF)
line = "&stuff"
! Problem manifests on two bad reads on same string.
do i = 1, 6
n = -1
ioresult = 0
read (line,nml=stuff,iostat=ioresult)
if (n /= -1) STOP 24
if (ioresult == 0) STOP 25
end do
end program testnmlread