+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
* 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,
{
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;
/* 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;
+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,
--- /dev/null
+! { 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