2013-07-30 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Jul 2013 07:20:43 +0000 (07:20 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Jul 2013 07:20:43 +0000 (07:20 +0000)
        PR fortran/57530
        * symbol.c (gfc_type_compatible): A type is type compatible with
        a class if both have the same declared type.
        * interface.c (compare_type): Reject CLASS/TYPE even if they
        are type compatible.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@201329 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/interface.c
gcc/fortran/symbol.c

index 6e00cdc..8faf7ec 100644 (file)
@@ -1,6 +1,14 @@
 2013-07-30  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/57530
+       * symbol.c (gfc_type_compatible): A type is type compatible with
+       a class if both have the same declared type.
+       * interface.c (compare_type): Reject CLASS/TYPE even if they
+       are type compatible.
+
+2013-07-30  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/57530
        * trans-expr.c (gfc_trans_class_assign): Handle CLASS array
        functions.
        (gfc_trans_pointer_assign): Ditto and support pointer assignment of
index 339dd24..9055cf5 100644 (file)
@@ -514,6 +514,12 @@ compare_type (gfc_symbol *s1, gfc_symbol *s2)
   if (s2->attr.ext_attr & (1 << EXT_ATTR_NO_ARG_CHECK))
     return 1;
 
+  /* TYPE and CLASS of the same declared type are type compatible,
+     but have different characteristics.  */
+  if ((s1->ts.type == BT_CLASS && s2->ts.type == BT_DERIVED)
+      || (s1->ts.type == BT_DERIVED && s2->ts.type == BT_CLASS))
+    return 0;
+
   return gfc_compare_types (&s1->ts, &s2->ts) || s2->ts.type == BT_ASSUMED;
 }
 
index c72974d..9d23e8b 100644 (file)
@@ -4489,6 +4489,9 @@ gfc_type_compatible (gfc_typespec *ts1, gfc_typespec *ts2)
   if (is_derived1 && is_derived2)
     return gfc_compare_derived_types (ts1->u.derived, ts2->u.derived);
 
+  if (is_derived1 && is_class2)
+    return gfc_compare_derived_types (ts1->u.derived,
+                                     ts2->u.derived->components->ts.u.derived);
   if (is_class1 && is_derived2)
     return gfc_type_is_extension_of (ts1->u.derived->components->ts.u.derived,
                                     ts2->u.derived);