+2018-06-08 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/85631
+ * trans.h (gfc_ss): Add field no_bounds_check.
+ * trans-array.c (gfc_conv_ss_startstride): If flag_realloc_lhs and
+ ss->no_bounds_check is set, do not use runtime checks.
+ * trans-expr.c (gfc_trans_assignment_1): Set lss->no_bounds_check
+ for reallocatable lhs.
+
2018-06-08 Steven G. Kargl <kargl@gcc.gnu.org>
- PR fortran/86059
+ PR fortran/86059
* array.c (match_array_cons_element): NULL() cannot be in an
array constructor.
}
}
- /* The rest is just runtime bound checking. */
+ /* The rest is just runtime bounds checking. */
if (gfc_option.rtcheck & GFC_RTCHECK_BOUNDS)
{
stmtblock_t block;
continue;
/* Catch allocatable lhs in f2003. */
- if (flag_realloc_lhs && ss->is_alloc_lhs)
+ if (flag_realloc_lhs && ss->no_bounds_check)
continue;
expr = ss_info->expr;
/* Walk the lhs. */
lss = gfc_walk_expr (expr1);
- if (gfc_is_reallocatable_lhs (expr1)
- && !(expr2->expr_type == EXPR_FUNCTION
- && expr2->value.function.isym != NULL
- && !(expr2->value.function.isym->elemental
- || expr2->value.function.isym->conversion)))
- lss->is_alloc_lhs = 1;
+ if (gfc_is_reallocatable_lhs (expr1))
+ {
+ lss->no_bounds_check = 1;
+ if (!(expr2->expr_type == EXPR_FUNCTION
+ && expr2->value.function.isym != NULL
+ && !(expr2->value.function.isym->elemental
+ || expr2->value.function.isym->conversion)))
+ lss->is_alloc_lhs = 1;
+ }
rss = NULL;
struct gfc_loopinfo *loop;
unsigned is_alloc_lhs:1;
+ unsigned no_bounds_check:1;
}
gfc_ss;
#define gfc_get_ss() XCNEW (gfc_ss)
+2018-06-08 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/85631
+ * gfortran.dg/bounds_check_20.f90: New test.
+
2018-06-08 Carl Love <cel@us.ibm.com>
* gcc.target/powerpc/p8vector-builtin-3.c: Add vec_pack test. Update
2018-06-08 Steven G. Kargl <kargl@gcc.gnu.org>
- PR fortran/86059
+ PR fortran/86059
* gfortran.dg/associate_30.f90: Remove code tested ...
* gfortran.dg/pr67803.f90: Ditto.
* gfortran.dg/pr67805.f90: Ditto.
--- /dev/null
+! { dg-do run }
+! { dg-additional-options "-fcheck=bounds -ffrontend-optimize" }
+! PR 85631 - this used to cause a runtime error with bounds checking.
+module x
+contains
+ subroutine sub(a, b)
+ real, dimension(:,:), intent(in) :: a
+ real, dimension(:,:), intent(out), allocatable :: b
+ b = transpose(a)
+ end subroutine sub
+end module x
+
+program main
+ use x
+ implicit none
+ real, dimension(2,2) :: a
+ real, dimension(:,:), allocatable :: b
+ data a /-2., 3., -5., 7./
+ call sub(a, b)
+ if (any (b /= reshape([-2., -5., 3., 7.], shape(b)))) stop 1
+ b = matmul(transpose(b), a)
+ if (any (b /= reshape([-11., 15., -25., 34.], shape(b)))) stop 2
+end program
+