summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-12 16:17:09 +0000
committertkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-12 16:17:09 +0000
commitf17aef516df62ff37b49117f6bc4013fd9c8af83 (patch)
tree701f44e1967d692188338d5ad05a0d538280050d
parentd3f0af4b36e325a54e39d6940a234da257051e2b (diff)
downloadgcc-f17aef516df62ff37b49117f6bc4013fd9c8af83.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210329 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog9
-rw-r--r--gcc/fortran/frontend-passes.c23
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/associate_16.f9023
4 files changed, 58 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 3f2f787cf21..9f5ba628143 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -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,
diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c
index 8bac7bf3516..564231690c8 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -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:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 746aa415066..667ce8cfe5d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 00000000000..9129388b25b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/associate_16.f90
@@ -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