From fba5a793b30b22de6ac5ad185b99b45b835227fd Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Thu, 24 Nov 2016 18:27:58 +0000 Subject: [PATCH] re PR fortran/78500 (ICE in gfc_check_vardef_context, at fortran/expr.c:5289) 2016-11-24 Steven G. Kargl PR fortran/78500 * expr.c (gfc_check_vardef_contextm): Fix NULL pointer dereference. * interface.c (matching_typebound_op): Ditto. 2016-11-24 Steven G. Kargl PR fortran/78500 * gfortran.dg/class_result_4.f90: New test. From-SVN: r242846 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/expr.c | 3 ++- gcc/fortran/interface.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/class_result_4.f90 | 6 ++++++ 5 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/class_result_4.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e468a492881..4c27f1b622e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-11-24 Steven G. Kargl + + PR fortran/78500 + * expr.c (gfc_check_vardef_contextm): Fix NULL pointer dereference. + * interface.c (matching_typebound_op): Ditto. + 2016-11-23 Steven G. Kargl PR fortran/78297 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index b028d81ba6d..60f6080877f 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -5291,7 +5291,8 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj, component. Note that (normal) assignment to procedure pointers is not possible. */ check_intentin = !own_scope; - ptr_component = (sym->ts.type == BT_CLASS && CLASS_DATA (sym)) + ptr_component = (sym->ts.type == BT_CLASS && sym->ts.u.derived + && CLASS_DATA (sym)) ? CLASS_DATA (sym)->attr.class_pointer : sym->attr.pointer; for (ref = e->ref; ref && check_intentin; ref = ref->next) { diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index a0cb0bb9ce3..4c8d67193ae 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -3885,7 +3885,7 @@ matching_typebound_op (gfc_expr** tb_base, if (base->expr->ts.type == BT_CLASS) { - if (CLASS_DATA (base->expr) == NULL + if (!base->expr->ts.u.derived || CLASS_DATA (base->expr) == NULL || !gfc_expr_attr (base->expr).class_ok) continue; derived = CLASS_DATA (base->expr)->ts.u.derived; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 194e85fd49b..144cd3cbff0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-24 Steven G. Kargl + + PR fortran/78500 + * gfortran.dg/class_result_4.f90: New test. + 2016-11-24 James Greenhalgh * gcc.target/aarch64/_Float16_1.c: New. diff --git a/gcc/testsuite/gfortran.dg/class_result_4.f90 b/gcc/testsuite/gfortran.dg/class_result_4.f90 new file mode 100644 index 00000000000..4b22a3c30ee --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_result_4.f90 @@ -0,0 +1,6 @@ +! { dg-do compile } +! PR fortran/78500 +class(t) function f() ! { dg-error "must be dummy, allocatable or pointer" } + f = 1 ! { dg-error "variable must not be polymorphic" } +end + -- 2.30.2