aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBud Davis <bdavis9659@sbcglobal.net>2010-04-09 02:03:10 +0000
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2010-04-09 02:03:10 +0000
commitd0a2c5a9e7eb16099be1f4b1068f9fe1ff9d9d19 (patch)
tree9178c104384627411065bdb3f8bea6f559d57ada /gcc
parentc02105beb38f80c405ff8b90e3aec9223a49c39e (diff)
downloadgcc-d0a2c5a9e7eb16099be1f4b1068f9fe1ff9d9d19.zip
gcc-d0a2c5a9e7eb16099be1f4b1068f9fe1ff9d9d19.tar.gz
gcc-d0a2c5a9e7eb16099be1f4b1068f9fe1ff9d9d19.tar.bz2
re PR fortran/28039 (Warn when ignoring extra characters in the format specification)
2010-04-08 Bud Davis <bdavis9659@sbcglobal.net> PR fortran/28039 * io.c (check_format_string): Added check for additional non blank characters after the format string was successfully parsed. * io.c (check_format): Changed the error messages for positive int required and period required to drop through the error logic and report with gfc_error instead of gfc_error_now. Corrected format postion for hollerith strings. From-SVN: r158147
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog11
-rw-r--r--gcc/fortran/io.c28
2 files changed, 32 insertions, 7 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index b63a6fd..0b6bfae 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,14 @@
+2010-04-08 Bud Davis <bdavis9659@sbcglobal.net>
+
+ PR fortran/28039
+ * io.c (check_format_string): Added check for additional non
+ blank characters after the format string was successfully
+ parsed.
+ * io.c (check_format): Changed the error messages for positive
+ int required and period required to drop through the error logic
+ and report with gfc_error instead of gfc_error_now. Corrected
+ format postion for hollerith strings.
+
2010-04-08 Tobias Burnus <burnus@net-b.de>
* module.c (use_iso_fortran_env_module): Fix standard check.
diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c
index 9b0ee8d..1ce26df 100644
--- a/gcc/fortran/io.c
+++ b/gcc/fortran/io.c
@@ -850,11 +850,11 @@ data_desc:
if (u != FMT_POSINT)
{
format_locus.nextc += format_string_pos;
- gfc_error_now ("Positive width required in format "
+ gfc_error ("Positive width required in format "
"specifier %s at %L", token_to_string (t),
&format_locus);
saved_token = u;
- goto finished;
+ goto fail;
}
u = format_lex ();
@@ -866,11 +866,11 @@ data_desc:
format_locus.nextc += format_string_pos;
if (gfc_option.warn_std != 0)
{
- gfc_error_now ("Period required in format "
+ gfc_error ("Period required in format "
"specifier %s at %L", token_to_string (t),
&format_locus);
saved_token = u;
- goto finished;
+ goto fail;
}
else
gfc_warning ("Period required in format "
@@ -970,11 +970,11 @@ data_desc:
gfc_warning ("The H format specifier at %L is"
" a Fortran 95 deleted feature", &format_locus);
}
-
if (mode == MODE_STRING)
{
format_string += value;
format_length -= value;
+ format_string_pos += repeat;
}
else
{
@@ -1152,6 +1152,8 @@ finished:
static gfc_try
check_format_string (gfc_expr *e, bool is_input)
{
+ gfc_try rv;
+ int i;
if (!e || e->ts.type != BT_CHARACTER || e->expr_type != EXPR_CONSTANT)
return SUCCESS;
@@ -1162,8 +1164,20 @@ check_format_string (gfc_expr *e, bool is_input)
format string that has been calculated, but that's probably not worth the
effort. */
format_locus = e->where;
-
- return check_format (is_input);
+ rv = check_format (is_input);
+ /* check for extraneous characters at the end of an otherwise valid format
+ string, like '(A10,I3)F5'
+ start at the end and move back to the last character processed,
+ spaces are OK */
+ if (rv == SUCCESS && e->value.character.length > format_string_pos)
+ for (i=e->value.character.length-1;i>format_string_pos-1;i--)
+ if (e->value.character.string[i] != ' ')
+ {
+ format_locus.nextc += format_length + 1;
+ gfc_warning ("Extraneous characters in format at %L", &format_locus);
+ break;
+ }
+ return rv;
}