re PR fortran/36059 (-frepack-arrays: symbols w/ TARGET should not be repacked)
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Wed, 14 May 2008 21:44:36 +0000 (21:44 +0000)
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Wed, 14 May 2008 21:44:36 +0000 (21:44 +0000)
        PR fortran/36059

        * trans-decl.c (gfc_build_dummy_array_decl): Don't repack
        arrays that have the TARGET attribute.

        * gfortran.dg/repack_arrays_1.f90: New test.

From-SVN: r135310

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

index c38717cda56cf3ebf40980af8b50cb3408d9e7e6..c39b86e25cf0661016fb18e04f87c30100be48ee 100644 (file)
@@ -1,3 +1,9 @@
+2008-05-14  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/36059
+       * trans-decl.c (gfc_build_dummy_array_decl): Don't repack
+       arrays that have the TARGET attribute.
+
 2008-05-14  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        PR fortran/36186
index 6e0b5425a913c66a34a689eac3dac235c10f49ff..aa3712ce4fddb3d1dd4d01a6fbb86e80b340f7a8 100644 (file)
@@ -733,7 +733,10 @@ gfc_build_dummy_array_decl (gfc_symbol * sym, tree dummy)
       /* Create a descriptorless array pointer.  */
       as = sym->as;
       packed = PACKED_NO;
-      if (!gfc_option.flag_repack_arrays)
+
+      /* Even when -frepack-arrays is used, symbols with TARGET attribute
+        are not repacked.  */
+      if (!gfc_option.flag_repack_arrays || sym->attr.target)
        {
          if (as->type == AS_ASSUMED_SIZE)
            packed = PACKED_FULL;
index 9abe367154db5f48706df8d75225480e41ef036d..02ef0b5f8cb43836a57572dc4d6ca745b124eb4a 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-14  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/36059
+       * gfortran.dg/repack_arrays_1.f90: New test.
+
 2008-05-14  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        PR fortran/36186
diff --git a/gcc/testsuite/gfortran.dg/repack_arrays_1.f90 b/gcc/testsuite/gfortran.dg/repack_arrays_1.f90
new file mode 100644 (file)
index 0000000..adf20aa
--- /dev/null
@@ -0,0 +1,24 @@
+! { dg-do run }
+! { dg-options "-frepack-arrays" }
+!
+! Check that arrays marked with TARGET attribute are not repacked.
+!
+program test2
+   use iso_c_binding
+   implicit none
+   real, target :: x(7)
+   type(c_ptr) cp1, cp2
+
+   x = 42
+   if (.not. c_associated(c_loc(x(3)),point(x(::2)))) call abort
+contains
+  function point(x)
+    use iso_c_binding
+    real, intent(in), target :: x(:)
+    type(c_ptr) point
+    real, pointer :: p
+
+    p => x(2)
+    point = c_loc(p)
+  end function point
+end program test2