diff options
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/close.c | 13 | ||||
-rw-r--r-- | libgfortran/io/format.c | 10 | ||||
-rw-r--r-- | libgfortran/io/open.c | 10 | ||||
-rw-r--r-- | libgfortran/io/read.c | 2 |
4 files changed, 27 insertions, 8 deletions
diff --git a/libgfortran/io/close.c b/libgfortran/io/close.c index 8122311..41d278c 100644 --- a/libgfortran/io/close.c +++ b/libgfortran/io/close.c @@ -84,8 +84,17 @@ st_close (st_parameter_close *clp) if (u != NULL) { - if (close_share (u) < 0) - generate_error (&clp->common, LIBERROR_OS, "Problem in CLOSE"); + if (u->s == NULL) + { + if (u->unit_number < 0) + generate_error (&clp->common, LIBERROR_BAD_UNIT, + "Unit number is negative with no associated file"); + library_end (); + return; + } + else + if (close_share (u) < 0) + generate_error (&clp->common, LIBERROR_OS, "Problem in CLOSE"); if (u->flags.status == STATUS_SCRATCH) { if (status == CLOSE_KEEP) diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c index eef1d34..87e21a9 100644 --- a/libgfortran/io/format.c +++ b/libgfortran/io/format.c @@ -1235,9 +1235,9 @@ parse_format_list (st_parameter_dt *dtp, bool *seen_dd) default: /* Assume a missing comma with -std=legacy, GNU extension. */ - if (compile_options.warn_std == 0) - goto format_item_1; - format_error (dtp, tail, comma_missing); + if (compile_options.warn_std != 0) + fmt->error = comma_missing; + goto format_item_1; } /* Optional comma is a weird between state where we've just finished @@ -1252,7 +1252,7 @@ parse_format_list (st_parameter_dt *dtp, bool *seen_dd) case FMT_RPAREN: goto finished; - default: /* Assume that we have another format item */ + default: /* Assume that we have another format item */ fmt->saved_token = t; break; } @@ -1419,7 +1419,7 @@ parse_format (st_parameter_dt *dtp) else fmt->error = "Missing initial left parenthesis in format"; - if (format_cache_ok) + if (format_cache_ok && !fmt->error) save_parsed_format (dtp); else dtp->u.p.format_not_saved = 1; diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c index 06ddf7f..e9fb0a7 100644 --- a/libgfortran/io/open.c +++ b/libgfortran/io/open.c @@ -912,6 +912,16 @@ st_open (st_parameter_open *opp) library_end (); return; } + + if (u->s == NULL) + { + unlock_unit (u); + generate_error (&opp->common, LIBERROR_BAD_OPTION, + "Unit number is negative and unit was not already " + "opened with OPEN(NEWUNIT=...)"); + library_end (); + return; + } } if (u == NULL) diff --git a/libgfortran/io/read.c b/libgfortran/io/read.c index a8a6a69..e34d31b 100644 --- a/libgfortran/io/read.c +++ b/libgfortran/io/read.c @@ -1375,7 +1375,7 @@ exponent: /* At this point a digit string is required. We calculate the value of the exponent in order to take account of the scale factor and - the d parameter before explict conversion takes place. */ + the d parameter before explicit conversion takes place. */ if (w == 0) { |