Commit 3e4d188a by Andre Vehreschild

re PR fortran/68218 (ALLOCATE with size given by a module function)

gcc/fortran/ChangeLog:

2015-11-08  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/68218
	* trans-array.c (gfc_array_init_size): Add gfc_evaluate_now() when
	array spec in allocate is a function call.

gcc/testsuite/ChangeLog:

2015-11-08  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/68218
	* gfortran.dg/allocate_with_arrayspec_1.f90: New test.

From-SVN: r229956
parent 28bc117f
2015-11-08 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/68218
* trans-array.c (gfc_array_init_size): Add gfc_evaluate_now() when
array spec in allocate is a function call.
2015-11-08 Steven G. Kargl <kargl@gc.gnu.org>
PR fortran/68224
......
......@@ -5150,6 +5150,8 @@ gfc_array_init_size (tree descriptor, int rank, int corank, tree * poffset,
gcc_assert (ubound);
gfc_conv_expr_type (&se, ubound, gfc_array_index_type);
gfc_add_block_to_block (pblock, &se.pre);
if (ubound->expr_type == EXPR_FUNCTION)
se.expr = gfc_evaluate_now (se.expr, pblock);
}
gfc_conv_descriptor_ubound_set (descriptor_block, descriptor,
gfc_rank_cst[n], se.expr);
......
2015-11-08 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/68218
* gfortran.dg/allocate_with_arrayspec_1.f90: New test.
2015-11-08 Steven G. Kargl <kargl@gc.gnu.org>
PR fortran/68224
......
! { dg-do run }
! { dg-options "-fdump-tree-original" }
MODULE mo_test
integer :: n = 0
CONTAINS
FUNCTION nquery()
INTEGER :: nquery
WRITE (0,*) "hello!"
n = n + 1
nquery = n
END FUNCTION nquery
END MODULE mo_test
! ----------------------------------------------------------------------
! MAIN PROGRAM
! ----------------------------------------------------------------------
PROGRAM example
USE mo_test
INTEGER, ALLOCATABLE :: query_buf(:)
ALLOCATE(query_buf(nquery()))
if (n /= 1 .or. size(query_buf) /= n) call abort()
END PROGRAM example
! { dg-final { scan-tree-dump-times "nquery" 5 "original" } }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment