[Bug fortran/52010] [OOP] Intrinsic assignment of a CLASS to a TYPE

burnus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jan 27 17:07:00 GMT 2012


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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-27 16:06:51 UTC ---
The following handles the checking part. However, one also needs to handle the
access internally (in trans-expr.c). Namely:
  type_var = class_var
  type_var = class_function ()
and both for "scalar = scalar", "array = scalar" and "array = array". Note that
the class_function can also be an intrinsic function such as RESHAPE. (Cf.
PR47505.)

--- expr.c      (revision 183625)
+++ expr.c      (working copy)
@@ -3256,3 +3256,8 @@ gfc_check_assign (gfc_expr *lvalue, gfc_

-  if (gfc_compare_types (&lvalue->ts, &rvalue->ts))
+  if (lvalue->ts.type == BT_DERIVED && rvalue->ts.type == BT_CLASS)
+    {
+      if (gfc_compare_types (&lvalue->ts, &CLASS_DATA (rvalue)->ts))
+       return SUCCESS;
+    }
+  else if (gfc_compare_types (&lvalue->ts, &rvalue->ts))
     return SUCCESS;



More information about the Gcc-bugs mailing list