[multiple changes]
authorBud Davis <bdavis9659@sbcglobal.net>
Sun, 23 Aug 2009 02:19:59 +0000 (02:19 +0000)
committerBud Davis <bdavis@gcc.gnu.org>
Sun, 23 Aug 2009 02:19:59 +0000 (02:19 +0000)
2009-08-22 Bud Davis <bdavis9659@sbcglobal.net>

PR fortran/28093
* io.c : added variable to store original len of fmt
* io.c (check_format): Consume H items using next_char
in both modes to handle consecutive single quotes.
Test for extra characters in fmt, issue warning.

2009-08-22  Bud Davis  <bdavis9659@sbcglobal.net>

PR fortran/28039
* gfortran.dg/fmt_with_extra.f: new file.

From-SVN: r151021

gcc/fortran/ChangeLog
gcc/fortran/io.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/fmt_with_extra.f [new file with mode: 0644]

index 53a9d6d99ec6996ea2cba42cc6df97c643852ddf..635e68cb88bda39e7fca909ff057f66603b2cd6d 100644 (file)
@@ -1,3 +1,11 @@
+2009-08-22     Bud Davis <bdavis9659@sbcglobal.net>
+
+       PR fortran/28093
+       * io.c : added variable to store original len of fmt
+       * io.c (check_format): Consume H items using next_char
+       in both modes to handle consecutive single quotes.
+       Test for extra characters in fmt, issue warning.
+
 2009-08-21  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/41106
index f11ea38f7291bbf1dfb60c9dfcd3777f5ea34c5b..4f60b80db4052f8448945e4f3b6633d76be8ae4e 100644 (file)
@@ -121,6 +121,7 @@ format_token;
 static gfc_char_t *format_string;
 static int format_string_pos;
 static int format_length, use_last_char;
+static int starting_format_length;
 static char error_element;
 static locus format_locus;
 
@@ -875,20 +876,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;
-       }
-      else
-       {
-         while (repeat >0)
-          {
-            next_char (1);
-            repeat -- ;
-          }
-       }
+      while (repeat >0)
+       {
+          next_char (1);
+          repeat -- ;
+       }
      break;
 
     case FMT_IBOZ:
@@ -1039,6 +1031,13 @@ fail:
   rv = FAILURE;
 
 finished:
+  /* check for extraneous characters at end of valid format string */
+  if ( starting_format_length > format_length )
+    {
+       format_locus.nextc += format_length + 1; /* point to the extra */
+       gfc_warning ("Extraneous characters in format at %L", &format_locus); 
+    }
+    
   return rv;
 }
 
@@ -1054,7 +1053,7 @@ check_format_string (gfc_expr *e, bool is_input)
 
   mode = MODE_STRING;
   format_string = e->value.character.string;
-
+  starting_format_length = e->value.character.length;
   /* 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.  */
index 90308c96fded2d19048c2ec83ee9108a77264c6e..8e60e36d31758699e2c4abf4b894836a13abdd96 100644 (file)
@@ -1,3 +1,7 @@
+2009-08-22  Bud Davis  <bdavis9659@sbcglobal.net>
+
+       PR fortran/28039
+       * gfortran.dg/fmt_with_extra.f: new file.
 2009-08-21  Maciej W. Rozycki  <macro@codesourcery.com>
 
        * lib/target-supports.exp
diff --git a/gcc/testsuite/gfortran.dg/fmt_with_extra.f b/gcc/testsuite/gfortran.dg/fmt_with_extra.f
new file mode 100644 (file)
index 0000000..45664be
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! test case contributed by tobias.burnus@physik.fu-berlin.de
+! PR28039 Warn when ignoring extra characters in the format specification
+       implicit none
+       real :: r
+       r = 1.0
+       write(*,'(a),f)') 'Hello', r   !{ dg-warning "Extraneous characters in format at" }
+       end