The check for assigning a pointer that cannot be determined to be simply
contiguous at compile time to a contiguous pointer does not need to be
invoked if the lhs of the assignment is known to have conflicting attributes.
2020-06-11  Harald Anlauf  <anlauf@gmx.de>
gcc/fortran/
	PR fortran/95503
	* expr.c (gfc_check_pointer_assign): Skip contiguity check of rhs
	of pointer assignment if lhs cannot be simply contiguous.
gcc/testsuite/
	PR fortran/95503
	* gfortran.dg/pr95503.f90: New test.
      contiguous.  Be lenient in the definition of what counts as
      contiguous.  */
 
-  if (lhs_attr.contiguous && !gfc_is_simply_contiguous (rvalue, false, true))
+  if (lhs_attr.contiguous
+      && lhs_attr.dimension > 0
+      && !gfc_is_simply_contiguous (rvalue, false, true))
     gfc_warning (OPT_Wextra, "Assignment to contiguous pointer from "
                 "non-contiguous target at %L", &rvalue->where);
 
 
--- /dev/null
+! { dg-do compile }
+! PR fortran/95503 - ICE in gfc_is_simply_contiguous
+
+program p
+  complex, target :: a
+  real, pointer, contiguous :: b => a%re ! { dg-error "not an array pointer" }
+end