diff options
Diffstat (limited to 'gcc/fortran/io.c')
-rw-r--r-- | gcc/fortran/io.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 20bf26215d5..b0dfa8f0311 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -2744,7 +2744,8 @@ match_io (io_kind k) where = gfc_current_locus; comma_flag = 0; current_dt = dt = gfc_getmem (sizeof (gfc_dt)); - if (gfc_match_char ('(') == MATCH_NO) + m = gfc_match_char ('('); + if (m == MATCH_NO) { where = gfc_current_locus; if (k == M_WRITE) @@ -2796,9 +2797,25 @@ match_io (io_kind k) } else { - /* Error for constructs like print (1,*). */ - if (k == M_PRINT) - goto syntax; + /* Before issuing an error for a malformed 'print (1,*)' type of + error, check for a default-char-expr of the form ('(I0)'). */ + + if (k == M_PRINT && m == MATCH_YES) + { + /* Reset current locus to get the initial '(' in an expression. */ + gfc_current_locus = where; + dt->format_expr = NULL; + m = match_dt_format (dt); + + if (m == MATCH_ERROR) + goto cleanup; + if (m == MATCH_NO || dt->format_expr == NULL) + goto syntax; + + comma_flag = 1; + dt->io_unit = default_unit (k); + goto get_io_list; + } } /* Match a control list */ |