mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-31 18:40:52 +08:00
Fortran: error recovery handling invalid CLASS variable [PR107899]
gcc/fortran/ChangeLog: PR fortran/107899 * resolve.cc (resolve_deallocate_expr): Avoid NULL pointer dereference on invalid CLASS variable. gcc/testsuite/ChangeLog: PR fortran/107899 * gfortran.dg/pr107899.f90: New test.
This commit is contained in:
parent
079add3ad3
commit
9123863828
@ -7570,7 +7570,7 @@ resolve_deallocate_expr (gfc_expr *e)
|
||||
sym = e->symtree->n.sym;
|
||||
unlimited = UNLIMITED_POLY(sym);
|
||||
|
||||
if (sym->ts.type == BT_CLASS)
|
||||
if (sym->ts.type == BT_CLASS && sym->attr.class_ok && CLASS_DATA (sym))
|
||||
{
|
||||
allocatable = CLASS_DATA (sym)->attr.allocatable;
|
||||
pointer = CLASS_DATA (sym)->attr.class_pointer;
|
||||
|
13
gcc/testsuite/gfortran.dg/pr107899.f90
Normal file
13
gcc/testsuite/gfortran.dg/pr107899.f90
Normal file
@ -0,0 +1,13 @@
|
||||
! { dg-do compile }
|
||||
! { dg-options "-fcoarray=single" }
|
||||
! PR fortran/107899 - ICE in resolve_deallocate_expr
|
||||
! Contributed by G.Steinmetz
|
||||
|
||||
program p
|
||||
type t
|
||||
end type
|
||||
class(t), target :: x[:] ! { dg-error "deferred shape" }
|
||||
if (allocated (x)) then ! { dg-error "must be ALLOCATABLE" }
|
||||
deallocate (x) ! { dg-error "must be ALLOCATABLE or a POINTER" }
|
||||
end if
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user