[patch, Fortran] PR61933 Inquire on Internal Units

Jerry DeLisle jvdelisle@charter.net
Wed Jan 21 05:19:00 GMT 2015


On 01/19/2015 11:28 PM, Tobias Burnus wrote:
> Hi Jerry, hi all,
>
> sorry for the slow patch review. I also still want to review your other inquire
> patch.
>
> Jerry DeLisle wrote:
>> The fundamental problem: if the variable containing the unit number in an
>> INQUIRE statement is of type KIND greater than 4 and the value is outside the
>> range of a KIND=4 we cannot test for it within the run-time library.  Unit
>> numbers are passed to the run-time in the IOPARM structures as a KIND=4.
>> KIND=8 are cast into the KIND=4.  The test case
>> gfortran.dg/negative_unit_int8.f illustrates a case where a bogus unit number
>> can get passed to the library.
>>
>
>> Regression tested on x86-64 and Joost's case in the PR now works as expected.
>> OK for trunk?
>
> Mostly OK, however, some remarks are below.

--- snip---

> I don't know where this number is used, but I really should be a #define; if it
> is shared with libgfortran, it belongs to libgfortran.h. You wrote that -1 is
> also reserved and used; is the -1 somewhere defined? [Disclaimer: I have only
> browsed the other patch and do not recall whether it add, handles or #defines -1
> - or whether -1 is already defined somewhere.]
>

I have added the following to libgfortran.h and used them (see patch)

/* Special unit numbers used to convey certain conditions.  Numbers -3
    thru -9 available.  NEWUNIT values start at -10.  */
#define GFC_INTERNAL_UNIT -1
#define GFC_INVALID_UNIT  -2

--- snip ---

>
> The conditions could be combined with a fold_build2_loc(...,TRUTH_AND_EXPR,...).
>

I have combined the conditions using TRUTH_OR_EXPR which is what we want.  I 
also rolled the one helper function I had into the caller since I now only build 
one block in the combined condition.

The new -fdump-tree-orginal result looks good:

     inquire_parm.4.common.unit = (integer(kind=4)) i;
     D.3393 = i;
     if (D.3393 < 0 || D.3393 > 2147483647)
       {
         inquire_parm.4.common.unit = -2;
       }
     _gfortran_st_inquire (&inquire_parm.4);

The updated patch is attached.

Regression tested completely again.  OK for Trunk?

Thanks for the review.

Regards,

Jerry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr61933-b.diff
Type: text/x-patch
Size: 9943 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20150121/e7315123/attachment.bin>


More information about the Fortran mailing list