]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: Fix ICE due to referencing a NULL pointer [PR100018]
authorJosé Rui Faustino de Sousa <jrfsousa@gmail.com>
Fri, 16 Apr 2021 16:17:21 +0000 (16:17 +0000)
committerJosé Rui Faustino de Sousa <jrfsousa@gmail.com>
Fri, 16 Apr 2021 16:19:56 +0000 (16:19 +0000)
gcc/fortran/ChangeLog:

PR fortran/100018
* resolve.c: Add association check before de-referencing pointer.

gcc/testsuite/ChangeLog:

PR fortran/100018
* gfortran.dg/PR10018.f90: New test.

gcc/fortran/resolve.c
gcc/testsuite/gfortran.dg/PR10018.f90 [new file with mode: 0644]

index 1c9b0c5cb622f299a7387aa4cbbfd3399670961b..dd4b26680e04f30324493a40803151b4aa360946 100644 (file)
@@ -11999,6 +11999,7 @@ start:
            /* Assigning a class object always is a regular assign.  */
            if (code->expr2->ts.type == BT_CLASS
                && code->expr1->ts.type == BT_CLASS
+               && CLASS_DATA (code->expr2)
                && !CLASS_DATA (code->expr2)->attr.dimension
                && !(gfc_expr_attr (code->expr1).proc_pointer
                     && code->expr2->expr_type == EXPR_VARIABLE
diff --git a/gcc/testsuite/gfortran.dg/PR10018.f90 b/gcc/testsuite/gfortran.dg/PR10018.f90
new file mode 100644 (file)
index 0000000..f1cf267
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do compile }
+!
+subroutine foo(that)
+  implicit none
+  class(*),  target, intent(in)  :: this
+  class(*), pointer, intent(out) :: that
+
+  that => this
+  return
+end subroutine foo
+! { dg-error "Symbol at \\\(1\\\) is not a DUMMY variable" "" { target "*-*-*" } 5 }