From: Tobias Burnus Date: Fri, 18 Oct 2019 12:04:31 +0000 (+0000) Subject: Fortran] PR91586 Fix ICE on invalid code with CLASS X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7c929c9c611546f0e77753e90b652f7607d06484;p=gcc.git Fortran] PR91586 Fix ICE on invalid code with CLASS gcc/fortran/ PR fortran/91586 * class.c (gfc_find_derived_vtab): Return NULL instead of deref'ing NULL pointer. gcc/testsuite/ PR fortran/91586 * gfortran.dg/class_71.f90: New. From-SVN: r277153 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 1dbc890f5da..8a1beeafa01 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-10-18 Tobias Burnus + + PR fortran/91586 + * class.c (gfc_find_derived_vtab): Return NULL + instead of deref'ing NULL pointer. + 2019-10-15 James Norris Tobias Burnus 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 b783c8dede3..4e817eb1371 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-10-18 Tobias Burnus + + PR fortran/91586 + * gfortran.dg/class_71.f90: New. + 2019-10-18 Georg-Johann Lay Fix some fallout for small targets. 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