re PR fortran/56867 (Missing temporary with string array assignment)
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 28 Dec 2014 12:03:02 +0000 (12:03 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 28 Dec 2014 12:03:02 +0000 (12:03 +0000)
2014-12-28  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/56867
* trans-array.c (gfc_conv_resolve_dependencies):  Also check
dependencies when there may be substrings of character arrays.

2014-12-28  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/56867
* gfortran.dg/dependency_45.f90:  New test.

From-SVN: r219089

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/dependency_45.f90 [new file with mode: 0644]

index 6912797a456274231dfa3a5866dfa040ffe5eab1..d7a76a3c9f9128fc5c5249299f1d3046fa28141e 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-28  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/56867
+       * trans-array.c (gfc_conv_resolve_dependencies):  Also check
+       dependencies when there may be substrings of character arrays.
+
 2014-12-27  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/54756
index 67beab291a11216d0f8a2fc9e45a84de8d336f4f..ebd7f11a53bb9301cf238b26c34c3a4308a370d3 100644 (file)
@@ -4355,6 +4355,13 @@ gfc_conv_resolve_dependencies (gfc_loopinfo * loop, gfc_ss * dest,
              && ss_expr->rank)
            nDepend = gfc_check_dependency (dest_expr, ss_expr, true);
 
+         /* Check for cases like   c(:)(1:2) = c(2)(2:3)  */
+         if (!nDepend && dest_expr->rank > 0
+             && dest_expr->ts.type == BT_CHARACTER
+             && ss_expr->expr_type == EXPR_VARIABLE)
+           
+           nDepend = gfc_check_dependency (dest_expr, ss_expr, false);
+
          continue;
        }
 
index 4422c960deb56fbf1018f133a9cb74ec88209d30..ebcfdc4c769cee064fdbaefb2e207aee41c5c4d4 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-28  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/56867
+       * gfortran.dg/dependency_45.f90:  New test.
+
 2014-12-27  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/54756
diff --git a/gcc/testsuite/gfortran.dg/dependency_45.f90 b/gcc/testsuite/gfortran.dg/dependency_45.f90
new file mode 100644 (file)
index 0000000..8b43f75
--- /dev/null
@@ -0,0 +1,12 @@
+! { dg-do run }
+! { dg-options "-Warray-temporaries" }
+! PR 56867 - substrings were not checked for dependency.
+program main
+  character(len=4) :: a
+  character(len=4) :: c(3)
+  c(1) = 'abcd'
+  c(2) = '1234'
+  c(3) = 'wxyz'
+  c(:)(1:2) = c(2)(2:3)   ! { dg-warning "array temporary" }
+  if (c(3) .ne. '23yz') call abort
+end program main