re PR fortran/60834 ([OOP] ICE with ASSOCIATE construct (gimplify_var_or_parm_decl...
authorThomas Koenig <tkoenig@gcc.gnu.org>
Mon, 12 May 2014 16:17:09 +0000 (16:17 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Mon, 12 May 2014 16:17:09 +0000 (16:17 +0000)
2014-05-12  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/60834
* frontend-passes.c (in_assoc_list):  New variable.
(optimize_namespace):  Initialize in_assoc_list
(combine_array_constructor): Don't try to combine
assoc lists.
(gfc_code_walker):  Keep track of in_assoc_list.

2014-05-12  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/60834
* gfortran.dg/associate_16.f90:  New test.

From-SVN: r210329

gcc/fortran/ChangeLog
gcc/fortran/frontend-passes.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/associate_16.f90 [new file with mode: 0644]

index 3f2f787..9f5ba62 100644 (file)
@@ -1,3 +1,12 @@
+2014-05-12  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/60834
+       * frontend-passes.c (in_assoc_list):  New variable.
+       (optimize_namespace):  Initialize in_assoc_list
+       (combine_array_constructor): Don't try to combine
+       assoc lists.
+       (gfc_code_walker):  Keep track of in_assoc_list.
+
 2014-05-11  Jakub Jelinek  <jakub@redhat.com>
 
        * gfortran.h (gfc_statement): Add ST_OMP_CANCEL,
index 8bac7bf..5642316 100644 (file)
@@ -88,6 +88,10 @@ static int doloop_size, doloop_level;
 
 struct my_struct *evec;
 
+/* Keep track of association lists.  */
+
+static bool in_assoc_list;
+
 /* Entry point - run all passes for a namespace. */
 
 void
@@ -820,6 +824,7 @@ optimize_namespace (gfc_namespace *ns)
   current_ns = ns;
   forall_level = 0;
   iterator_level = 0;
+  in_assoc_list = false;
   in_omp_workshare = false;
 
   gfc_code_walker (&ns->code, convert_do_while, dummy_expr_callback, NULL);
@@ -1054,6 +1059,11 @@ combine_array_constructor (gfc_expr *e)
   if (e->rank != 1)
     return false;
 
+  /* Don't try to combine association lists, this makes no sense
+     and leads to an ICE.  */
+  if (in_assoc_list)
+    return false;
+
   op1 = e->value.op.op1;
   op2 = e->value.op.op2;
 
@@ -1940,8 +1950,17 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t codefn, walk_expr_fn_t exprfn,
 
            case EXEC_BLOCK:
              WALK_SUBCODE (co->ext.block.ns->code);
-             for (alist = co->ext.block.assoc; alist; alist = alist->next)
-               WALK_SUBEXPR (alist->target);
+             if (co->ext.block.assoc)
+               {
+                 bool saved_in_assoc_list = in_assoc_list;
+
+                 in_assoc_list = true;
+                 for (alist = co->ext.block.assoc; alist; alist = alist->next)
+                   WALK_SUBEXPR (alist->target);
+
+                 in_assoc_list = saved_in_assoc_list;
+               }
+
              break;
 
            case EXEC_DO:
index 746aa41..667ce8c 100644 (file)
@@ -1,3 +1,8 @@
+2014-05-12  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/60834
+       * gfortran.dg/associate_16.f90:  New test.
+
 2014-05-12  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
 
        PR target/60991
diff --git a/gcc/testsuite/gfortran.dg/associate_16.f90 b/gcc/testsuite/gfortran.dg/associate_16.f90
new file mode 100644 (file)
index 0000000..9129388
--- /dev/null
@@ -0,0 +1,23 @@
+! { dg-do compile }
+! PR 60834 - this used to ICE.
+
+module m
+  implicit none
+  type :: t
+    real :: diffusion=1.
+  end type
+contains
+  subroutine solve(this, x)
+    class(t), intent(in) :: this
+    real, intent(in) :: x(:)
+    integer :: i
+    integer, parameter :: n(1:5)=[(i,i=1, 5)]
+
+    associate( nu=>this%diffusion)
+      associate( exponential=>exp(-(x(i)-n) ))
+        do i = 1, size(x)
+        end do
+      end associate
+    end associate
+  end subroutine solve
+end module m