Skip to content

Commit 8d007d3

Browse files
committed
a68: fix layout of incomplete types
Apparently there is some case where the c_union of an union may be incomplete and the containing union complete. At this point I don't fully understand how is that possible and the layering out of modes should probably be rethinked, but for now fix this corner case. Signed-off-by: Jose E. Marchesi <[email protected]> gcc/algol68/ChangeLog * a68-low-moids.cc (a68_lower_moids): Fix for layout of incomplete types.
1 parent 2874932 commit 8d007d3

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

gcc/algol68/a68-low-moids.cc

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -688,27 +688,32 @@ a68_lower_moids (MOID_T *mode)
688688

689689
for (MOID_T *m = mode; m != NO_MOID; FORWARD (m))
690690
{
691-
if (!COMPLETE_TYPE_P (CTYPE (m)))
691+
if (IS_UNION (m))
692692
{
693-
if (IS_STRUCT (m))
693+
tree union_type = CTYPE (m);
694+
tree c_union_type = TREE_TYPE (TREE_CHAIN (TYPE_FIELDS (union_type)));
695+
696+
if (!COMPLETE_TYPE_P (c_union_type))
694697
{
695-
tree struct_type = CTYPE (m);
696-
layout_type (struct_type);
697-
compute_record_mode (struct_type);
698+
layout_type (c_union_type);
699+
compute_record_mode (c_union_type);
700+
gcc_assert (COMPLETE_TYPE_P (c_union_type));
698701
}
699-
else if (IS_UNION (m))
700-
{
701-
tree union_type = CTYPE (m);
702-
tree c_union_type = TREE_TYPE (TREE_CHAIN (TYPE_FIELDS (union_type)));
703-
704-
if (!COMPLETE_TYPE_P (c_union_type))
705-
{
706-
layout_type (c_union_type);
707-
compute_record_mode (c_union_type);
708-
}
709702

703+
if (!COMPLETE_TYPE_P (union_type))
704+
{
710705
layout_type (union_type);
711706
compute_record_mode (union_type);
707+
gcc_assert (COMPLETE_TYPE_P (union_type));
708+
}
709+
}
710+
else if (!COMPLETE_TYPE_P (CTYPE (m)))
711+
{
712+
if (IS_STRUCT (m))
713+
{
714+
tree struct_type = CTYPE (m);
715+
layout_type (struct_type);
716+
compute_record_mode (struct_type);
712717
}
713718
else
714719
layout_type (CTYPE (m));

0 commit comments

Comments
 (0)