re PR fortran/61406 (ICE on ASSOCIATE construct to literal array expression)

2014-06-09  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/61406
	* trans-stmt.c (trans_associate_var): Check that array
	constructors are constant for direct reference.

2014-06-09  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/61406
	* gfortran.dg/associate_17.f90 : New test

From-SVN: r211374
This commit is contained in:
Paul Thomas 2014-06-09 11:55:55 +00:00
parent 45b4a79657
commit bcac046f5f
4 changed files with 29 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2014-06-09 Paul Thomas <pault@gcc.gnu.org>
PR fortran/61406
* trans-stmt.c (trans_associate_var): Check that array
constructors are constant for direct reference.
2014-06-09 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/36096
@ -333,7 +339,7 @@
* trans.c (trans_code): Handle EXEC_OMP_CANCEL,
EXEC_OMP_CANCELLATION_POINT, EXEC_OMP_DO_SIMD,
EXEC_OMP_PARALLEL_DO_SIMD, EXEC_OMP_SIMD and EXEC_OMP_TASKGROUP.
* resolve.c (gfc_resolve_blocks): Handle EXEC_OMP_DO_SIMD,
* resolve.c (gfc_resolve_blocks): Handle EXEC_OMP_DO_SIMD,
EXEC_OMP_PARALLEL_DO_SIMD, EXEC_OMP_SIMD and EXEC_OMP_TASKGROUP.
(resolve_code): Handle EXEC_OMP_CANCEL,
EXEC_OMP_CANCELLATION_POINT, EXEC_OMP_DO_SIMD,

View File

@ -1167,13 +1167,16 @@ trans_associate_var (gfc_symbol *sym, gfc_wrapped_block *block)
{
gfc_se se;
tree desc;
bool cst_array_ctor;
desc = sym->backend_decl;
cst_array_ctor = e->expr_type == EXPR_ARRAY
&& gfc_constant_array_constructor_p (e->value.constructor);
/* If association is to an expression, evaluate it and create temporary.
Otherwise, get descriptor of target for pointer assignment. */
gfc_init_se (&se, NULL);
if (sym->assoc->variable || e->expr_type == EXPR_ARRAY)
if (sym->assoc->variable || cst_array_ctor)
{
se.direct_byref = 1;
se.use_offset = 1;
@ -1184,7 +1187,7 @@ trans_associate_var (gfc_symbol *sym, gfc_wrapped_block *block)
/* If we didn't already do the pointer assignment, set associate-name
descriptor to the one generated for the temporary. */
if (!sym->assoc->variable && e->expr_type != EXPR_ARRAY)
if (!sym->assoc->variable && !cst_array_ctor)
{
int dim;

View File

@ -1,3 +1,8 @@
2014-06-09 Paul Thomas <pault@gcc.gnu.org>
PR fortran/61406
* gfortran.dg/associate_17.f90 : New test
2014-06-09 Petr Murzin <petr.murzin@intel.com>
* gcc.target/i386/avx512f-vaddpd-2.c: Add static void for CALC,

View File

@ -0,0 +1,12 @@
! { dg-do run }
! Test the fix for PR61406
! Contributed by Adam Hirst <adam@aphirst.karoo.co.uk>
program test
implicit none
real :: theta = 1.0
associate (n => [cos(theta), sin(theta)])
if (abs (norm2(n) - 1.0) .gt. 1.0e-4) call abort
end associate
end program test