From: Steven G. Kargl Date: Wed, 7 Feb 2018 22:41:59 +0000 (+0000) Subject: re PR fortran/82994 (ICE in gfc_match_deallocate, at fortran/match.c:4478) X-Git-Tag: releases/gcc-6.5.0~539 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b957ec24e4566f84b17618216a54bab571fba33f;p=thirdparty%2Fgcc.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: r257468 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 00caf4add6ed..c3a2b628d8ab 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 Steven G. Kargl PR fortran/82049 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index d3ea16735543..516abc5ba80e 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -4275,8 +4275,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 4e8db9407c9a..09a8056109cf 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 Steven G. Kargl PR fortran/82049 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 000000000000..149b7c8c15a2 --- /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 000000000000..c12e776dd275 --- /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