This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/52393] Erroneous parse of read statement with parenthesised expression in format
- From: "ian_harvey at bigpond dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 27 Feb 2012 09:28:22 +0000
- Subject: [Bug fortran/52393] Erroneous parse of read statement with parenthesised expression in format
- Auto-submitted: auto-generated
- References: <bug-52393-4@http.gcc.gnu.org/bugzilla/>
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.