+2016-10-05 Fritz Reese <fritzoreese@gmail.com>
+
+ * interface.c (gfc_compare_types): Don't compare BT_UNION components
+ until we know they're both UNIONs.
+ * interface.c (gfc_compare_union_types): Guard against empty
+ components.
+
2016-10-05 Louis Krupp <louis.krupp@zoho.com>
PR fortran/67524
if (un1->attr.flavor != FL_UNION || un2->attr.flavor != FL_UNION)
return 0;
+ if (un1->attr.zero_comp != un2->attr.zero_comp)
+ return 0;
+
+ if (un1->attr.zero_comp)
+ return 1;
+
map1 = un1->components;
map2 = un2->components;
&& (ts1->u.derived->attr.sequence || ts1->u.derived->attr.is_bind_c))
return 1;
- if (ts1->type == BT_UNION && ts2->type == BT_UNION)
- return gfc_compare_union_types (ts1->u.derived, ts2->u.derived);
-
if (ts1->type != ts2->type
- && ((!gfc_bt_struct (ts1->type) && ts1->type != BT_CLASS)
- || (!gfc_bt_struct (ts2->type) && ts2->type != BT_CLASS)))
+ && ((ts1->type != BT_DERIVED && ts1->type != BT_CLASS)
+ || (ts2->type != BT_DERIVED && ts2->type != BT_CLASS)))
return 0;
+
+ if (ts1->type == BT_UNION)
+ return gfc_compare_union_types (ts1->u.derived, ts2->u.derived);
+
if (ts1->type != BT_DERIVED && ts1->type != BT_CLASS)
return (ts1->kind == ts2->kind);
+2016-10-05 Fritz Reese <fritzoreese@gmail.com>
+
+ * gfortran.dg/dec_union_9.f90: New testcase.
+ * gfortran.dg/dec_union_10.f90: New testcase.
+
2016-10-05 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/66343
--- /dev/null
+! { dg-do compile }
+! { dg-options "-fdec-structure" }
+!
+! Test a regression where union components could compare equal to structure/map
+! components, causing an ICE in gfc_conv_component_ref.
+!
+
+implicit none
+
+structure /s1/
+ integer(4) i
+end structure
+
+structure /s2/
+ union
+ map
+ record /s1/ r
+ end map
+ end union
+end structure
+
+record /s2/ x
+
+x.r.i = 0
+
+end