re PR fortran/60302 (ICE with c_f_pointer and android cross compiler)
authorJanus Weil <janus@gcc.gnu.org>
Fri, 21 Feb 2014 22:54:50 +0000 (23:54 +0100)
committerJanus Weil <janus@gcc.gnu.org>
Fri, 21 Feb 2014 22:54:50 +0000 (23:54 +0100)
2014-02-21  Janus Weil  <janus@gcc.gnu.org>

PR fortran/60302
* check.c (gfc_check_c_f_pointer): Only clear 'size' if 'gfc_array_size'
is successful.

2014-02-21  Janus Weil  <janus@gcc.gnu.org>

PR fortran/60302
* gfortran.dg/c_f_pointer_shape_tests_6.f90: New.

From-SVN: r208033

gcc/fortran/ChangeLog
gcc/fortran/check.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_6.f90 [new file with mode: 0644]

index c27a1d0..995ede7 100644 (file)
@@ -1,5 +1,11 @@
 2014-02-21  Janus Weil  <janus@gcc.gnu.org>
 
+       PR fortran/60302
+       * check.c (gfc_check_c_f_pointer): Only clear 'size' if 'gfc_array_size'
+       is successful.
+
+2014-02-21  Janus Weil  <janus@gcc.gnu.org>
+
        PR fortran/60234
        * gfortran.h (gfc_build_class_symbol): Removed argument.
        * class.c (gfc_add_component_ref): Fix up missing vtype if necessary.
index 4282030..119750a 100644 (file)
@@ -3944,16 +3944,17 @@ gfc_check_c_f_pointer (gfc_expr *cptr, gfc_expr *fptr, gfc_expr *shape)
   if (shape)
     {
       mpz_t size;
-
-      if (gfc_array_size (shape, &size)
-         && mpz_cmp_ui (size, fptr->rank) != 0)
+      if (gfc_array_size (shape, &size))
        {
+         if (mpz_cmp_ui (size, fptr->rank) != 0)
+           {
+             mpz_clear (size);
+             gfc_error ("SHAPE argument at %L to C_F_POINTER must have the same "
+                       "size as the RANK of FPTR", &shape->where);
+             return false;
+           }
          mpz_clear (size);
-         gfc_error ("SHAPE argument at %L to C_F_POINTER must have the same "
-                    "size as the RANK of FPTR", &shape->where);
-         return false;
        }
-      mpz_clear (size);
     }
 
   if (fptr->ts.type == BT_CLASS)
index 8f8f35b..0301079 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-21  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/60302
+       * gfortran.dg/c_f_pointer_shape_tests_6.f90: New.
+
 2014-02-21  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        * gcc.dg/vmx/vsums.c: Check entire result vector.
diff --git a/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_6.f90 b/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_6.f90
new file mode 100644 (file)
index 0000000..dd9b163
--- /dev/null
@@ -0,0 +1,14 @@
+! { dg-do compile }
+!
+! PR 60302: [4.9 Regression] ICE with c_f_pointer and android cross compiler
+!
+! Contributed by Valery Weber <valeryweber@hotmail.com>
+
+subroutine reshape_inplace_c2_c2 (new_shape)
+  use, intrinsic :: iso_c_binding
+  implicit none
+  integer :: new_shape(:)
+  complex, pointer :: ptr_x(:)
+  type(c_ptr) :: loc_x
+  call c_f_pointer (loc_x, ptr_x, new_shape)
+end subroutine