From 007dd57def1952b038d5a517dff77a421f3b4073 Mon Sep 17 00:00:00 2001 From: pault Date: Mon, 9 Jun 2014 11:55:55 +0000 Subject: [PATCH] 2014-06-09 Paul Thomas PR fortran/61406 * trans-stmt.c (trans_associate_var): Check that array constructors are constant for direct reference. 2014-06-09 Paul Thomas PR fortran/61406 * gfortran.dg/associate_17.f90 : New test git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211374 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 8 +++++++- gcc/fortran/trans-stmt.c | 7 +++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/associate_17.f90 | 12 ++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/associate_17.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f84cd8e2f8a..c0443337c53 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2014-06-09 Paul Thomas + + PR fortran/61406 + * trans-stmt.c (trans_associate_var): Check that array + constructors are constant for direct reference. + 2014-06-09 Francois-Xavier Coudert 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, diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 212a2586d2a..547e9c1bb91 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 544b80be584..f3b2c6ab427 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-06-09 Paul Thomas + + PR fortran/61406 + * gfortran.dg/associate_17.f90 : New test + 2014-06-09 Petr Murzin * gcc.target/i386/avx512f-vaddpd-2.c: Add static void for CALC, diff --git a/gcc/testsuite/gfortran.dg/associate_17.f90 b/gcc/testsuite/gfortran.dg/associate_17.f90 new file mode 100644 index 00000000000..5c39cf06247 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_17.f90 @@ -0,0 +1,12 @@ +! { dg-do run } +! Test the fix for PR61406 +! Contributed by Adam Hirst +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 -- 2.11.4.GIT