[PR fortran/71862] Patch
Steve Kargl
sgk@troutmask.apl.washington.edu
Fri Jul 22 19:53:00 GMT 2016
I intend to commit the following patch and close the
PR in approximate 6.283 hours.
2016-07-22 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/71862
* class.c: Remove assert. Iterate over component only if non-null.
2016-07-22 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/71862
* gfortran.dg/pr71862.f90: New test.
Index: gcc/fortran/class.c
===================================================================
--- gcc/fortran/class.c (revision 238665)
+++ gcc/fortran/class.c (working copy)
@@ -238,12 +238,14 @@ gfc_add_component_ref (gfc_expr *e, cons
/* 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;
+ }
}
Index: gcc/testsuite/gfortran.dg/pr71862.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr71862.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr71862.f90 (working copy)
@@ -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
--
Steve
More information about the Fortran
mailing list