From: Francois-Xavier Coudert Date: Wed, 14 May 2008 21:17:54 +0000 (+0000) Subject: re PR fortran/35685 (UBOUND incorrect for run-time zero-sized section) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f10827b13be2d7f3a031c93ba6fcc35f81f762fd;p=gcc.git re PR fortran/35685 (UBOUND incorrect for run-time zero-sized section) PR fortran/35685 * trans-intrinsic.c (gfc_conv_intrinsic_bound): Correctly handle zero-size sections. * gfortran.dg/bound_3.f90: New test. From-SVN: r135305 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7ed34a61c08..d478a2511df 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2008-05-14 Francois-Xavier Coudert + + PR fortran/35685 + * trans-intrinsic.c (gfc_conv_intrinsic_bound): Correctly + handle zero-size sections. + 2008-05-14 Francois-Xavier Coudert PR fortran/36215 diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 9f022e7a09d..2f9cadd199a 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -938,6 +938,8 @@ gfc_conv_intrinsic_bound (gfc_se * se, gfc_expr * expr, int upper) size = fold_build2 (MINUS_EXPR, gfc_array_index_type, ubound, lbound); se->expr = fold_build2 (PLUS_EXPR, gfc_array_index_type, size, gfc_index_one_node); + se->expr = fold_build2 (MAX_EXPR, gfc_array_index_type, se->expr, + gfc_index_zero_node); } else se->expr = gfc_index_one_node; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ab790da0667..f2795bb9c1f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-05-14 Francois-Xavier Coudert + + PR fortran/35685 + * gfortran.dg/bound_3.f90: New test. + 2008-05-14 Michael Meissner Dwarakanath Rajagopal diff --git a/gcc/testsuite/gfortran.dg/bound_3.f90 b/gcc/testsuite/gfortran.dg/bound_3.f90 new file mode 100644 index 00000000000..7b1696d09f6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/bound_3.f90 @@ -0,0 +1,20 @@ +! { dg-do run } +! + call s(1,0) + call s(2,0) + call s(3,0) + call s(4,0) + call s(5,1) + call s(6,2) + call s(7,3) +contains + subroutine s(n,m) + implicit none + integer n, m + real x(10) + if (any (lbound(x(5:n)) /= 1)) call abort + if (lbound(x(5:n),1) /= 1) call abort + if (any (ubound(x(5:n)) /= m)) call abort + if (ubound(x(5:n),1) /= m) call abort + end subroutine +end program