This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Fortran, Patch] PR 33232 - Reject comma in "READ(...)," with -std=f95
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>, "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>
- Date: Fri, 31 Aug 2007 16:03:43 +0200
- Subject: [Fortran, Patch] PR 33232 - Reject comma in "READ(...)," with -std=f95
:ADDPATCH fortran:
The comma before the i/o list is invalid in Fortran 95/2003 for READ and
WRITE, but a common vendor extension. For WRITE gfortran was correctly
diagnosing it (-std=f95/f2003 as error, -pedantic as warning), but for
READ it didn't.
read '(f3.3)', a ! valid
read *, a ! valid
read(*,*), a ! Invalid
Build and check-gfortran'ed on x86-64-Linux.
Ok for the trunk?
Tobias
2007-08-31 Tobias Burnus <burnus@net-b.de>
PR fortran/33232
* io.c (match_io): Also diagnose the extra comma for READ.
2007-08-31 Tobias Burnus <burnus@net-b.de>
PR fortran/33232
* gfortran.dg/eor_handling_2.f90: Add dg-warnings.
Index: gcc/fortran/io.c
===================================================================
--- gcc/fortran/io.c (Revision 127989)
+++ gcc/fortran/io.c (Arbeitskopie)
@@ -2975,9 +2975,9 @@ get_io_list:
/* Optional leading comma (non-standard). */
if (!comma_flag
&& gfc_match_char (',') == MATCH_YES
- && k == M_WRITE
- && gfc_notify_std (GFC_STD_GNU, "Extension: Comma before output "
- "item list at %C is an extension") == FAILURE)
+ && (k == M_WRITE || k == M_READ)
+ && gfc_notify_std (GFC_STD_GNU, "Extension: Comma before i/o "
+ "item list at %C") == FAILURE)
return MATCH_ERROR;
io_code = NULL;
Index: gcc/testsuite/gfortran.dg/eor_handling_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/eor_handling_2.f90 (Revision 127989)
+++ gcc/testsuite/gfortran.dg/eor_handling_2.f90 (Arbeitskopie)
@@ -4,10 +4,10 @@
program main
character(len=1) c1(10),c2(10)
open(77,status='scratch')
- write(77,'(A)') 'Line 1','Line 2','Line 3'
+ write(77,'(A)'), 'Line 1','Line 2','Line 3' ! { dg-warning "Comma before i/o item list" }
rewind(77)
- read(77,'(10A1)'), c1
- read(77,'(10A1)'), c2
+ read(77,'(10A1)'), c1 ! { dg-warning "Comma before i/o item list" }
+ read(77,'(10A1)'), c2 ! { dg-warning "Comma before i/o item list" }
if (c1(1) /= 'L' .or. c2(1) /= 'L') call abort
close(77)
end program main