]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/55789 (Needless realloc with array constructor.)
authorPaul Thomas <pault@gcc.gnu.org>
Wed, 6 Feb 2013 20:20:08 +0000 (20:20 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Wed, 6 Feb 2013 20:20:08 +0000 (20:20 +0000)
2013-02-06 Paul Thomas  <pault@gcc.gnu.org>

PR fortran/55789
* trans-array.c (trans_array_constructor): Remove condition
'dynamic' = true if the loop ubound is a VAR_DECL.

2013-02-06 Paul Thomas  <pault@gcc.gnu.org>

PR fortran/55789
* gfortran.dg/array_constructor_41.f90: New test.

From-SVN: r195815

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

index c22d3d9908f2b0d0f864e6444716f23172ccf439..90987da2238e660ea79b2417a77c4edb5d4418cd 100644 (file)
@@ -1,3 +1,9 @@
+2013-02-06 Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/55789
+       * trans-array.c (trans_array_constructor): Remove condition
+       'dynamic' = true if the loop ubound is a VAR_DECL.
+
 2013-02-04  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/56008
index 4553ddc5b537390874dd73c1c434fb3c08c0f8c5..ee2954e5bcab0a9dd48503d9580fa89158e1a676 100644 (file)
@@ -2307,9 +2307,6 @@ trans_array_constructor (gfc_ss * ss, locus * where)
        }
     }
 
-  if (TREE_CODE (*loop_ubound0) == VAR_DECL)
-    dynamic = true;
-
   gfc_trans_create_temp_array (&outer_loop->pre, &outer_loop->post, ss, type,
                               NULL_TREE, dynamic, true, false, where);
 
index fd5146fa7b4bf458e43266507f02d991ec2a99b3..219b12a6e7557bb11c0faeca695b6d6e6a379260 100644 (file)
@@ -1,3 +1,8 @@
+2013-02-06 Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/55789
+       * gfortran.dg/array_constructor_41.f90: New test.
+
 2013-02-06  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/55978
diff --git a/gcc/testsuite/gfortran.dg/array_constructor_41.f90 b/gcc/testsuite/gfortran.dg/array_constructor_41.f90
new file mode 100644 (file)
index 0000000..eb5fd92
--- /dev/null
@@ -0,0 +1,33 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+! Test fix for PR55789
+!
+! Contributed by Joost VandVandole  <Joost.VandeVondele@mat.ethz.ch>
+!
+MODULE M1
+CONTAINS
+  SUBROUTINE cp_1d_i4_sort(arr)
+      INTEGER(kind=4), DIMENSION(:), &
+        INTENT(inout)                          :: arr
+      arr = (/ (i, i = 1, SIZE(arr)) /)
+  END SUBROUTINE
+END MODULE M1
+
+PROGRAM TEST
+  USE M1
+  INTEGER :: arr(1)
+  INTERFACE
+    SUBROUTINE mtrace() BIND(C,name="mtrace")
+    END SUBROUTINE
+  END INTERFACE
+  INTERFACE
+    SUBROUTINE muntrace() BIND(C,name="muntrace")
+    END SUBROUTINE
+  END INTERFACE
+  CALL mtrace()
+  CALL cp_1d_i4_sort(arr)
+  CALL muntrace()
+END
+
+! { dg-final { scan-tree-dump-times "realloc" 0 "original" } }
+! { dg-final { cleanup-tree-dump "original" } }