diff options
author | Daniel Kraft <d@domob.eu> | 2008-07-22 19:05:55 +0200 |
---|---|---|
committer | Daniel Kraft <domob@gcc.gnu.org> | 2008-07-22 19:05:55 +0200 |
commit | 9cad01cefbf1620fe2264feab58011ea3c23ccee (patch) | |
tree | 67b495422c086b17e39317d3339ecd1b1cfb0040 /gcc/fortran | |
parent | 1e58e43be96f1001a41de4e770a0e1f78e8ee68e (diff) | |
download | gcc-9cad01cefbf1620fe2264feab58011ea3c23ccee.zip gcc-9cad01cefbf1620fe2264feab58011ea3c23ccee.tar.gz gcc-9cad01cefbf1620fe2264feab58011ea3c23ccee.tar.bz2 |
re PR fortran/29835 (Error message of unknown edit descriptor needs improvement)
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.
From-SVN: r138063
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/fortran/io.c | 27 |
2 files changed, 33 insertions, 7 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b463061..3e50db4 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,16 @@ +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-21 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> * expr.c (gfc_check_pointer_assign): Fix typo in string. diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 5d3f454..188cf95 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -119,6 +119,8 @@ format_token; process. */ static gfc_char_t *format_string; static int format_length, use_last_char; +static char error_element; +static locus format_locus; static format_token saved_token; @@ -165,6 +167,9 @@ next_char (int in_string) if (mode == MODE_COPY) *format_string++ = c; + if (mode != MODE_STRING) + format_locus = gfc_current_locus; + c = gfc_wide_toupper (c); return c; } @@ -186,7 +191,7 @@ next_char_not_space (bool *error) char c; do { - c = next_char (0); + error_element = c = next_char (0); if (c == '\t') { if (gfc_option.allow_std & GFC_STD_GNU) @@ -431,14 +436,14 @@ format_lex (void) { if (gfc_notify_std (GFC_STD_F2003, "Fortran 2003: DP format " "specifier not allowed at %C") == FAILURE) - return FMT_ERROR; + return FMT_ERROR; token = FMT_DP; } else if (c == 'C') { if (gfc_notify_std (GFC_STD_F2003, "Fortran 2003: DC format " "specifier not allowed at %C") == FAILURE) - return FMT_ERROR; + return FMT_ERROR; token = FMT_DC; } else @@ -474,7 +479,8 @@ check_format (bool is_input) { const char *posint_required = _("Positive width required"); const char *nonneg_required = _("Nonnegative width required"); - const char *unexpected_element = _("Unexpected element"); + const char *unexpected_element = _("Unexpected element '%c' in format string" + " at %L"); const char *unexpected_end = _("Unexpected end of format string"); const char *zero_width = _("Zero width in format descriptor"); const char *g0_precision = _("Specifying precision with G0 not allowed"); @@ -960,10 +966,11 @@ extension_optional_comma: goto format_item; syntax: - gfc_error ("%s in format string at %C", error); + if (error == unexpected_element) + gfc_error (error, error_element, &format_locus); + else + gfc_error ("%s in format string at %L", error, &format_locus); fail: - /* TODO: More elaborate measures are needed to show where a problem - is within a format string that has been calculated. */ rv = FAILURE; finished: @@ -982,6 +989,12 @@ check_format_string (gfc_expr *e, bool is_input) mode = MODE_STRING; format_string = e->value.character.string; + + /* More elaborate measures are needed to show where a problem is within a + format string that has been calculated, but that's probably not worth the + effort. */ + format_locus = e->where; + return check_format (is_input); } |