This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, fortran] Error for non-contiguous pointers


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]