diff options
author | Francois-Xavier Coudert <coudert@clipper.ens.fr> | 2006-06-24 20:10:47 +0200 |
---|---|---|
committer | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2006-06-24 18:10:47 +0000 |
commit | 97bca5132a023e28006681eb5f77c5cec69eb52d (patch) | |
tree | ee1b46d136cd96d996c92541874c42defcc70489 /gcc/fortran/resolve.c | |
parent | 8fa36578242417c8fe58f9c513bc3995a69393d9 (diff) | |
download | gcc-97bca5132a023e28006681eb5f77c5cec69eb52d.zip gcc-97bca5132a023e28006681eb5f77c5cec69eb52d.tar.gz gcc-97bca5132a023e28006681eb5f77c5cec69eb52d.tar.bz2 |
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
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r-- | gcc/fortran/resolve.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 384b5a4..fe37f2c 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -2542,7 +2542,9 @@ resolve_substring (gfc_ref * ref) 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", &ref->u.ss.start->where); @@ -2570,9 +2572,11 @@ resolve_substring (gfc_ref * ref) } 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); return FAILURE; } |