OSDN Git Service

2010-09-23 Thomas Koenig <tkoenig@gcc.gnu.org>
authortkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Sep 2010 19:37:48 +0000 (19:37 +0000)
committertkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Sep 2010 19:37:48 +0000 (19:37 +0000)
PR fortran/45744
* frontend-passes.c (optimize_binop_array_assignment):
Only re-use lhs as intermediate storage if kind and type
parameters match.

2010-09-23  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/45744
* gfortran.dg/dependency_36.f90:  New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164570 138bc75d-0d04-0410-961f-82ee72b054a4

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

index d57a449..02ab36d 100644 (file)
@@ -1,9 +1,16 @@
+2010-09-23  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/45744
+       * frontend-passes.c (optimize_binop_array_assignment):
+       Only re-use lhs as intermediate storage if kind and type
+       parameters match.
+
 2010-09-23  Mikael Morin  <mikael@gcc.gnu.org>
 
        PR fortran/45745
        PR fortran/45648
-       * trans-array.c (gfc_conv_expr_descriptor): Handle 
-       ss->type == GFC_SS_INTRINSIC (for {l,u}bound intrinsics) case. 
+       * trans-array.c (gfc_conv_expr_descriptor): Handle
+       ss->type == GFC_SS_INTRINSIC (for {l,u}bound intrinsics) case.
 
 2010-09-23  Tobias Burnus  <burnus@net-b.de>
 
index b456f47..aefee62 100644 (file)
@@ -122,8 +122,13 @@ optimize_binop_array_assignment (gfc_code *c, gfc_expr **rhs, bool seen_op)
   else if (seen_op && e->expr_type == EXPR_FUNCTION && e->rank > 0
           && ! (e->value.function.esym 
                 && (e->value.function.esym->attr.elemental 
-                    || e->value.function.esym->attr.allocatable))
-          && ! (e->value.function.isym && e->value.function.isym->elemental))
+                    || e->value.function.esym->attr.allocatable
+                    || e->value.function.esym->ts.type != c->expr1->ts.type
+                    || e->value.function.esym->ts.kind != c->expr1->ts.kind))
+          && ! (e->value.function.isym
+                && (e->value.function.isym->elemental
+                    || e->ts.type != c->expr1->ts.type
+                    || e->ts.kind != c->expr1->ts.kind)))
     {
 
       gfc_code *n;
index 65fca96..3773f07 100644 (file)
@@ -1,3 +1,8 @@
+2010-09-23  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/45744
+       * gfortran.dg/dependency_36.f90:  New test.
+
 2010-09-23  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.target/i386/pad-1.c: Remove -S from dg-options.
diff --git a/gcc/testsuite/gfortran.dg/dependency_36.f90 b/gcc/testsuite/gfortran.dg/dependency_36.f90
new file mode 100644 (file)
index 0000000..f3c0ef7
--- /dev/null
@@ -0,0 +1,28 @@
+! { dg-do compile }
+! { dg-options "-O -Warray-temporaries" }
+! PR 45744 - this used to ICE because of type mismatch
+!            in the generated temporary.
+MODULE m
+CONTAINS
+  FUNCTION rnd(n)
+    INTEGER, INTENT(in) :: n
+    REAL(8), DIMENSION(n) :: rnd
+    CALL RANDOM_NUMBER(rnd)
+  END FUNCTION rnd
+
+  SUBROUTINE GeneticOptimize(n)
+    INTEGER :: n
+    LOGICAL :: mask(n)
+    REAL(8) :: popcross=0
+    REAL(4) :: foo(n)
+    real(4) :: a(n,n), b(n,n)
+    real(8) :: c(n,n)
+    integer(4) :: x(n,n)
+    integer(8) :: bar(n)
+    mask = (rnd(n) < popcross)  ! { dg-warning "Creating array temporary" }
+    foo = rnd(n)                ! { dg-warning "Creating array temporary" }
+    bar = rnd(n)                ! { dg-warning "Creating array temporary" }
+    c = matmul(a,b)             ! { dg-warning "Creating array temporary" }
+    x = matmul(a,b)             ! { dg-warning "Creating array temporary" }
+  END SUBROUTINE GeneticOptimize
+END MODULE m