re PR fortran/38033 (Bounds of a pointer/allocatable array not stabilized)
2008-10-14 Paul Thomas <pault@gcc.gnu.org> PR fortran/38033 * trans-array.c (gfc_trans_create_temp_array): Stabilize the 'to' expression. (gfc_conv_loop_setup): Use the end expression for the loop 'to' if it is available. 2008-10-14 Paul Thomas <pault@gcc.gnu.org> PR fortran/38033 * gfortran.dg/array_section_2.f90: New test. From-SVN: r141861
This commit is contained in:
parent
927425dffe
commit
993ac38b0f
@ -1,3 +1,11 @@
|
|||||||
|
2008-10-14 Paul Thomas <pault@gcc.gnu.org>
|
||||||
|
|
||||||
|
PR fortran/38033
|
||||||
|
* trans-array.c (gfc_trans_create_temp_array): Stabilize the
|
||||||
|
'to' expression.
|
||||||
|
(gfc_conv_loop_setup): Use the end expression for the loop 'to'
|
||||||
|
if it is available.
|
||||||
|
|
||||||
2008-11-12 Jakub Jelinek <jakub@redhat.com>
|
2008-11-12 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
PR target/35366
|
PR target/35366
|
||||||
|
@ -650,8 +650,10 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post,
|
|||||||
{
|
{
|
||||||
/* Callee allocated arrays may not have a known bound yet. */
|
/* Callee allocated arrays may not have a known bound yet. */
|
||||||
if (loop->to[n])
|
if (loop->to[n])
|
||||||
loop->to[n] = fold_build2 (MINUS_EXPR, gfc_array_index_type,
|
loop->to[n] =
|
||||||
loop->to[n], loop->from[n]);
|
gfc_evaluate_now (fold_build2 (MINUS_EXPR,
|
||||||
|
gfc_array_index_type, loop->to[n],
|
||||||
|
loop->from[n]), pre);
|
||||||
loop->from[n] = gfc_index_zero_node;
|
loop->from[n] = gfc_index_zero_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3511,8 +3513,13 @@ gfc_conv_loop_setup (gfc_loopinfo * loop, locus * where)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case GFC_SS_SECTION:
|
case GFC_SS_SECTION:
|
||||||
loop->to[n] = gfc_conv_section_upper_bound (loopspec[n], n,
|
/* Use the end expression if it exists and is not constant,
|
||||||
&loop->pre);
|
so that it is only evaluated once. */
|
||||||
|
if (info->end[n] && !INTEGER_CST_P (info->end[n]))
|
||||||
|
loop->to[n] = info->end[n];
|
||||||
|
else
|
||||||
|
loop->to[n] = gfc_conv_section_upper_bound (loopspec[n], n,
|
||||||
|
&loop->pre);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GFC_SS_FUNCTION:
|
case GFC_SS_FUNCTION:
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2008-10-14 Paul Thomas <pault@gcc.gnu.org>
|
||||||
|
|
||||||
|
PR fortran/38033
|
||||||
|
* gfortran.dg/array_section_2.f90: New test.
|
||||||
|
|
||||||
2008-11-14 Jakub Jelinek <jakub@redhat.com>
|
2008-11-14 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
PR tree-optimization/38104
|
PR tree-optimization/38104
|
||||||
|
16
gcc/testsuite/gfortran.dg/array_section_2.f90
Normal file
16
gcc/testsuite/gfortran.dg/array_section_2.f90
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
! { dg-do compile }
|
||||||
|
! { dg-options "-fdump-tree-original" }
|
||||||
|
!
|
||||||
|
! PR38033 - size(a) was not stabilized correctly and so the expression was
|
||||||
|
! evaluated twice outside the loop and then within the scalarization loops.
|
||||||
|
!
|
||||||
|
! Contributed by Thomas Bruel <tmbdev@gmail.com>
|
||||||
|
!
|
||||||
|
program test
|
||||||
|
integer, parameter :: n = 100
|
||||||
|
real, pointer :: a(:),temp(:) ! pointer or allocatable have the same effect
|
||||||
|
allocate(a(n), temp(n))
|
||||||
|
temp(1:size(a)) = a
|
||||||
|
end program
|
||||||
|
! { dg-final { scan-tree-dump-times "size0" 1 "original" } }
|
||||||
|
! { dg-final { cleanup-tree-dump "original" } }
|
Loading…
Reference in New Issue
Block a user