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  <anl...@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  <anl...@gmx.de>

        PR fortran/92898
        * gfortran.dg/pr91641.f90: Extend to check fix for PR92898.
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);
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

Reply via email to