[Bug fortran/52393] Erroneous parse of read statement with parenthesised expression in format

2012-02-27 Thread ian_harvey at bigpond dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52393

--- Comment #2 from Ian Harvey ian_harvey at bigpond dot com 2012-02-27 
09:28:22 UTC ---
There is no unit number in that /read-stmt/, just a /format/ and one io item. 
This is the second form (per the ordering in the syntax rules from F77 on) of
read that is the companion to the /print-stmt/ (as opposed to the more commonly
seen form that is the companion to a /write-stmt/).  This second form always
reads from the console (or whatever the unit * means), just like PRINT always
writes to the console.

R910
/read-stmt/ is READ ( /io-control-spec-list/ ) [ /input-item-list/ ]

or READ /format/ [ , /input-item-list/ ] ! -- This one.

R915
/format/is /default-char-expr/  ! -- Then this one.

or /label/

or *

The /format/ for this /read-stmt/ is then the /default-char-expr/

  ('('   )// 'A)'

which has a pointlessly parenthesised character literal '(' concatenated with
'A)'.  The result of evaluating that is '(A)', which is a valid format
specification (9.6.2.2p2).

The comma is simply the comma that is required in the /read-stmt/ to separate
the format expression from the /input-item-list/.  The common vendor extension
for the extra comma for the other form of /read-stmt/ is problematic here with
respect to ambiguity.

I've used F2008 references above, but this is all standard F90 (salient parts
are F77 even?).  See c.l.f for discussion of ambiguity issues with F2008.  

I accept that this is somewhat obscure and that the specific example is rather
contrived.


[Bug fortran/52393] Erroneous parse of read statement with parenthesised expression in format

2012-02-26 Thread burnus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52393

Tobias Burnus burnus at gcc dot gnu.org changed:

   What|Removed |Added

 CC||burnus at gcc dot gnu.org

--- Comment #1 from Tobias Burnus burnus at gcc dot gnu.org 2012-02-27 
07:50:05 UTC ---
Looks like an invalid (logical) UNIT number to me. You either need to have an
integer literal/parameter/variable, a character variable or a * for UNIT=.

I think you intended to write instead of:
   READ ('(') // 'A)', var  

  READ (*,'(' // 'A)') var

That is: With unit * and with the ) not after ')' but after 'A)'.
Additional, the comma before var is not allowed (but a common vendor
extension).