From b6f42c2cc3f50fa7c7982585574b9bee5536035e Mon Sep 17 00:00:00 2001 From: mikael Date: Fri, 25 Nov 2011 20:18:21 +0000 Subject: [PATCH] fortran/ PR fortran/51250 PR fortran/43829 * trans-array.c (gfc_trans_create_temp_array): Get dimension from the right gfc_ss struct. testsuite/ PR fortran/51250 PR fortran/43829 * gfortran.dg/inline_sum_3.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181730 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/trans-array.c | 2 +- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gfortran.dg/inline_sum_3.f90 | 31 ++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/inline_sum_3.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f0faca4..d669f5a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2011-11-25 Mikael Morin + + PR fortran/51250 + PR fortran/43829 + * trans-array.c (gfc_trans_create_temp_array): Get dimension from + the right gfc_ss struct. + 2011-11-25 Tobias Burnus PR fortran/50408 diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 2fb2d34..943503a 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -1087,7 +1087,7 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, gfc_ss * ss, for (s = ss; s; s = s->parent) for (n = 0; n < s->loop->dimen; n++) { - dim = get_scalarizer_dim_for_array_dim (ss, ss->dim[n]); + dim = get_scalarizer_dim_for_array_dim (ss, s->dim[n]); /* For a callee allocated array express the loop bounds in terms of the descriptor fields. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 68c78f7..eafeb9e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-11-25 Mikael Morin + + PR fortran/51250 + PR fortran/43829 + * gfortran.dg/inline_sum_3.f90: New test. + 2011-11-25 Uros Bizjak PR testsuite/51258 diff --git a/gcc/testsuite/gfortran.dg/inline_sum_3.f90 b/gcc/testsuite/gfortran.dg/inline_sum_3.f90 new file mode 100644 index 0000000..6858228 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/inline_sum_3.f90 @@ -0,0 +1,31 @@ +! { dg-do run } +! +! PR fortran/51250 +! Wrong loop shape for SUM when arguments are library-allocated arrays. +! +! Original testcase provided by Harald Anlauf + +program gfcbug115 + implicit none + integer :: n_obstype = 2 + integer :: nboxes = 1 + integer :: nprocs = 1 + integer :: nbox, j + integer, allocatable :: nbx(:,:), pes(:) + + allocate (pes(nboxes)) + allocate (nbx(n_obstype,nboxes)) + nbx(:,:) = 1 + do j = 1, nboxes + pes(j) = modulo (j-1, nprocs) + end do + if (any(nbx /= 1)) call abort + do j = 0, nprocs-1 + if (.not. all(spread (pes==j,dim=1,ncopies=n_obstype))) call abort + ! The two following tests used to fail + if (any(shape(sum(nbx,dim=2,mask=spread (pes==j,dim=1,ncopies=n_obstype))) & + /= (/ 2 /))) call abort + if (any(sum (nbx,dim=2,mask=spread (pes==j,dim=1,ncopies=n_obstype)) & + /= (/ 1, 1 /))) call abort + end do +end program gfcbug115 -- 2.7.4