]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/69742 (ICE with -O3 and ASSOCIATE containing repeated expression)
authorThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 9 Aug 2016 06:28:57 +0000 (06:28 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 9 Aug 2016 06:28:57 +0000 (06:28 +0000)
2016-08-09  Thomas Koenig  <tkoenig@gcc.gnu.org>

Backport from trunk
PR fortran/69742
* frontend-passes.c (cfe-expr_0):  Don't register functions
from within an ASSOCIATE statement.

2016-08-09  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/69742
* gfortran.dg/associate_21.f90:  New test.

From-SVN: r239271

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

index 67ec56c5a0091da2fd9690e5477802ccfb283ee5..6881684d12689b45b0896a305048714f6d46f511 100644 (file)
@@ -1,3 +1,10 @@
+2016-08-09  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       Backport from trunk
+       PR fortran/69742
+       * frontend-passes.c (cfe-expr_0):  Don't register functions
+       from within an ASSOCIATE statement.
+
 2016-08-08  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        Backport from trunk
index 92a1f9b75eb258c2fa2301e44329cace588472a6..31d7caf66893926496027a9b3e2fcc7afd089a24 100644 (file)
@@ -711,7 +711,7 @@ cfe_expr_0 (gfc_expr **e, int *walk_subtrees,
 
   /* Don't do this optimization within OMP workshare.  */
 
-  if (in_omp_workshare)
+  if (in_omp_workshare || in_assoc_list)
     {
       *walk_subtrees = 0;
       return 0;
index 4765fce5e33996e4b369246c2df5b045fdf9d795..a7ee12126ac2b4d8de336d42af8f7d5e8d6c6850 100644 (file)
@@ -1,3 +1,8 @@
+2016-08-09  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/69742
+       * gfortran.dg/associate_21.f90:  New test.
+
 2016-08-08  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/60526
diff --git a/gcc/testsuite/gfortran.dg/associate_21.f90 b/gcc/testsuite/gfortran.dg/associate_21.f90
new file mode 100644 (file)
index 0000000..a7bbaba
--- /dev/null
@@ -0,0 +1,19 @@
+! { dg-do compile }
+! { dg-options "-ffrontend-optimize" }
+! PR 69742 - this used to ICE with front-end optimizatoin
+! Original test case by Marco Restelli.
+program p
+ implicit none
+ integer, allocatable :: i(:), j
+
+  allocate( i(5) )
+  i = (/( j , j=1,5 )/)
+
+  ! The ICE appears when "size(i)" is used twice in associate
+  associate( i5 => i(size(i):size(i)) ) ! this gives ICE
+  !associate( i5 => i(size(2*i):size(i)) ) ! this works
+  i5 = 2
+  end associate
+
+  write(*,*) i
+end program p