]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/61406 (ICE on ASSOCIATE construct to literal array expression)
authorPaul Thomas <pault@gcc.gnu.org>
Mon, 9 Jun 2014 11:55:55 +0000 (11:55 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Mon, 9 Jun 2014 11:55:55 +0000 (11:55 +0000)
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

gcc/fortran/ChangeLog
gcc/fortran/trans-stmt.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/associate_17.f90 [new file with mode: 0644]

index f84cd8e2f8a8d67dd0141f8b300db5c04597227c..c0443337c536e9f9ad15354502fb2598128aa546 100644 (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
        * 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,
index 212a2586d2acae0e0f1fd98b2ae67a5f861750ed..547e9c1bb91b38cfc0c054d5babc325a85aa2344 100644 (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;
 
index 544b80be58473a5892dde8f8ae6917c3a70c9769..f3b2c6ab4279ba534944e31055be3e19b1bc2ba7 100644 (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,
diff --git a/gcc/testsuite/gfortran.dg/associate_17.f90 b/gcc/testsuite/gfortran.dg/associate_17.f90
new file mode 100644 (file)
index 0000000..5c39cf0
--- /dev/null
@@ -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