This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PR fortran/71862] Patch
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 22 Jul 2016 12:52:48 -0700
- Subject: [PR fortran/71862] Patch
- Authentication-results: sourceware.org; auth=none
- Reply-to: kargl at uw dot edu
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