Commit 66faed76 by Daniel Franke Committed by Daniel Franke

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
parent 749aa96d
2010-05-19 Daniel Franke <franke.daniel@gmail.com> 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 PR fortran/34505
* intrinsic.h (gfc_check_float): New prototype. * intrinsic.h (gfc_check_float): New prototype.
(gfc_check_sngl): New prototype. (gfc_check_sngl): New prototype.
......
...@@ -154,9 +154,10 @@ create_character_intializer (gfc_expr *init, gfc_typespec *ts, ...@@ -154,9 +154,10 @@ create_character_intializer (gfc_expr *init, gfc_typespec *ts,
if (len > end - start) 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; len = end - start;
gfc_warning_now ("initialization string truncated to match variable "
"at %L", &rvalue->where);
} }
if (rvalue->ts.type == BT_HOLLERITH) if (rvalue->ts.type == BT_HOLLERITH)
......
...@@ -868,12 +868,11 @@ match_string_constant (gfc_expr **result) ...@@ -868,12 +868,11 @@ match_string_constant (gfc_expr **result)
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
start_locus = gfc_current_locus;
c = gfc_next_char (); c = gfc_next_char ();
if (c == '\'' || c == '"') if (c == '\'' || c == '"')
{ {
kind = gfc_default_character_kind; kind = gfc_default_character_kind;
start_locus = gfc_current_locus;
goto got_delim; goto got_delim;
} }
...@@ -917,12 +916,13 @@ match_string_constant (gfc_expr **result) ...@@ -917,12 +916,13 @@ match_string_constant (gfc_expr **result)
goto no_match; goto no_match;
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
start_locus = gfc_current_locus;
c = gfc_next_char (); c = gfc_next_char ();
if (c != '\'' && c != '"') if (c != '\'' && c != '"')
goto no_match; goto no_match;
start_locus = gfc_current_locus;
if (kind == -1) if (kind == -1)
{ {
q = gfc_extract_int (sym->value, &kind); q = gfc_extract_int (sym->value, &kind);
...@@ -976,7 +976,6 @@ got_delim: ...@@ -976,7 +976,6 @@ got_delim:
e->ts.is_iso_c = 0; e->ts.is_iso_c = 0;
gfc_current_locus = start_locus; gfc_current_locus = start_locus;
gfc_next_char (); /* Skip delimiter */
/* We disable the warning for the following loop as the warning has already /* We disable the warning for the following loop as the warning has already
been printed in the loop above. */ been printed in the loop above. */
......
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> 2010-05-19 Martin Jambor <mjambor@suse.cz>
* g++.dg/ipa/ivinline-8.C: New test. * g++.dg/ipa/ivinline-8.C: New test.
......
! { 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
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
program data_char_1 program data_char_1
character(len=5) :: a(2) character(len=5) :: a(2)
character(len=5) :: b(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) & 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 ((a(1) .ne. 'Hello') .or. (a(2) .ne. 'orld ')) call abort
if ((b(1) .ne. 'abcdj') .or. (b(2) .ne. 'hi k')) call abort if ((b(1) .ne. 'abcdj') .or. (b(2) .ne. 'hi k')) call abort
......
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