From 5f395580078d31f52b920a46a723da54c080a04e Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Wed, 9 Nov 2016 10:22:52 +0100 Subject: [PATCH] re PR fortran/71894 ([OOP] ICE in gfc_add_component_ref, at fortran/class.c:227) 2016-11-09 Janus Weil PR fortran/71894 * class.c (gfc_add_component_ref): Add safety checks to avoid ICE. 2016-11-09 Janus Weil PR fortran/71894 * gfortran.dg/class_59.f90: New test. From-SVN: r241993 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/class.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/class_59.f90 | 25 +++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/class_59.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 499c3d4c4e3..6c39866487f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2016-11-09 Janus Weil + + PR fortran/71894 + * class.c (gfc_add_component_ref): Add safety checks to avoid ICE. + 2016-11-08 Janus Weil PR fortran/68440 diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index 400c22abaf5..b7f68d2f19a 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -224,7 +224,8 @@ gfc_add_component_ref (gfc_expr *e, const char *name) break; tail = &((*tail)->next); } - if (derived->components->next->ts.type == BT_DERIVED && + if (derived->components && derived->components->next && + derived->components->next->ts.type == BT_DERIVED && derived->components->next->ts.u.derived == NULL) { /* Fix up missing vtype. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 888e9e2f6c0..43586a91430 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-09 Janus Weil + + PR fortran/71894 + * gfortran.dg/class_59.f90: New test. + 2016-11-09 Richard Biener PR tree-optimization/78007 diff --git a/gcc/testsuite/gfortran.dg/class_59.f90 b/gcc/testsuite/gfortran.dg/class_59.f90 new file mode 100644 index 00000000000..e077ef8dc30 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_59.f90 @@ -0,0 +1,25 @@ +! { dg-do compile } +! +! PR 71894: [OOP] ICE in gfc_add_component_ref, at fortran/class.c:227 +! +! Contributed by Gerhard Steinmetz + +subroutine s1 + type t + integer :: n + end type + type(t) :: x + class(t) :: y ! { dg-error "must be dummy, allocatable or pointer" } + x = y +end + +subroutine s2 + type t + end type + class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" } + class(t), allocatable :: y + select type (y) + type is (t) + y = x + end select +end -- 2.30.2