From: José Rui Faustino de Sousa Date: Fri, 16 Apr 2021 16:17:21 +0000 (+0000) Subject: Fortran: Fix ICE due to referencing a NULL pointer [PR100018] X-Git-Tag: basepoints/gcc-12~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98c5b5924de969ae8ab37d140aa85bcca3f3c76c;p=thirdparty%2Fgcc.git Fortran: Fix ICE due to referencing a NULL pointer [PR100018] 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. --- diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 1c9b0c5cb622..dd4b26680e04 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -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 index 000000000000..f1cf2676f854 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/PR10018.f90 @@ -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 }