diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2019-10-18 12:38:26 +0000 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2019-10-18 12:38:26 +0000 |
commit | 14bd751f8109a703255168d26fa6693bc89bcf04 (patch) | |
tree | 93ea0dfc8c813971bfa6b7bf8fff8109182ceff1 | |
parent | 696d750ce308bc0005ba225ab8c47e5ca2297535 (diff) |
Fortran] PR91586 Fix ICE on invalid code with CLASS
gcc/fortran/
Backport from mainline
2019-10-18 Tobias Burnus <tobias@codesourcery.com>
PR fortran/91586
* class.c (gfc_find_derived_vtab): Return NULL
instead of deref'ing NULL pointer.
gcc/testsuite/
Backport from mainline
2019-10-18 Tobias Burnus <tobias@codesourcery.com>
PR fortran/91586
* gfortran.dg/class_71.f90: New.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-9-branch@277154 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/fortran/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/fortran/class.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/class_71.f90 | 13 |
4 files changed, 33 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 66ff7f143fe..eb84a154d27 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2019-10-18 Tobias Burnus <tobias@codesourcery.com> + + Backport from mainline + 2019-10-18 Tobias Burnus <tobias@codesourcery.com> + + PR fortran/91586 + * class.c (gfc_find_derived_vtab): Return NULL + instead of deref'ing NULL pointer. + 2019-10-17 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/83113 diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index 8a1f43f116c..9117121e5fe 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -2241,6 +2241,9 @@ gfc_find_derived_vtab (gfc_symbol *derived) if (!derived->attr.unlimited_polymorphic && derived->attr.is_class) derived = gfc_get_derived_super_type (derived); + if (!derived) + return NULL; + /* Find the gsymbol for the module of use associated derived types. */ if ((derived->attr.use_assoc || derived->attr.used_in_submodule) && !derived->attr.vtype && !derived->attr.is_class) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4de50acd482..b429ed3c93e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2019-10-18 Tobias Burnus <tobias@codesourcery.com> + + Backport from mainline + 2019-10-18 Tobias Burnus <tobias@codesourcery.com> + + PR fortran/91586 + * gfortran.dg/class_71.f90: New. + 2019-10-17 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/83113 diff --git a/gcc/testsuite/gfortran.dg/class_71.f90 b/gcc/testsuite/gfortran.dg/class_71.f90 new file mode 100644 index 00000000000..bc0ffcd2305 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_71.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! +! PR fortran/91586 +! +! Contributed by G. Steinmetz +! +program p + type t + class(*), allocatable :: a + end type + class(t) :: x, y ! { dg-error "must be dummy, allocatable or pointer" } + y = x ! { dg-error "Nonallocatable variable must not be polymorphic in intrinsic assignment" } +end |