This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch, fortran] Error for non-contiguous pointers
- From: Thomas Koenig <tkoenig at netcologne dot de>
- To: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 3 Oct 2017 20:35:34 +0200
- Subject: [patch, fortran] Error for non-contiguous pointers
- Authentication-results: sourceware.org; auth=none
Hello world,
I have re-thought and simplified the patch for PR49232.
This now uses gfc_is_simply_contiguous, in the
non-strict version. I have also opted for an error
because, well, the use cases rejected by this are really
errors, and will very likely lead to wrong code in
user applications.
Regression-tested. OK for trunk?
Thomas
2017-10-03 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/49232
* expr.c (gfc_check_pointer_assign): Error
for non-contiguous rhs.
2017-10-03 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/49232
* gfortran.dg/contiguous_4.f90: New test.
Index: expr.c
===================================================================
--- expr.c (Revision 253377)
+++ expr.c (Arbeitskopie)
@@ -3851,6 +3851,14 @@
}
}
+ /* Error for assignments of contiguous pointers to targets which is not
+ contiguous. Be lenient in the definition of what counts as
+ congiguous. */
+
+ if (lhs_attr.contiguous && !gfc_is_simply_contiguous (rvalue, false, true))
+ gfc_error ("Assignment to contiguous pointer from non-contiguous "
+ "target at %L", &rvalue->where);
+
/* Warn if it is the LHS pointer may lives longer than the RHS target. */
if (warn_target_lifetime
&& rvalue->expr_type == EXPR_VARIABLE