[PATCH] Fix fortran/PR20846 "inquire(FILE=..., UNIT=...) not flagged as error"

Steve Kargl sgk@troutmask.apl.washington.edu
Sun May 29 04:39:00 GMT 2005


On Sat, May 28, 2005 at 11:43:51AM -0700, Steve Kargl wrote:
> On Tue, May 24, 2005 at 09:02:11PM +0300, Janne Blomqvist wrote:
> > 
> > attached patch fixes PR 20846 "inquire(FILE=..., UNIT=...) not flagged
> > as error".
> > 
> > ChangeLog:
> > 
> > 
> >         PR fortran/20846
> > 
> >         * trans-io.c (gfc_trans_inquire): Add sanity check for UNIT and
> >         FILE.
> > 
> > Patch itself is attached.
> > 
> 
> Janne's patch modified trans-io.c and I could not get
> the error message to print a sane locus incorrect line.
> I also recall that Paul (or Tobi) wanted to avoid error
> messages coming from the trans-* files if possible.  So,
> I've moved Janne's patch into io.c.  See attached patch
> and testcase.  Bootstrapped and regression tested on
> mainline.  Ok for mainline?  Ok for 4.0 after regtesting.
> 

Here's a better solution.

Janne, you've opened a can of worms with your patch to
PR 20846.

In looking at how the matching of INQUIRE is implemented,
I've found that neither constraint in 9.6.1 is flagged.
To implement the constraints and to point at the inquire
statement, I needed to add "locus where" to the gfc_inquire
struct; otherwise, the error message pointed to the end
of the statement.


2005-05-28  Steven G. Kargl  <kargls@comcast.com>

        * gfortran.h (gfc_inquire): Add locus to struct.
        * io.c (gfc_match_inquire): Implement constraints in 9.6.1

2005-05-28  Steven G. Kargl  <kargls@comcast.com>

        gfortran.dg/inquire_8.f90: new test.

-- 
Steve
-------------- next part --------------
Index: io.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/io.c,v
retrieving revision 1.22
diff -c -p -r1.22 io.c
*** io.c	11 May 2005 22:32:02 -0000	1.22
--- io.c	28 May 2005 18:38:28 -0000
*************** gfc_match_inquire (void)
*** 2426,2431 ****
--- 2426,2438 ----
  	  gfc_error ("IOLENGTH tag invalid in INQUIRE statement at %C");
  	  goto cleanup;
  	}
+ 
+       if (inquire->unit != NULL && inquire->file)
+ 	{
+ 	  gfc_error ("INQUIRE statement at %C cannot contain both FILE and"
+ 		     " UNIT specifiers");
+ 	  goto cleanup;
+ 	}
      }
  
    if (gfc_match_eos () != MATCH_YES)
-------------- next part --------------
! { dg-do compile }
program inquire_8
  character(len=20) :: n = 'data'
  integer :: d = 23
  logical a
  inquire(file=n,unit=d,opened=a) ! { dg-error "cannot contain both FILE and UNIT" }
  inquire(unit=d,file=n,opened=a) ! { dg-error "cannot contain both FILE and UNIT" }
end program inquire_8


More information about the Gcc-patches mailing list