From 3cbc0fb39c84ae0a51a9a88649dccd105bf17d6e Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sat, 27 Jun 2020 14:56:33 +0200 Subject: [PATCH] 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. --- gcc/fortran/resolve.c | 1 + gcc/testsuite/gfortran.dg/pr95881.f90 | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr95881.f90 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 -- 2.30.2