From: Steven G. Kargl Date: Tue, 26 Jul 2016 22:42:49 +0000 (+0000) Subject: re PR fortran/71862 (ICE in gfc_add_component_ref, at fortran/class.c:241) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9cd74e8fa89a528c779bbc9f31a2b362db9c12ec;p=gcc.git re PR fortran/71862 (ICE in gfc_add_component_ref, at fortran/class.c:241) 2016-07-22 Steven G. Kargl PR fortran/71862 * class.c: Remove assert. Iterate over component only if non-null. 2016-07-22 Steven G. Kargl PR fortran/71862 * gfortran.dg/pr71862.f90: New test. From-SVN: r238774 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b056e0e86e8..0847e64fc5f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2016-07-26 Steven G. Kargl + + PR fortran/71862 + * class.c: Remove assert. Iterate over component only if non-null. + 2016-07-22 Steven G. Kargl PR fortran/71935 diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index a627448529e..6d324a61242 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -238,12 +238,14 @@ gfc_add_component_ref (gfc_expr *e, const char *name) /* Avoid losing memory. */ gfc_free_ref_list (*tail); c = gfc_find_component (derived, name, true, true, tail); - gcc_assert (c); - for (ref = *tail; ref->next; ref = ref->next) - ; - ref->next = next; - if (!next) - e->ts = c->ts; + + if (c) { + for (ref = *tail; ref->next; ref = ref->next) + ; + ref->next = next; + if (!next) + e->ts = c->ts; + } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 23a30625ccf..3c335c6eb42 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-07-26 Steven G. Kargl + + PR fortran/71862 + * gfortran.dg/pr71862.f90: New test. + 2016-07-26 Martin Sebor * gcc.dg/atomic/pr71675.c: Replace the unsupported c11 target diff --git a/gcc/testsuite/gfortran.dg/pr71862.f90 b/gcc/testsuite/gfortran.dg/pr71862.f90 new file mode 100644 index 00000000000..411bfc27848 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr71862.f90 @@ -0,0 +1,16 @@ +! { dg-do compile } +program p + type t + integer :: n = 0 + integer, pointer :: q => null() + end type + type(t) :: x + print *, associated(x%q) + x = f() + print *, associated(x%q) +contains + function f() result (z) ! { dg-error "must be dummy, allocatable or pointer" } + class(t) :: z + print *, associated(z%q) + end +end