2011-12-03 Tobias Burnus <burnus@net-b.de>
PR fortran/51383
* resolve.c (find_array_spec): Use ref->u.c.component
directly without starting from ts.u.derived.
2011-12-03 Tobias Burnus <burnus@net-b.de>
PR fortran/51383
* gfortran.dg/associate_10.f90: New.
===================================================================
@@ -4515,14 +4515,12 @@ find_array_spec (gfc_expr *e)
{
gfc_array_spec *as;
gfc_component *c;
- gfc_symbol *derived;
gfc_ref *ref;
if (e->symtree->n.sym->ts.type == BT_CLASS)
as = CLASS_DATA (e->symtree->n.sym)->as;
else
as = e->symtree->n.sym->as;
- derived = NULL;
for (ref = e->ref; ref; ref = ref->next)
switch (ref->type)
@@ -4536,26 +4534,7 @@ find_array_spec (gfc_expr *e)
break;
case REF_COMPONENT:
- if (derived == NULL)
- derived = e->symtree->n.sym->ts.u.derived;
-
- if (derived->attr.is_class)
- derived = derived->components->ts.u.derived;
-
- c = derived->components;
-
- for (; c; c = c->next)
- if (c == ref->u.c.component)
- {
- /* Track the sequence of component references. */
- if (c->ts.type == BT_DERIVED)
- derived = c->ts.u.derived;
- break;
- }
-
- if (c == NULL)
- gfc_internal_error ("find_array_spec(): Component not found");
-
+ c = ref->u.c.component;
if (c->attr.dimension)
{
if (as != NULL)
===================================================================
@@ -0,0 +1,23 @@
+! { dg-do compile }
+!
+! PR fortran/51383
+!
+! Contributed by kaiserkarl31@yahoo.com
+!
+! Was failing before at the ref resolution of y1(1)%i.
+!
+program extend
+ type :: a
+ integer :: i
+ end type a
+ type, extends (a) :: b
+ integer :: j
+ end type b
+ type (a) :: x(2)
+ type (b) :: y(2)
+ associate (x1 => x, y1 => y)
+ x1(1)%i = 1
+ ! Commenting out the following line will avoid the error
+ y1(1)%i = 2
+ end associate
+end program extend