]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/40962 (Conversion problem for f-allocatable -> cptr -> fptr -> f-alloc...
authorThomas Koenig <tkoenig@gcc.gnu.org>
Thu, 20 Aug 2009 20:16:15 +0000 (20:16 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Thu, 20 Aug 2009 20:16:15 +0000 (20:16 +0000)
2009-08-20  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR libfortran/40962
* iso_c_binding.c (c_f_pointer_u0):  Multiply stride by
previous stride.

2009-08-20  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR libfortran/40962
* c_f_pointer_tests_4.f90:  New test.

From-SVN: r150974

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/c_f_pointer_tests_4.f90 [new file with mode: 0644]
libgfortran/ChangeLog
libgfortran/intrinsics/iso_c_binding.c

index c341ae8903c4edc814ebc333021f42b792f0d78f..b3d135744cd96037d7d6d8f5c8cd84a4f8e04cc6 100644 (file)
@@ -1,3 +1,8 @@
+2009-08-20  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR libfortran/40962
+       * c_f_pointer_tests_4.f90:  New test.
+
 2009-08-20  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/slice6.adb: New test.
diff --git a/gcc/testsuite/gfortran.dg/c_f_pointer_tests_4.f90 b/gcc/testsuite/gfortran.dg/c_f_pointer_tests_4.f90
new file mode 100644 (file)
index 0000000..4f5338d
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do run }
+program main
+   use iso_c_binding, only: c_ptr, c_loc, c_f_pointer
+   implicit none
+   integer, dimension(2,1,2), target :: table
+   table = reshape ( (/ 1,2,-1,-2/), (/2,1,2/))
+   call set_table (c_loc (table))
+contains
+   subroutine set_table (cptr)
+     type(c_ptr), intent(in) :: cptr
+     integer, dimension(:,:,:), pointer :: table_tmp
+     call c_f_pointer (cptr, table_tmp, (/2,1,2/))
+     if (any(table_tmp /= table)) call abort
+   end subroutine set_table
+end program main
index 7a0f056c9c987bb3cbb5d95462675b30c7769eff..b22306f8f47536fe7eff69e643edac7599235add 100644 (file)
@@ -1,3 +1,9 @@
+2009-08-20  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR libfortran/40962
+       * iso_c_binding.c (c_f_pointer_u0):  Multiply stride by
+       previous stride.
+
 2009-08-20  Dave Korn  <dave.korn.cygwin@gmail.com>
 
        * Makefile.am (LTLDFLAGS): Add -bindir flag.
index 0dd7449df6d5ec14427c96a330968f216110db81..569b122f2360b297ac1736d3086e315595120d5d 100644 (file)
@@ -152,7 +152,7 @@ ISO_C_BINDING_PREFIX (c_f_pointer_u0) (void *c_ptr_in,
            }
          else
            {
-             str = GFC_DESCRIPTOR_EXTENT(f_ptr_out,i-1);
+             str = str * GFC_DESCRIPTOR_EXTENT(f_ptr_out,i-1);
              f_ptr_out->offset += str;
            }