aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-expr.c
diff options
context:
space:
mode:
authorTobias Schlüter <tobi@gcc.gnu.org>2006-12-12 21:59:21 +0100
committerTobias Schlüter <tobi@gcc.gnu.org>2006-12-12 21:59:21 +0100
commitad7082e3d95afb5f313a8663050876ef5fd35534 (patch)
treeebe6161c8b4daad75b3bc7aef87776ccb21980b5 /gcc/fortran/trans-expr.c
parent0cf9e3a4be73380dd59958bc800f83e04893afb0 (diff)
downloadgcc-ad7082e3d95afb5f313a8663050876ef5fd35534.zip
gcc-ad7082e3d95afb5f313a8663050876ef5fd35534.tar.gz
gcc-ad7082e3d95afb5f313a8663050876ef5fd35534.tar.bz2
trans-expr.c (gfc_conv_substring): Check for empty substring.
fortran/ * trans-expr.c (gfc_conv_substring): Check for empty substring. testsuite/ * lib/fortran-torture.exp: Update copyright years. Remove obsolete comment. Test -ftree-vectorize where it makes sense. * lib/gfortran-dg.exp: Update copyright years. Use settings from fortran-torture.exp. * gfortran.dg/char_transpose_1.f90, gfortran.dg/char_spread_1.f90, gfortran.dg/g77/dnrm2.f, gfortran.dg/dependent_decls_1.f90: Fixout-of-bound errors. * gfortran.dg/enum_10.f90, gfortran.dg/mixed_io_1.f90: Add '-w' to dg-options. From-SVN: r119797
Diffstat (limited to 'gcc/fortran/trans-expr.c')
-rw-r--r--gcc/fortran/trans-expr.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 7c064ff..04736d5 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -278,9 +278,14 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind,
}
if (flag_bounds_check)
{
+ tree nonempty = fold_build2 (LE_EXPR, boolean_type_node,
+ start.expr, end.expr);
+
/* Check lower bound. */
fault = fold_build2 (LT_EXPR, boolean_type_node, start.expr,
build_int_cst (gfc_charlen_type_node, 1));
+ fault = fold_build2 (TRUTH_ANDIF_EXPR, boolean_type_node,
+ nonempty, fault);
if (name)
asprintf (&msg, "Substring out of bounds: lower bound of '%s' "
"is less than one", name);
@@ -293,6 +298,8 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind,
/* Check upper bound. */
fault = fold_build2 (GT_EXPR, boolean_type_node, end.expr,
se->string_length);
+ fault = fold_build2 (TRUTH_ANDIF_EXPR, boolean_type_node,
+ nonempty, fault);
if (name)
asprintf (&msg, "Substring out of bounds: upper bound of '%s' "
"exceeds string length", name);