Patchwork [fortran] PR 50554 - redefinition of index variable with inquire(iolength=...)

login
register
mail settings
Submitter Tobias Burnus
Date June 28, 2013, 8:47 a.m.
Message ID <51CD4DBA.8040306@net-b.de>
Download mbox | patch
Permalink /patch/255309/
State New
Headers show

Comments

Tobias Burnus - June 28, 2013, 8:47 a.m.
Tobias Burnus wrote:
> Actually, I wonder whether the following (untested) shouldn't be 
> sufficient:

Seems to work.

Build and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias
Tobias Burnus - July 8, 2013, 4:14 p.m.
Now committed as obvious (Rev. 200790).

Tobias

Tobias Burnus wrote:
> Tobias Burnus wrote:
>> Actually, I wonder whether the following (untested) shouldn't be 
>> sufficient:
>
> Seems to work.
>
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?
>
> Tobias

Patch

2013-06-28  Tobias Burnus  <burnus@net-b.de>

	PR fortran/50554
	* io.c (match_inquire_element): Add missing do-var check.

2013-06-28  Tobias Burnus  <burnus@net-b.de>

	PR fortran/50554
	* gfortran.dg/do_check_9.f90: New.

diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c
index c5120dd..678bc5d 100644
--- a/gcc/fortran/io.c
+++ b/gcc/fortran/io.c
@@ -3890,12 +3890,12 @@  match_inquire_element (gfc_inquire *inquire)
   RETM m = match_vtag (&tag_s_async, &inquire->asynchronous);
   RETM m = match_vtag (&tag_s_delim, &inquire->delim);
   RETM m = match_vtag (&tag_s_decimal, &inquire->decimal);
-  RETM m = match_vtag (&tag_size, &inquire->size);
+  RETM m = match_out_tag (&tag_size, &inquire->size);
   RETM m = match_vtag (&tag_s_encoding, &inquire->encoding);
   RETM m = match_vtag (&tag_s_round, &inquire->round);
   RETM m = match_vtag (&tag_s_sign, &inquire->sign);
   RETM m = match_vtag (&tag_s_pad, &inquire->pad);
-  RETM m = match_vtag (&tag_iolength, &inquire->iolength);
+  RETM m = match_out_tag (&tag_iolength, &inquire->iolength);
   RETM m = match_vtag (&tag_convert, &inquire->convert);
   RETM m = match_out_tag (&tag_strm_out, &inquire->strm_pos);
   RETM m = match_vtag (&tag_pending, &inquire->pending);
--- /dev/null	2013-06-28 09:04:44.785079259 +0200
+++ gcc/gcc/testsuite/gfortran.dg/do_check_9.f90	2013-06-28 09:57:03.224522219 +0200
@@ -0,0 +1,14 @@ 
+! { dg-do compile }
+!
+! PR fortran/50554
+!
+! Contributed by Vittorio Zecca
+!
+! INQUIRE cannot redefine DO index
+!
+      do I=1,10 ! { dg-error "cannot be redefined inside loop beginning at" }
+       inquire(iolength=I) n ! { dg-error "cannot be redefined inside loop beginning at" }
+       inquire(99,size=I) ! { dg-error "cannot be redefined inside loop beginning at" }
+       read(99,'(i4)',size=I,advance="no") n ! { dg-error "cannot be redefined inside loop beginning at" }
+      end do
+      end