From 9aceacac9268f061154de7b0596f7f935fc52d46 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Mon, 30 Oct 2006 19:22:47 +0100 Subject: [PATCH] re PR fortran/29452 (Keyword check for specifiers in WRITE and READ) fortran/ 2006-10-30 Tobias Burnus PR fortran/29452 * io.c (check_io_constraints): Fix keyword string comparison. libgfortran/ 2006-10-30 Tobias Burnus PR fortran/29452 * runtime/string.c (compare0): Check whether string lengths match. testsuite/ 2006-10-30 Tobias Burnus 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 | 7 ++++++- gcc/fortran/io.c | 4 ++-- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gfortran.dg/write_check.f90 | 16 ++++++++++++++++ gcc/testsuite/gfortran.dg/write_check2.f90 | 10 ++++++++++ libgfortran/ChangeLog | 5 +++++ libgfortran/runtime/string.c | 1 + 7 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/write_check.f90 create mode 100644 gcc/testsuite/gfortran.dg/write_check2.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 25ace324b40..f6ea47990e6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2006-10-30 Tobias Burnus + + PR fortran/29452 + * io.c (check_io_constraints): Fix keyword string comparison. + 2006-10-30 Andrew Pinski PR fortran/29410 @@ -149,7 +154,7 @@ * io.c (gfc_match_close): Ensure that status is terminated by a NULL element. -2006-10-16 Tobias Burnus +2006-10-16 Tobias Burnus * trans-stmt.c: Fix a typo * invoke.texi: Fix typos diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index cbb7cf90b06..ae9df4a967b 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -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 { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f8876e353d7..f9da3e8885b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2006-10-30 Tobias Burnus + + 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 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 index 00000000000..4172303926a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/write_check.f90 @@ -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 index 00000000000..52f32bb121c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/write_check2.f90 @@ -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 diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 82db785e1b5..6dd8270db22 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,8 @@ +2006-10-30 Tobias Burnus + + PR fortran/29452 + * runtime/string.c (compare0): Check whether string lengths match. + 2006-10-29 Francois-Xavier Coudert * configure: Regenerate. diff --git a/libgfortran/runtime/string.c b/libgfortran/runtime/string.c index 00dfc298305..a92082f73ee 100644 --- a/libgfortran/runtime/string.c +++ b/libgfortran/runtime/string.c @@ -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; }