OSDN Git Service

2010-04-08 Bud Davis <bdavis9659@sbcglobal.net>
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Apr 2010 02:03:10 +0000 (02:03 +0000)
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Apr 2010 02:03:10 +0000 (02:03 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158147 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/io.c

index b63a6fd..0b6bfae 100644 (file)
@@ -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.
index 9b0ee8d..1ce26df 100644 (file)
@@ -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;
 }