From 96cc09dea48b562a0fc93d43fb3b702ac20b89fd Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Fri, 12 May 2023 13:38:25 -0700 Subject: [PATCH] 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. --- gcc/testsuite/gfortran.dg/pr109662-a.f90 | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/pr109662-a.f90 b/gcc/testsuite/gfortran.dg/pr109662-a.f90 index 0059df28b9f..dc05d6b7a80 100644 --- a/gcc/testsuite/gfortran.dg/pr109662-a.f90 +++ b/gcc/testsuite/gfortran.dg/pr109662-a.f90 @@ -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