From 8cd239614e43c9dcc0838845aec504e5eb938dbd Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Mon, 8 Jun 2020 21:00:11 +0200 Subject: [PATCH] PR fortran/95195 - Fortran testcase should clean up afterwards Change testcase to check error message (iomsg) at runtime, rather than to crash. libgfortran/ PR fortran/95091 * io/transfer.c (finalize_transfer): Fix type in error message. gcc/testsuite/ PR fortran/95195 * gfortran.dg/namelist_97.f90: Adjust testcase. --- gcc/testsuite/gfortran.dg/namelist_97.f90 | 10 ++++++---- libgfortran/io/transfer.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/namelist_97.f90 b/gcc/testsuite/gfortran.dg/namelist_97.f90 index 4907e46b46a..3c6ad7ce3c1 100644 --- a/gcc/testsuite/gfortran.dg/namelist_97.f90 +++ b/gcc/testsuite/gfortran.dg/namelist_97.f90 @@ -1,14 +1,16 @@ ! { dg-do run } -! { dg-output "At line 12 .*" } -! { dg-shouldfail "Fortran runtime error: Namelist formatting .* FORM='UNFORMATTED'" } ! ! PR95195 - improve runtime error when writing a namelist to an unformatted file program test character(len=11) :: my_form = 'unformatted' integer :: i = 1, j = 2, k = 3 + character(80) :: iomsg namelist /nml1/ i, j, k - open (unit=10, file='test.dat', form=my_form) - write (unit=10, nml=nml1) + open (unit=10, file='namelist_97.dat', form=my_form) + write (unit=10, nml=nml1, iostat=iostat, iomsg=iomsg) close (unit=10, status='delete') + if (iostat == 0) stop 1 + if (iomsg /= "Namelist formatting for unit connected with FORM='UNFORMATTED'") & + stop 2 end program test diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index cd51679ff46..dc18bc34b32 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -4127,7 +4127,7 @@ finalize_transfer (st_parameter_dt *dtp) { generate_error (&dtp->common, LIBERROR_OPTION_CONFLICT, "Namelist formatting for unit connected " - "with FORM='UNFORMATTED"); + "with FORM='UNFORMATTED'"); return; } -- 2.30.2