Commit 97bca513 by Francois-Xavier Coudert Committed by François-Xavier Coudert

re PR fortran/28081 (Undue compile-time error for zero-sized substring)

	PR fortran/28081

	* resolve.c (resolve_substring): Don't issue out-of-bounds
	error messages when the range has zero size.

	* gfortran.dg/substr_3.f: New test.
	* gfortran.dg/equiv_2.f90: Update expected error message.

From-SVN: r114972
parent 8fa36578
2006-06-24 Francois-Xavier Coudert <coudert@clipper.ens.fr> 2006-06-24 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR fortran/28081
* resolve.c (resolve_substring): Don't issue out-of-bounds
error messages when the range has zero size.
2006-06-24 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR fortran/23862 PR fortran/23862
* lang-specs.h (f95-cpp-input): Pass -ffree-form to f951 unless * lang-specs.h (f95-cpp-input): Pass -ffree-form to f951 unless
-ffixed-form is explicitly specified. -ffixed-form is explicitly specified.
......
...@@ -2542,7 +2542,9 @@ resolve_substring (gfc_ref * ref) ...@@ -2542,7 +2542,9 @@ resolve_substring (gfc_ref * ref)
return FAILURE; return FAILURE;
} }
if (compare_bound_int (ref->u.ss.start, 1) == CMP_LT) if (compare_bound_int (ref->u.ss.start, 1) == CMP_LT
&& (compare_bound (ref->u.ss.end, ref->u.ss.start) == CMP_EQ
|| compare_bound (ref->u.ss.end, ref->u.ss.start) == CMP_GT))
{ {
gfc_error ("Substring start index at %L is less than one", gfc_error ("Substring start index at %L is less than one",
&ref->u.ss.start->where); &ref->u.ss.start->where);
...@@ -2570,9 +2572,11 @@ resolve_substring (gfc_ref * ref) ...@@ -2570,9 +2572,11 @@ resolve_substring (gfc_ref * ref)
} }
if (ref->u.ss.length != NULL if (ref->u.ss.length != NULL
&& compare_bound (ref->u.ss.end, ref->u.ss.length->length) == CMP_GT) && compare_bound (ref->u.ss.end, ref->u.ss.length->length) == CMP_GT
&& (compare_bound (ref->u.ss.end, ref->u.ss.start) == CMP_EQ
|| compare_bound (ref->u.ss.end, ref->u.ss.start) == CMP_GT))
{ {
gfc_error ("Substring end index at %L is out of bounds", gfc_error ("Substring end index at %L exceeds the string length",
&ref->u.ss.start->where); &ref->u.ss.start->where);
return FAILURE; return FAILURE;
} }
......
2006-06-24 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR fortran/28081
* gfortran.dg/substr_3.f: New test.
* gfortran.dg/equiv_2.f90: Update expected error message.
2006-06-24 Paul Thomas <pault@gcc.gnu.org> 2006-06-24 Paul Thomas <pault@gcc.gnu.org>
PR fortran/28118 PR fortran/28118
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
subroutine broken_equiv2 subroutine broken_equiv2
character*4 j character*4 j
character*2 k character*2 k
equivalence (j(2:3), k(1:5)) ! { dg-error "out of bounds" } equivalence (j(2:3), k(1:5)) ! { dg-error "exceeds the string length" }
end subroutine end subroutine
subroutine broken_equiv3 subroutine broken_equiv3
......
! { dg-do run }
! Check that substrings behave correctly even when zero-sized
implicit none
character(len=10) :: s, t
integer :: i, j
s = "abcdefghij"
t(:10) = s(1:)
s(16:15) = "foo"
s(0:-1) = "foo"
if (s /= t) call abort
end
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