Commit 5e1d6b4c by Daniel Kraft Committed by Daniel Kraft

re PR fortran/39171 (Misleading warning for negative character length)

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/39171
	* gfortran.dg/char_length_2.f90: Change warning expectations accordingly
	and pass -Wsurprising as necessary.

From-SVN: r156620
parent d0d4124c
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 PR fortran/41507
* intrinsic.texi (MAXVAL): Remove wrong claim that array argument * intrinsic.texi (MAXVAL): Remove wrong claim that array argument
can be CHARACTER type. can be CHARACTER type.
......
...@@ -792,6 +792,9 @@ A TRANSFER specifies a source that is shorter than the destination. ...@@ -792,6 +792,9 @@ A TRANSFER specifies a source that is shorter than the destination.
@item @item
The type of a function result is declared more than once with the same type. If 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. @option{-pedantic} or standard-conforming mode is enabled, this is an error.
@item
A @code{CHARACTER} variable is declared with negative length.
@end itemize @end itemize
@item -Wtabs @item -Wtabs
......
...@@ -8559,8 +8559,10 @@ resolve_charlen (gfc_charlen *cl) ...@@ -8559,8 +8559,10 @@ resolve_charlen (gfc_charlen *cl)
value, the length of character entities declared is zero." */ 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", if (gfc_option.warn_surprising)
&cl->length->where); 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));
} }
......
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> 2010-02-08 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/42890 PR tree-optimization/42890
......
! { dg-do link } ! { dg-do link }
! { dg-options "-Wsurprising" }
! Tests the fix for PR 31250 ! Tests the fix for PR 31250
! CHARACTER lengths weren't reduced early enough for all checks of ! CHARACTER lengths weren't reduced early enough for all checks of
! them to be meaningful. Furthermore negative string lengths weren't ! them to be meaningful. Furthermore negative string lengths weren't
! dealt with correctly. ! dealt with correctly.
CHARACTER(len=0) :: c1 ! This is OK. 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=I) :: c3 ! { dg-warning "has negative length" }
CHARACTER(len=min(I,500)) :: c4 ! { dg-warning "CHARACTER variable has zero length" } CHARACTER(len=min(I,500)) :: c4 ! { dg-warning "has negative length" }
CHARACTER(len=max(I,500)) :: d1 ! no warning CHARACTER(len=max(I,500)) :: d1 ! no warning
CHARACTER(len=5) :: d2 ! no warning CHARACTER(len=5) :: d2 ! no warning
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment