From ad7082e3d95afb5f313a8663050876ef5fd35534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Schl=C3=BCter?= Date: Tue, 12 Dec 2006 21:59:21 +0100 Subject: 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 --- gcc/fortran/ChangeLog | 7 ++++++- gcc/fortran/trans-expr.c | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'gcc/fortran') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e3b6852..eb9efa1 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,6 +1,11 @@ +2006-12-12 Tobias Schlüter + + * trans-expr.c (gfc_conv_substring): Check for empty substring. + 2006-12-11 Jan Hubicka - * f59-lang.c (gfc_expand_function): Update for renamed varpool functions. + * f95-lang.c (gfc_expand_function): Update for renamed varpool + functions. 2006-12-10 Tobias Burnus 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); -- cgit v1.1