]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/29452 (Keyword check for specifiers in WRITE and READ)
authorTobias Burnus <burnus@net-b.de>
Mon, 30 Oct 2006 18:22:47 +0000 (19:22 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Mon, 30 Oct 2006 18:22:47 +0000 (19:22 +0100)
fortran/
2006-10-30  Tobias Burnus  <burnus@net-b.de>

        PR fortran/29452
        * io.c (check_io_constraints): Fix keyword string comparison.

libgfortran/
2006-10-30  Tobias Burnus  <burnus@net-b.de>

        PR fortran/29452
* runtime/string.c (compare0): Check whether string lengths match.

testsuite/
2006-10-30  Tobias Burnus  <burnus@net-b.de>

PR fortran/29452
* gfortran.dg/write_check.f90: Check run-time keyword checking.
* gfortran.dg/write_check2.f90: Check compile-time keyword checking

From-SVN: r118191

gcc/fortran/ChangeLog
gcc/fortran/io.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/write_check.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/write_check2.f90 [new file with mode: 0644]
libgfortran/ChangeLog
libgfortran/runtime/string.c

index 25ace324b40486d76491a18857b3abc4eda715fd..f6ea47990e6462a5d140bab92857c08c9233ac77 100644 (file)
@@ -1,3 +1,8 @@
+2006-10-30  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/29452
+       * io.c (check_io_constraints): Fix keyword string comparison.
+
 2006-10-30  Andrew Pinski  <pinskia@gmail.com>
 
        PR fortran/29410
        * io.c (gfc_match_close): Ensure that status is terminated by
        a NULL element.
 
-2006-10-16  Tobias Burnus <burnus@net-b.de>
+2006-10-16  Tobias Burnus  <burnus@net-b.de>
 
        * trans-stmt.c: Fix a typo
        * invoke.texi: Fix typos
index cbb7cf90b062b4d42057bc83b83ab13b01c4fe4d..ae9df4a967b6c22f672ea5040cf1733436f2779f 100644 (file)
@@ -2701,8 +2701,8 @@ if (condition) \
       if (expr->expr_type == EXPR_CONSTANT && expr->ts.type == BT_CHARACTER)
        {
          const char * advance = expr->value.character.string;
-         not_no = strncasecmp (advance, "no", 2) != 0;
-         not_yes = strncasecmp (advance, "yes", 2) != 0;
+         not_no = strcasecmp (advance, "no") != 0;
+         not_yes = strcasecmp (advance, "yes") != 0;
        }
       else
        {
index f8876e353d7da0ef3333006296f300a8470cc80a..f9da3e8885b77c6bec0337fd7e4c502c2fe2bd18 100644 (file)
@@ -1,3 +1,9 @@
+2006-10-30  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/29452
+       * gfortran.dg/write_check.f90: Check run-time keyword checking.
+       * gfortran.dg/write_check2.f90: Check compile-time keyword checking.
+
 2006-10-30  Andrew Pinski  <pinskia@gmail.com>
 
        PR Fortran/29410
diff --git a/gcc/testsuite/gfortran.dg/write_check.f90 b/gcc/testsuite/gfortran.dg/write_check.f90
new file mode 100644 (file)
index 0000000..4172303
--- /dev/null
@@ -0,0 +1,16 @@
+! { dg-do run }
+! { dg-shouldfail "Compile-time specifier checking" }
+! Check keyword checking for specifiers
+! PR fortran/29452
+program test
+  implicit none
+  character(len=5) :: str
+  str = 'yes'
+  write(*,'(a)',advance=str) ''
+  str = 'no'
+  write(*,'(a)',advance=str) ''
+  str = 'NOT'
+  write(*,'(a)',advance=str) ''
+end program test
+! { dg-output "At line 13 of file.*" }
+! { dg-output "Bad ADVANCE parameter in data transfer statement" }
diff --git a/gcc/testsuite/gfortran.dg/write_check2.f90 b/gcc/testsuite/gfortran.dg/write_check2.f90
new file mode 100644 (file)
index 0000000..52f32bb
--- /dev/null
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! Check keyword checking for specifiers
+! PR fortran/29452
+  character(len=20) :: str
+  write(13,'(a)',advance='yes')  'Hello:'
+  write(13,'(a)',advance='no')   'Hello:'
+  write(13,'(a)',advance='y')    'Hello:' ! { dg-error "ADVANCE=specifier at \\(1\\) must have value = YES or NO." }
+  write(13,'(a)',advance='yet')  'Hello:' ! { dg-error "ADVANCE=specifier at \\(1\\) must have value = YES or NO." }
+  write(13,'(a)',advance='yess') 'Hello:' ! { dg-error "ADVANCE=specifier at \\(1\\) must have value = YES or NO." }
+  end
index 82db785e1b5899ce83b166bd89a3b8ad9680fdf2..6dd8270db2250025418b5528643f2ba6393d27f3 100644 (file)
@@ -1,3 +1,8 @@
+2006-10-30  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/29452
+       * runtime/string.c (compare0): Check whether string lengths match.
+
 2006-10-29  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
        * configure: Regenerate.
index 00dfc298305168111aa89e6abf4c3d93b5827758..a92082f73ee9cc24708c9ffe1312ae4dd993c8f7 100644 (file)
@@ -44,6 +44,7 @@ compare0 (const char *s1, int s1_len, const char *s2)
 
   /* Strip trailing blanks from the Fortran string.  */
   len = fstrlen (s1, s1_len);
+  if(len != strlen(s2)) return 0; /* don't match */
   return strncasecmp (s1, s2, len) == 0;
 }