From: Harald Anlauf Date: Sat, 27 Jun 2020 12:56:33 +0000 (+0200) Subject: PR fortran/95881 - ICE in resolve_symbol, at fortran/resolve.c:15175 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3cbc0fb39c84ae0a51a9a88649dccd105bf17d6e;p=gcc.git PR fortran/95881 - ICE in resolve_symbol, at fortran/resolve.c:15175 Avoid NULL pointer dereference. gcc/fortran/ PR fortran/95881 * resolve.c (resolve_symbol): Avoid NULL pointer dereference. --- diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 6fa34caec54..f3e8ffc204c 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -15170,6 +15170,7 @@ resolve_symbol (gfc_symbol *sym) if (flag_coarray == GFC_FCOARRAY_LIB && sym->ts.type == BT_CLASS && sym->ts.u.derived && CLASS_DATA (sym) && CLASS_DATA (sym)->attr.codimension + && CLASS_DATA (sym)->ts.u.derived && (CLASS_DATA (sym)->ts.u.derived->attr.alloc_comp || CLASS_DATA (sym)->ts.u.derived->attr.pointer_comp)) { diff --git a/gcc/testsuite/gfortran.dg/pr95881.f90 b/gcc/testsuite/gfortran.dg/pr95881.f90 new file mode 100644 index 00000000000..9f171764948 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr95881.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! { dg-options "-fcoarray=lib" } +! PR fortran/95881 - ICE in resolve_symbol, at fortran/resolve.c:15175 + +program p + type t + real, allocatable :: a[:] + end type t + class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" } + allocate (x%a[*]) +end