From 903ecc6c2a564e4d3754082e2025e1d80fddf5a4 Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Tue, 8 Jan 2019 20:29:01 +0100 Subject: [PATCH] re PR fortran/88047 (ICE in gfc_find_vtab, at fortran/class.c:2843) 2019-01-08 Janus Weil PR fortran/88047 * class.c (gfc_find_vtab): For polymorphic typespecs, the components of the class container may not be available (in case of invalid code). 2019-01-08 Janus Weil PR fortran/88047 * gfortran.dg/class_69.f90: New test case. From-SVN: r267735 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/class.c | 5 ++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/class_69.f90 | 21 +++++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/class_69.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 73d47da9832..f29be83229e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-01-08 Janus Weil + + PR fortran/88047 + * class.c (gfc_find_vtab): For polymorphic typespecs, the components of + the class container may not be available (in case of invalid code). + 2019-01-08 Richard Biener PR fortran/88611 diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index 77f0fca9385..8809b5b5b6e 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -2846,7 +2846,10 @@ gfc_find_vtab (gfc_typespec *ts) case BT_DERIVED: return gfc_find_derived_vtab (ts->u.derived); case BT_CLASS: - return gfc_find_derived_vtab (ts->u.derived->components->ts.u.derived); + if (ts->u.derived->components && ts->u.derived->components->ts.u.derived) + return gfc_find_derived_vtab (ts->u.derived->components->ts.u.derived); + else + return NULL; default: return find_intrinsic_vtab (ts); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 28439297735..2c9fe3255b2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-08 Janus Weil + + PR fortran/88047 + * gfortran.dg/class_69.f90: New test case. + 2019-01-08 H.J. Lu PR target/88717 diff --git a/gcc/testsuite/gfortran.dg/class_69.f90 b/gcc/testsuite/gfortran.dg/class_69.f90 new file mode 100644 index 00000000000..e45e03528b7 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_69.f90 @@ -0,0 +1,21 @@ +! { dg-do compile } +! +! PR 88047: [9 Regression] ICE in gfc_find_vtab, at fortran/class.c:2843 +! +! Contributed by G. Steinmetz + +subroutine sub_a + type t + end type + class(t) :: x(2) ! { dg-error "must be dummy, allocatable or pointer" } + class(t), parameter :: a(2) = t() ! { dg-error "cannot have the PARAMETER attribute" } + x = a ! { dg-error "Nonallocatable variable must not be polymorphic in intrinsic assignment" } +end + +subroutine sub_b + type t + integer :: n + end type + class(t) :: a, x ! { dg-error "must be dummy, allocatable or pointer" } + x = a ! { dg-error "Nonallocatable variable must not be polymorphic in intrinsic assignment" } +end -- 2.30.2