http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50981

--- Comment #17 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-10 
23:54:50 UTC ---
(In reply to comment #16)
> This patch passes gfortran.dg/*elemental*, but fails on
> gfortran.dg/class_array_{1,2,3,7,9}.f03.

The problem is the way _copy is translated. One currently has in trans-stmt.c's
gfc_trans_allocate

              /* Do a polymorphic deep copy.  */
              actual->next->expr->ts.type = BT_CLASS;
              gfc_add_data_component (actual->next->expr);

This adds "class._data". With the patch of comment 16 one has now additionally
in trans-expr.c's gfc_conv_procedure_call:

+         if (fsym && fsym->ts.type == BT_DERIVED && e->ts.type == BT_CLASS)
+           parmse.expr = gfc_class_data_get (parmse.expr);

If one removes the latter it works.

I think the proper solution is to remove the trans-stmt.c manual scalarization
and handle somewhere in trans-{array,expr}.c the array bounds.

Stupid attempts fail for various reasons: Changing the BT_CLASS to BT_DERIVED
in gfc_trans_allocate does not work as one the offsets will no longer be
class._size (why?). Keeping BT_CLASS but removing the gfc_add_data_component in
trans-stmt.c will ICE for dataref - and removing that as well will lead to
valid code with class._size, but without scalarization loop ...

Reply via email to