[PR,fortran/95503,9/10/11,Regression] ICE in gfc_is_simply_contiguous, at fortran/expr.c:5844

Message ID trinity-43f06470-fdd1-49ea-9fc9-f9353aea5f34-1591296458395@3c-app-gmx-bs48
State New
Headers show
Series
  • [PR,fortran/95503,9/10/11,Regression] ICE in gfc_is_simply_contiguous, at fortran/expr.c:5844
Related show

Commit Message

Harald Anlauf June 4, 2020, 6:47 p.m.
The following patch fixes an almost obvious ICE in invalid.

Regtested on x86_64-pc-linux-gnu.

OK for master, and backports to 9/10?

Thanks,
Harald


PR fortran/95503 - ICE in gfc_is_simply_contiguous, at fortran/expr.c:5844

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-04  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.

Comments

Harald Anlauf June 10, 2020, 7:55 p.m. | #1
Early ping.

> Gesendet: Donnerstag, 04. Juni 2020 um 20:47 Uhr

> Von: "Harald Anlauf" <anlauf@gmx.de>

> An: "fortran" <fortran@gcc.gnu.org>, "gcc-patches" <gcc-patches@gcc.gnu.org>

> Betreff: [PATCH, PR fortran/95503]  [9/10/11 Regression] ICE in gfc_is_simply_contiguous, at fortran/expr.c:5844

>

> The following patch fixes an almost obvious ICE in invalid.

>

> Regtested on x86_64-pc-linux-gnu.

>

> OK for master, and backports to 9/10?

>

> Thanks,

> Harald

>

>

> PR fortran/95503 - ICE in gfc_is_simply_contiguous, at fortran/expr.c:5844

>

> 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-04  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.

>

>
David Malcolm via Gcc-patches June 11, 2020, 1:20 p.m. | #2
Hi Harald,

> The following patch fixes an almost obvious ICE in invalid.

> 

> Regtested on x86_64-pc-linux-gnu.

> 

> OK for master, and backports to 9/10?


OK.  Thanks for the patch!

Regards

	Thomas

Patch

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index a9fa03ad153..8daa7bb8d06 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -4346,7 +4346,9 @@  gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue,
      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);

diff --git a/gcc/testsuite/gfortran.dg/pr95503.f90 b/gcc/testsuite/gfortran.dg/pr95503.f90
new file mode 100644
index 00000000000..4a202b405c4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95503.f90
@@ -0,0 +1,7 @@ 
+! { 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