From 9cad01cefbf1620fe2264feab58011ea3c23ccee Mon Sep 17 00:00:00 2001 From: Daniel Kraft Date: Tue, 22 Jul 2008 19:05:55 +0200 Subject: re PR fortran/29835 (Error message of unknown edit descriptor needs improvement) 2008-07-22 Daniel Kraft PR fortran/29835 * io.c (error_element), (format_locus): New static globals. (unexpected_element): Spelled out this message fully. (next_char): Keep track of locus when not MODE_STRING. (next_char_not_space): Remember last parsed element in error_element. (format_lex): Fix two indentation errors. (check_format): Use format_locus and possibly error_element for a slightly better error message on invalid format. (check_format_string): Set format_locus to start of the string expression used as format. 2008-07-22 Daniel Kraft PR fortran/29835 * io/format.c (struct format_data): New member error_element. (unexpected_element): Added '%c' to message. (next_char): Keep track of last parsed character in fmt->error_element. (format_error): If the message is unexpected_element, output the offending character, too. 2008-07-22 Daniel Kraft PR fortran/29835 * gfortran.dg/fmt_error_3.f90: New test. * gfortran.dg/fmt_error_4.f90: New test. * gfortran.dg/fmt_error_5.f90: New test. From-SVN: r138063 --- libgfortran/ChangeLog | 9 +++++++++ libgfortran/io/format.c | 10 +++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'libgfortran') diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 2437c4f..cf55910 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,12 @@ +2008-07-22 Daniel Kraft + + PR fortran/29835 + * io/format.c (struct format_data): New member error_element. + (unexpected_element): Added '%c' to message. + (next_char): Keep track of last parsed character in fmt->error_element. + (format_error): If the message is unexpected_element, output the + offending character, too. + 2008-07-22 Thomas Koenig PR libfortran/36890 diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c index cf299c16..02ce291 100644 --- a/libgfortran/io/format.c +++ b/libgfortran/io/format.c @@ -50,6 +50,7 @@ typedef struct format_data { char *format_string, *string; const char *error; + char error_element; format_token saved_token; int value, format_string_len, reversion_ok; fnode *avail; @@ -67,7 +68,7 @@ static const fnode colon_node = { FMT_COLON, 0, NULL, NULL, {{ 0, 0, 0 }}, 0, static const char posint_required[] = "Positive width required in format", period_required[] = "Period required in format", nonneg_required[] = "Nonnegative width required in format", - unexpected_element[] = "Unexpected element in format", + unexpected_element[] = "Unexpected element '%c' in format\n", unexpected_end[] = "Unexpected end of format string", bad_string[] = "Unterminated character constant in format", bad_hollerith[] = "Hollerith constant extends past the end of the format", @@ -89,7 +90,7 @@ next_char (format_data *fmt, int literal) return -1; fmt->format_string_len--; - c = toupper (*fmt->format_string++); + fmt->error_element = c = toupper (*fmt->format_string++); } while ((c == ' ' || c == '\t') && !literal); @@ -948,7 +949,10 @@ format_error (st_parameter_dt *dtp, const fnode *f, const char *message) if (f != NULL) fmt->format_string = f->source; - sprintf (buffer, "%s\n", message); + if (message == unexpected_element) + sprintf (buffer, message, fmt->error_element); + else + sprintf (buffer, "%s\n", message); j = fmt->format_string - dtp->format; -- cgit v1.1