OSDN Git Service

2010-02-09 Daniel Kraft <d@domob.eu>
authordomob <domob@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 9 Feb 2010 10:44:33 +0000 (10:44 +0000)
committerdomob <domob@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 9 Feb 2010 10:44:33 +0000 (10:44 +0000)
PR fortran/39171
* resolve.c (resolve_charlen): Change warning about negative CHARACTER
length to be correct and issue only with -Wsurprising.
* invoke.texi (Wsurprising): Mention this new warning that is
turned on by -Wsurprising.

2010-02-09  Daniel Kraft  <d@domob.eu>

PR fortran/39171
* gfortran.dg/char_length_2.f90: Change warning expectations accordingly
and pass -Wsurprising as necessary.

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

gcc/fortran/ChangeLog
gcc/fortran/invoke.texi
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/char_length_2.f90

index cd0c1be..3c6d009 100644 (file)
@@ -1,5 +1,13 @@
 2010-02-09  Daniel Kraft  <d@domob.eu>
 
 2010-02-09  Daniel Kraft  <d@domob.eu>
 
+       PR fortran/39171
+       * resolve.c (resolve_charlen): Change warning about negative CHARACTER
+       length to be correct and issue only with -Wsurprising.
+       * invoke.texi (Wsurprising): Mention this new warning that is
+       turned on by -Wsurprising.
+
+2010-02-09  Daniel Kraft  <d@domob.eu>
+
        PR fortran/41507
        * intrinsic.texi (MAXVAL): Remove wrong claim that array argument
        can be CHARACTER type.
        PR fortran/41507
        * intrinsic.texi (MAXVAL): Remove wrong claim that array argument
        can be CHARACTER type.
index 21db293..88a395d 100644 (file)
@@ -792,6 +792,9 @@ A TRANSFER specifies a source that is shorter than the destination.
 @item
 The type of a function result is declared more than once with the same type.  If
 @option{-pedantic} or standard-conforming mode is enabled, this is an error.
 @item
 The type of a function result is declared more than once with the same type.  If
 @option{-pedantic} or standard-conforming mode is enabled, this is an error.
+
+@item
+A @code{CHARACTER} variable is declared with negative length.
 @end itemize
 
 @item -Wtabs
 @end itemize
 
 @item -Wtabs
index d0aa6ad..b525e32 100644 (file)
@@ -8559,8 +8559,10 @@ resolve_charlen (gfc_charlen *cl)
      value, the length of character entities declared is zero."  */
   if (cl->length && !gfc_extract_int (cl->length, &i) && i < 0)
     {
      value, the length of character entities declared is zero."  */
   if (cl->length && !gfc_extract_int (cl->length, &i) && i < 0)
     {
-      gfc_warning_now ("CHARACTER variable has zero length at %L",
-                      &cl->length->where);
+      if (gfc_option.warn_surprising)
+       gfc_warning_now ("CHARACTER variable at %L has negative length %d,"
+                        " the length has been set to zero",
+                        &cl->length->where, i);
       gfc_replace_expr (cl->length, gfc_int_expr (0));
     }
 
       gfc_replace_expr (cl->length, gfc_int_expr (0));
     }
 
index 040b2a2..c92c428 100644 (file)
@@ -1,3 +1,9 @@
+2010-02-09  Daniel Kraft  <d@domob.eu>
+
+       PR fortran/39171
+       * gfortran.dg/char_length_2.f90: Change warning expectations accordingly
+       and pass -Wsurprising as necessary.
+
 2010-02-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/42890
 2010-02-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/42890
index a519c54..5673a2e 100644 (file)
@@ -1,13 +1,14 @@
 ! { dg-do link }
 ! { dg-do link }
+! { dg-options "-Wsurprising" }
 ! Tests the fix for PR 31250
 ! 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   ! This is OK.
 ! Tests the fix for PR 31250
 ! 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   ! This is OK.
-CHARACTER(len=-1) :: c2  ! { dg-warning "CHARACTER variable has zero length" }
+CHARACTER(len=-1) :: c2  ! { dg-warning "has negative length" }
 PARAMETER(I=-100)
 PARAMETER(I=-100)
-CHARACTER(len=I) :: c3   ! { dg-warning "CHARACTER variable has zero length" }
-CHARACTER(len=min(I,500)) :: c4  ! { dg-warning "CHARACTER variable has zero length" }
+CHARACTER(len=I) :: c3   ! { dg-warning "has negative length" }
+CHARACTER(len=min(I,500)) :: c4  ! { dg-warning "has negative length" }
 CHARACTER(len=max(I,500)) :: d1  ! no warning
 CHARACTER(len=5) :: d2   ! no warning
 
 CHARACTER(len=max(I,500)) :: d1  ! no warning
 CHARACTER(len=5) :: d2   ! no warning