OSDN Git Service

fortran/
authormikael <mikael@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 2 Mar 2014 18:49:18 +0000 (18:49 +0000)
committermikael <mikael@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 2 Mar 2014 18:49:18 +0000 (18:49 +0000)
        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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@208259 138bc75d-0d04-0410-961f-82ee72b054a4

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 a11df7b..2763fb2 100644 (file)
@@ -1,3 +1,9 @@
+2014-03-02  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-22  Mikael Morin  <mikael@gcc.gnu.org>
 
        PR fortran/59599
index 59e0641..acfb14d 100644 (file)
@@ -883,7 +883,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 4475c32..b2e4e61 100644 (file)
@@ -1,9 +1,14 @@
+2014-03-02  Mikael Morin  <mikael@gcc.gnu.org>
+
+       PR fortran/60341
+       * gfortran.dg/str_comp_optimize_1.f90: New test.
+
 2014-02-26  Fabien ChĂȘne  <fabien@gcc.gnu.org>
 
-        PR c++/37140
-        * g++.dg/template/using27.C: New.
-        * g++.dg/template/using28.C: New.
-        * g++.dg/template/using29.C: New.
+       PR c++/37140
+       * g++.dg/template/using27.C: New.
+       * g++.dg/template/using28.C: New.
+       * g++.dg/template/using29.C: New.
 
 2014-02-22  Mikael Morin  <mikael@gcc.gnu.org>
 
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