From: mikael Date: Fri, 7 Sep 2012 20:37:41 +0000 (+0000) Subject: fortran/ X-Git-Tag: upstream/4.9.2~10757 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=853d9607b52cfb57cc00231ba81bcf2bf45e7507;p=platform%2Fupstream%2Flinaro-gcc.git fortran/ PR fortran/54208 * simplify.c (simplify_bound_dim): Resolve array spec before proceeding with simplification. testsuite/ PR fortran/54208 * gfortran.dg/bound_simplification_3.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191083 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d237a24..f0e6cad 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2012-09-07 Mikael Morin + + PR fortran/54208 + * simplify.c (simplify_bound_dim): Resolve array spec before + proceeding with simplification. + 2012-09-06 Tobias Burnus PR fortran/54463 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index e4ccddf..07aeee8 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -3255,6 +3255,9 @@ simplify_bound_dim (gfc_expr *array, gfc_expr *kind, int d, int upper, gcc_assert (array->expr_type == EXPR_VARIABLE); gcc_assert (as); + if (gfc_resolve_array_spec (as, 0) == FAILURE) + return NULL; + /* The last dimension of an assumed-size array is special. */ if ((!coarray && d == as->rank && as->type == AS_ASSUMED_SIZE && !upper) || (coarray && d == as->rank + as->corank diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e4ea111..c977af8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-09-07 Mikael Morin + + PR fortran/54208 + * gfortran.dg/bound_simplification_3.f90: New test. + 2012-09-07 Aldy Hernandez PR testsuite/54184 diff --git a/gcc/testsuite/gfortran.dg/bound_simplification_3.f90 b/gcc/testsuite/gfortran.dg/bound_simplification_3.f90 new file mode 100644 index 0000000..de3a3dc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/bound_simplification_3.f90 @@ -0,0 +1,23 @@ +! { dg-do compile } +! { dg-options "-fdump-tree-original" } +! +! PR fortran/54208 +! The I and J definitions used to raise an error because ARR's array spec +! was resolved to late for the LBOUND and UBOUND calls to be simplified to +! a constant. +! +! Contributed by Carlos A. Cruz + +program testit + integer, parameter :: n=2 + integer, dimension(1-min(n,2)/2:n) :: arr + integer, parameter :: i=lbound(arr,1) + integer, parameter :: j=ubound(arr,1) + ! write(6,*) i, j + if (i /= 0) call abort + if (j /= 2) call abort +end program testit + +! { dg-final { scan-tree-dump-times "bound" 0 "original" } } +! { dg-final { scan-tree-dump-times "abort" 0 "original" } } +! { dg-final { cleanup-tree-dump "original" } }