]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/69742 (ICE with -O3 and ASSOCIATE containing repeated expression)
authorThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 16 Feb 2016 21:10:00 +0000 (21:10 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 16 Feb 2016 21:10:00 +0000 (21:10 +0000)
2015-02-16  Thomas Koenig  <tkoenig@gcc.gnu.org>

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

2015-02-16  Thomas Koenig  <tkoenig@gcc.gnu.org>

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

From-SVN: r233474

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

index 453e72a33a1958d4a259b66a3ee12a921d4c45ac..5cf25a476938eb95eef4ad1ef20a219dbc72db90 100644 (file)
@@ -1,3 +1,9 @@
+2015-02-16  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/69742
+       * frontend-passes.c (cfe-expr_0):  Don't register functions
+       from within an ASSOCIATE statement.
+
 2016-02-14  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/60526
index 76edbae131cd1807cf3e2e3f571e05daef9bfba8..156ea2b764020c79f7b526987267a6e2b953a370 100644 (file)
@@ -734,9 +734,9 @@ cfe_expr_0 (gfc_expr **e, int *walk_subtrees,
   gfc_expr *newvar;
   gfc_expr **ei, **ej;
 
-  /* Don't do this optimization within OMP workshare.  */
+  /* Don't do this optimization within OMP workshare or ASSOC lists.  */
 
-  if (in_omp_workshare)
+  if (in_omp_workshare || in_assoc_list)
     {
       *walk_subtrees = 0;
       return 0;
index df0b67cd447b15c051219b220044085e2d19563d..a07182385faf9a11a61154e0665f5231be0a99b4 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-16  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/69742
+       * gfortran.dg/associate_21.f90:  New test.
+
 2016-02-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/69835
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