This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, fortran] Fix PR 33539
- From: Thomas Koenig <tkoenig at netcologne dot de>
- To: fortran at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 04 Oct 2007 22:10:25 +0200
- Subject: [patch, fortran] Fix PR 33539
Hello world,
this fixes PR 33539 by not issuing a warning for strings
that have zero length. Regression-tested on i686-pc-linux-gnu.
No special test case needed; I just removed dg-warning lines from
the places where they occurred in the testsuite.
OK? (Also OK with the approach of not warning)?
Thomas
2007-10-04 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/33539
* resolve.c: Only warn if the string length is
less than zero.
2007-10-04 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/33539
* zero_length_2.f90: Omit warning for zero-length string.
* repeat_2.f90: Likewise.
* repeat_4.f90: Likewise.
* char_length_2.f90: Likewise.
Index: fortran/resolve.c
===================================================================
--- fortran/resolve.c (revision 128885)
+++ fortran/resolve.c (working copy)
@@ -6563,7 +6563,7 @@ resolve_charlen (gfc_charlen *cl)
/* "If the character length parameter value evaluates to a negative
value, the length of character entities declared is zero." */
- if (cl->length && !gfc_extract_int (cl->length, &i) && i <= 0)
+ if (cl->length && !gfc_extract_int (cl->length, &i) && i < 0)
{
gfc_warning_now ("CHARACTER variable has zero length at %L",
&cl->length->where);
Index: testsuite/gfortran.dg/zero_length_2.f90
===================================================================
--- testsuite/gfortran.dg/zero_length_2.f90 (revision 128885)
+++ testsuite/gfortran.dg/zero_length_2.f90 (working copy)
@@ -1,6 +1,6 @@
! { dg-do run }
character(len=1) :: s
- character(len=0) :: s0 ! { dg-warning "CHARACTER variable has zero length" }
+ character(len=0) :: s0
s = " "
s0 = ""
call bar ("")
Index: testsuite/gfortran.dg/repeat_2.f90
===================================================================
--- testsuite/gfortran.dg/repeat_2.f90 (revision 128885)
+++ testsuite/gfortran.dg/repeat_2.f90 (working copy)
@@ -22,10 +22,10 @@ end subroutine bar
program test
implicit none
- character(len=0), parameter :: s0 = "" ! { dg-warning "zero length" }
+ character(len=0), parameter :: s0 = ""
character(len=1), parameter :: s1 = "a"
character(len=2), parameter :: s2 = "ab"
- character(len=0) :: t0 ! { dg-warning "CHARACTER variable has zero length" }
+ character(len=0) :: t0
character(len=1) :: t1
character(len=2) :: t2
integer :: i
Index: testsuite/gfortran.dg/repeat_4.f90
===================================================================
--- testsuite/gfortran.dg/repeat_4.f90 (revision 128885)
+++ testsuite/gfortran.dg/repeat_4.f90 (working copy)
@@ -3,10 +3,10 @@
! { dg-do compile }
program test
implicit none
- character(len=0), parameter :: s0 = "" ! { dg-warning "zero length" }
+ character(len=0), parameter :: s0 = ""
character(len=1), parameter :: s1 = "a"
character(len=2), parameter :: s2 = "ab"
- character(len=0) :: t0 ! { dg-warning "CHARACTER variable has zero length" }
+ character(len=0) :: t0
character(len=1) :: t1
character(len=2) :: t2
Index: testsuite/gfortran.dg/char_length_2.f90
===================================================================
--- testsuite/gfortran.dg/char_length_2.f90 (revision 128885)
+++ testsuite/gfortran.dg/char_length_2.f90 (working copy)
@@ -3,7 +3,7 @@
! CHARACTER lengths weren't reduced early enough for all checks of
! them to be meaningful. Furthermore negative string lengths weren't
! dealt with correctly.
-CHARACTER(len=0) :: c1 ! { dg-warning "CHARACTER variable has zero length" }
+CHARACTER(len=0) :: c1 ! This is OK.
CHARACTER(len=-1) :: c2 ! { dg-warning "CHARACTER variable has zero length" }
PARAMETER(I=-100)
CHARACTER(len=I) :: c3 ! { dg-warning "CHARACTER variable has zero length" }