]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/60341 (ICE compiling Nonmem 6.2.0)
authorMikael Morin <mikael@gcc.gnu.org>
Sat, 1 Mar 2014 21:14:54 +0000 (21:14 +0000)
committerMikael Morin <mikael@gcc.gnu.org>
Sat, 1 Mar 2014 21:14:54 +0000 (21:14 +0000)
fortran/
        PR fortran/60341
        * frontend-passes.c (optimize_comparison): Guard two union
        accesses with the corresponding tag checks.

testsuite/
        PR fortran/60341
        * gfortran.dg/str_comp_optimize_1.f90: New test.

From-SVN: r208249

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

index 415a4cbaedf5d25b454c45a5b29c2fa322dccb3d..549421fbafcfdc532a4a3e6230b09abbcf6dca09 100644 (file)
@@ -1,3 +1,9 @@
+2014-03-01  Mikael Morin  <mikael@gcc.gnu.org>
+
+       PR fortran/60341
+       * frontend-passes.c (optimize_comparison): Guard two union accesses
+       with the corresponding tag checks.
+
 2014-02-28  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/60359
index 52bd7005e1757fb0b2345aeebb40bdd07ad8a95e..e663868d3ce00906f8f95e848721d9c04061d3f1 100644 (file)
@@ -1391,7 +1391,9 @@ optimize_comparison (gfc_expr *e, gfc_intrinsic_op op)
          /* Replace A // B < A // C with B < C, and A // B < C // B
             with A < C.  */
          if (op1->ts.type == BT_CHARACTER && op2->ts.type == BT_CHARACTER
+             && op1->expr_type == EXPR_OP
              && op1->value.op.op == INTRINSIC_CONCAT
+             && op2->expr_type == EXPR_OP
              && op2->value.op.op == INTRINSIC_CONCAT)
            {
              gfc_expr *op1_left = op1->value.op.op1;
index d7ef999776da59dd1c18f9a6eac1652b27f54645..dd9dcbae1d1bc796eb6d336a7716124c2bcbadd3 100644 (file)
@@ -1,3 +1,8 @@
+2014-03-01  Mikael Morin  <mikael@gcc.gnu.org>
+
+       PR fortran/60341
+       * gfortran.dg/str_comp_optimize_1.f90: New test.
+
 2014-03-01  Oleg Endo  <olegendo@gcc.gnu.org>
 
        PR target/60071
diff --git a/gcc/testsuite/gfortran.dg/str_comp_optimize_1.f90 b/gcc/testsuite/gfortran.dg/str_comp_optimize_1.f90
new file mode 100644 (file)
index 0000000..84287b4
--- /dev/null
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! { dg-options "-ffrontend-optimize" }
+!
+! PR fortran/60341
+! An unguarded union access was wrongly enabling a frontend optimization on a
+! string comparison, leading to an ICE.
+!
+! Original testcase from Steve Chapel  <steve.chapel@a2pg.com>.
+! Reduced by Steven G. Kargl  <kargl@gcc.gnu.org>.
+!
+
+      subroutine modelg(ncm)
+      implicit none
+      integer, parameter :: pc = 30, pm = pc - 1
+      integer i
+      character*4 catt(pm,2)
+      integer ncm,iatt(pm,pc)
+      do i=1,ncm
+         if (catt(i,1)//catt(i,2).eq.'central') exit
+      end do
+      iatt(i,4)=1
+      end