[Patch, Fortran] PR92898 - [9/10 Regression] ICE in gfc_check_is_contiguous, at fortran/check.c:7157

Harald Anlauf anlauf@gmx.de
Tue Dec 10 22:05:00 GMT 2019


The testcase in the PR exhibits a corner case in a check on invalid
code that was not handled appropriately and in turn ICEs.  The patch
below enhances that check.  Instead of adding a new testcase, I modified
the related one that came with the 'introduction' of the regression when
fixing PR91641.

Regtested on x86_64-pc-linux-gnu.

OK for trunk and 9 ?

Thanks,
Harald

2019-12-10  Harald Anlauf  <anlauf@gmx.de>

	PR fortran/92898
	* check.c (gfc_check_is_contiguous): Adjust check to handle NULL()
	argument without an actual argument.

2019-12-10  Harald Anlauf  <anlauf@gmx.de>

	PR fortran/92898
	* gfortran.dg/pr91641.f90: Extend to check fix for PR92898.
-------------- next part --------------
Index: gcc/fortran/check.c
===================================================================
--- gcc/fortran/check.c	(Revision 279183)
+++ gcc/fortran/check.c	(Arbeitskopie)
@@ -7154,7 +7154,9 @@ bool
 gfc_check_is_contiguous (gfc_expr *array)
 {
   if (array->expr_type == EXPR_NULL
-      && array->symtree->n.sym->attr.pointer == 1)
+      && (!array->symtree ||
+	  (array->symtree->n.sym &&
+	   array->symtree->n.sym->attr.pointer == 1)))
     {
       gfc_error ("Actual argument at %L of %qs intrinsic shall be an "
 		 "associated pointer", &array->where, gfc_current_intrinsic);
-------------- next part --------------
Index: gcc/testsuite/gfortran.dg/pr91641.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr91641.f90	(Revision 279183)
+++ gcc/testsuite/gfortran.dg/pr91641.f90	(Arbeitskopie)
@@ -1,7 +1,9 @@
 ! { dg-do compile }
 ! PR fortran/91641
-! Code conyributed by Gerhard Steinmetz
+! PR fortran/92898
+! Code contributed by Gerhard Steinmetz
 program p
    real, pointer :: z(:)
    print *, is_contiguous (null(z))    ! { dg-error "shall be an associated" }
+   print *, is_contiguous (null())     ! { dg-error "shall be an associated" }
 end


More information about the Fortran mailing list