From b35a0ccd139f5df8262ef7ea5fed81d88074ecf8 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Wed, 7 Feb 2018 22:29:22 +0000 Subject: [PATCH] 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 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/match.c | 4 ++-- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gfortran.dg/deallocate_error_3.f90 | 9 +++++++++ gcc/testsuite/gfortran.dg/deallocate_error_4.f90 | 10 ++++++++++ 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/deallocate_error_3.f90 create mode 100644 gcc/testsuite/gfortran.dg/deallocate_error_4.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7dbb9c1..a87c48a 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 7bce34b..9313f43 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 24a99a5..6d82e4e 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 0000000..149b7c8 --- /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 0000000..c12e776 --- /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 -- 2.7.4