]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
a68: fix layout of incomplete types
authorJose E. Marchesi <jose.marchesi@oracle.com>
Sat, 20 Dec 2025 14:59:50 +0000 (15:59 +0100)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Sat, 20 Dec 2025 15:52:23 +0000 (16:52 +0100)
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 <jemarch@gnu.org>
gcc/algol68/ChangeLog

* a68-low-moids.cc (a68_lower_moids): Fix for layout of
incomplete types.

gcc/algol68/a68-low-moids.cc

index 4dbf11891628ba7ca72502b8d6f68404947c2e54..b5bf46c8cf8e8300bcea91cf05f719aff9307df1 100644 (file)
@@ -688,27 +688,32 @@ a68_lower_moids (MOID_T *mode)
 
   for (MOID_T *m = mode; m != NO_MOID; FORWARD (m))
     {
-      if (!COMPLETE_TYPE_P (CTYPE (m)))
+      if (IS_UNION (m))
        {
-         if (IS_STRUCT (m))
+         tree union_type = CTYPE (m);
+         tree c_union_type = TREE_TYPE (TREE_CHAIN (TYPE_FIELDS (union_type)));
+
+         if (!COMPLETE_TYPE_P (c_union_type))
            {
-             tree struct_type = CTYPE (m);
-             layout_type (struct_type);
-             compute_record_mode (struct_type);
+             layout_type (c_union_type);
+             compute_record_mode (c_union_type);
+             gcc_assert (COMPLETE_TYPE_P (c_union_type));
            }
-         else if (IS_UNION (m))
-           {
-             tree union_type = CTYPE (m);
-             tree c_union_type = TREE_TYPE (TREE_CHAIN (TYPE_FIELDS (union_type)));
-
-             if (!COMPLETE_TYPE_P (c_union_type))
-               {
-                 layout_type (c_union_type);
-                 compute_record_mode (c_union_type);
-               }
 
+         if (!COMPLETE_TYPE_P (union_type))
+           {
              layout_type (union_type);
              compute_record_mode (union_type);
+             gcc_assert (COMPLETE_TYPE_P (union_type));
+           }
+       }
+      else if (!COMPLETE_TYPE_P (CTYPE (m)))
+       {
+         if (IS_STRUCT (m))
+           {
+             tree struct_type = CTYPE (m);
+             layout_type (struct_type);
+             compute_record_mode (struct_type);
            }
          else
            layout_type (CTYPE (m));