From: Steven G. Kargl Date: Wed, 7 Feb 2018 22:29:22 +0000 (+0000) Subject: re PR fortran/82994 (ICE in gfc_match_deallocate, at fortran/match.c:4478) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b35a0ccd139f5df8262ef7ea5fed81d88074ecf8;p=gcc.git re PR fortran/82994 (ICE in gfc_match_deallocate, at fortran/match.c:4478) 2018-02-07 Steven G. Kargl PR fortran/82994 * match.c (gfc_match_deallocate): Check for NULL pointer. 2018-02-07 Steven G. Kargl PR fortran/82994 * gfortran.dg/deallocate_error_3.f90: New test. * gfortran.dg/deallocate_error_4.f90: New test. From-SVN: r257465 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7dbb9c19849..a87c48a3ff8 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2018-02-07 Steven G. Kargl + + PR fortran/82994 + * match.c (gfc_match_deallocate): Check for NULL pointer. + 2018-02-07 Thomas Koenig PR fortran/68560 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 7bce34b56a0..9313f435ffb 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -4632,8 +4632,8 @@ gfc_match_deallocate (void) && (tail->expr->ref->type == REF_COMPONENT || tail->expr->ref->type == REF_ARRAY)); if (sym && sym->ts.type == BT_CLASS) - b2 = !(CLASS_DATA (sym)->attr.allocatable - || CLASS_DATA (sym)->attr.class_pointer); + b2 = !(CLASS_DATA (sym) && (CLASS_DATA (sym)->attr.allocatable + || CLASS_DATA (sym)->attr.class_pointer)); else b2 = sym && !(sym->attr.allocatable || sym->attr.pointer || sym->attr.proc_pointer); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 24a99a58ecd..6d82e4e2d74 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-02-07 Steven G. Kargl + + PR fortran/82994 + * gfortran.dg/deallocate_error_3.f90: New test. + * gfortran.dg/deallocate_error_4.f90: New test. + 2018-02-07 Thomas Koenig PR fortran/68560 diff --git a/gcc/testsuite/gfortran.dg/deallocate_error_3.f90 b/gcc/testsuite/gfortran.dg/deallocate_error_3.f90 new file mode 100644 index 00000000000..149b7c8c15a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/deallocate_error_3.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR fortran/82994 +! Code contributed by Gerhard Steinmetz +program p + type t + end type + class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" } + deallocate (x) ! { dg-error "not a nonprocedure pointer nor an allocatable" } +end diff --git a/gcc/testsuite/gfortran.dg/deallocate_error_4.f90 b/gcc/testsuite/gfortran.dg/deallocate_error_4.f90 new file mode 100644 index 00000000000..c12e776dd27 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/deallocate_error_4.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! PR fortran/82994 +! Code contributed by Gerhard Steinmetz +program p + type t + end type + class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" } + allocate (x) ! { dg-error "neither a data pointer nor an allocatable" } + deallocate (x) ! { dg-error "not a nonprocedure pointer nor an allocatable" } +end