diff options
author | domob <domob@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-07-22 17:05:55 +0000 |
---|---|---|
committer | domob <domob@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-07-22 17:05:55 +0000 |
commit | cd18d5cd1a79220502f9ac670fbf025280f6b576 (patch) | |
tree | 67b495422c086b17e39317d3339ecd1b1cfb0040 /libgfortran | |
parent | c2a9c40270625414ac9c30354107f261697d8405 (diff) | |
download | gcc-cd18d5cd1a79220502f9ac670fbf025280f6b576.tar.gz |
2008-07-22 Daniel Kraft <d@domob.eu>
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 <d@domob.eu>
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 <d@domob.eu>
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@138063 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 9 | ||||
-rw-r--r-- | libgfortran/io/format.c | 10 |
2 files changed, 16 insertions, 3 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 2437c4f379c..cf559109544 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,12 @@ +2008-07-22 Daniel Kraft <d@domob.eu> + + 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 <tkoenig@gcc.gnu.org> PR libfortran/36890 diff --git a/libgfortran/io/format.c b/libgfortran/io/format.c index cf299c161a4..02ce2913bd2 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; |