This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Fortran, Patch] PR 33232 - Reject comma in "READ(...)," with -std=f95


Tobias Schlüter wrote:
> Tobias Burnus wrote:
>> read *, a    ! valid
> From looking over the code, I think this will break the second case
> you mentioned.

Well, it does not. (I wondered myself, but as it did not break, I
ignored it.)
Thanks for being pedantic; I now remove the whole k == M_* check as
comma_flag is what matters.

> Do we have any testcases for this?
I could find only the following:
gfortran.dg/vect/vect-1.f90:READ*, X, Y
gfortran.dg/vect/vect-2.f90:READ*, X, Y

which however does not test for
  READ '(format-string)', ...
and which are
  ! { dg-require-effective-target vect_float }
thus I added another test case.

Rebuild and check-gfortraned. Now ok for the trunk?

Tobias
2007-08-31  Tobias Burnus  <burnus@net-b.de>

	PR fortran/33232
	* io.c (match_io): Also diagnose 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.
	* gfortran.dg/read_1.f90: New.

Index: gcc/fortran/io.c
===================================================================
--- gcc/fortran/io.c	(revision 127989)
+++ gcc/fortran/io.c	(working copy)
@@ -2975,9 +2975,8 @@ 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)
+      && 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	(working copy)
@@ -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
Index: gcc/testsuite/gfortran.dg/read_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/read_1.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/read_1.f90	(revision 0)
@@ -0,0 +1,9 @@
+! { dg-do compile }
+!
+! Cf. PR fortran/33232
+program test
+  implicit none
+  integer :: a
+  READ *, a
+  READ '(i3)', a
+end program test

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]