https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66089

--- Comment #33 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
A much cleaner patch which gets us to the wrong code:

Index: trans-expr.c
===================================================================
--- trans-expr.c        (Revision 269260)
+++ trans-expr.c        (Arbeitskopie)
@@ -10510,6 +10510,9 @@
       if (is_poly_assign && expr2->rank == 0 && !UNLIMITED_POLY (expr2))
        rss->info->type = GFC_SS_REFERENCE;

+      gfc_fix_class_refs (rss->info->expr);
+      gfc_fix_class_refs (lss->info->expr);
+
       rss->no_bounds_check = expr2->no_bounds_check;
       /* Associate the SS with the loop.  */
       gfc_add_ss_to_loop (&loop, lss);

Now, gfc_conv_resolve_dependencies sets
ss_info->data.scalar.needs_temporary = 1 both for type and class,
but obviously the temporary is not being generated for class.

Digging deeper a bit, it seems that gfc_scalar_elemental_arg_saved_as_reference
returns true for the class (which generated wrong code), false for the
type.

Reply via email to