[fortran,patch] Fix PR36059: don't repack arrays that have the TARGET attribute.

FX fxcoudert@gmail.com
Mon May 12 17:55:00 GMT 2008


Subject says it all... bootstrapped and regtested on x86_64-linux, OK
to commit? (I'm not committing as obvious because I fear I might be
missing something fundamental abound these repacked arrays, it seems
to simple to be true!)

FX




2008-05-12  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-12  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

        PR fortran/36059
        * gfortran.dg/repack_arrays_1.f90: New test.




Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c    (revision 135088)
+++ gcc/fortran/trans-decl.c    (working copy)
@@ -733,7 +733,10 @@ gfc_build_dummy_array_decl (gfc_symbol *
       /* 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: gcc/testsuite/gfortran.dg/repack_arrays_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/repack_arrays_1.f90       (revision 0)
+++ gcc/testsuite/gfortran.dg/repack_arrays_1.f90       (revision 0)
@@ -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


-- 
FX Coudert
http://www.homepages.ucl.ac.uk/~uccafco/



More information about the Fortran mailing list