From: Janus Weil Date: Fri, 21 Feb 2014 22:54:50 +0000 (+0100) Subject: re PR fortran/60302 (ICE with c_f_pointer and android cross compiler) X-Git-Tag: releases/gcc-4.9.0~756 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1ed9e151e1263e32142fa3fe3909d48964c72c2;p=thirdparty%2Fgcc.git re PR fortran/60302 (ICE with c_f_pointer and android cross compiler) 2014-02-21 Janus Weil PR fortran/60302 * check.c (gfc_check_c_f_pointer): Only clear 'size' if 'gfc_array_size' is successful. 2014-02-21 Janus Weil PR fortran/60302 * gfortran.dg/c_f_pointer_shape_tests_6.f90: New. From-SVN: r208033 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c27a1d0d0d42..995ede78f833 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2014-02-21 Janus Weil + + PR fortran/60302 + * check.c (gfc_check_c_f_pointer): Only clear 'size' if 'gfc_array_size' + is successful. + 2014-02-21 Janus Weil PR fortran/60234 diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 42820306e1ce..119750aab8f2 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8f8f35b9184b..030107932f13 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-02-21 Janus Weil + + PR fortran/60302 + * gfortran.dg/c_f_pointer_shape_tests_6.f90: New. + 2014-02-21 Bill Schmidt * 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 index 000000000000..dd9b16366422 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_6.f90 @@ -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 + +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