re PR fortran/38404 (Warning message identifies incorrect line)

gcc/fortran/:
2010-05-19  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/38404
	* primary.c (match_string_constant): Move start_locus just inside 
	the string.
	* data.c (create_character_intializer): Clarified truncation warning.

gcc/testsuite/:
2010-05-19  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/38404
	* gfortran.dg/data_char_1.f90: Updated warning message.
	* gfortran.dg/data_array_6.f: New.

From-SVN: r159561
This commit is contained in:
Daniel Franke 2010-05-19 08:55:26 -04:00 committed by Daniel Franke
parent 749aa96dab
commit 66faed7643
6 changed files with 40 additions and 8 deletions

View file

@ -1,3 +1,10 @@
2010-05-19 Daniel Franke <franke.daniel@gmail.com>
PR fortran/38404
* primary.c (match_string_constant): Move start_locus just inside
the string.
* data.c (create_character_intializer): Clarified truncation warning.
2010-05-19 Daniel Franke <franke.daniel@gmail.com>
PR fortran/34505

View file

@ -154,9 +154,10 @@ create_character_intializer (gfc_expr *init, gfc_typespec *ts,
if (len > end - start)
{
gfc_warning_now ("Initialization string starting at %L was "
"truncated to fit the variable (%d/%d)",
&rvalue->where, end - start, len);
len = end - start;
gfc_warning_now ("initialization string truncated to match variable "
"at %L", &rvalue->where);
}
if (rvalue->ts.type == BT_HOLLERITH)

View file

@ -868,12 +868,11 @@ match_string_constant (gfc_expr **result)
gfc_gobble_whitespace ();
start_locus = gfc_current_locus;
c = gfc_next_char ();
if (c == '\'' || c == '"')
{
kind = gfc_default_character_kind;
start_locus = gfc_current_locus;
goto got_delim;
}
@ -917,12 +916,13 @@ match_string_constant (gfc_expr **result)
goto no_match;
gfc_gobble_whitespace ();
start_locus = gfc_current_locus;
c = gfc_next_char ();
if (c != '\'' && c != '"')
goto no_match;
start_locus = gfc_current_locus;
if (kind == -1)
{
q = gfc_extract_int (sym->value, &kind);
@ -976,7 +976,6 @@ got_delim:
e->ts.is_iso_c = 0;
gfc_current_locus = start_locus;
gfc_next_char (); /* Skip delimiter */
/* We disable the warning for the following loop as the warning has already
been printed in the loop above. */

View file

@ -1,3 +1,9 @@
2010-05-19 Daniel Franke <franke.daniel@gmail.com>
PR fortran/38404
* gfortran.dg/data_char_1.f90: Updated warning message.
* gfortran.dg/data_array_6.f: New.
2010-05-19 Martin Jambor <mjambor@suse.cz>
* g++.dg/ipa/ivinline-8.C: New test.

View file

@ -0,0 +1,19 @@
! { dg-do "compile" }
!
! PR fortran/38404 - location marker in wrong line
! Testcase contributed by Steve Chapel <steve DOT chapel AT a2pg DOT com>
!
CHARACTER(len=72) TEXT(3)
DATA (TEXT(I),I=1,3)/
&'a string without issues',
&'a string with too many characters properly broken into the next
&line but too long to fit the variable',
& '
&a string that started just at the end of the last line -- some
&may not be helped'/
! { dg-warning "truncated" "" { target *-*-* } 10 }
! { dg-warning "truncated" "" { target *-*-* } 12 }
END

View file

@ -5,9 +5,9 @@
program data_char_1
character(len=5) :: a(2)
character(len=5) :: b(2)
data a /'Hellow', 'orld'/ ! { dg-warning "string truncated" }
data a /'Hellow', 'orld'/ ! { dg-warning "truncated" }
data b(:)(1:4), b(1)(5:5), b(2)(5:5) &
/'abcdefg', 'hi', 'j', 'k'/ ! { dg-warning "string truncated" }
/'abcdefg', 'hi', 'j', 'k'/ ! { dg-warning "truncated" }
if ((a(1) .ne. 'Hello') .or. (a(2) .ne. 'orld ')) call abort
if ((b(1) .ne. 'abcdj') .or. (b(2) .ne. 'hi k')) call abort