]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix internal error on misaligned component with variable nominal size
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 7 Sep 2023 08:53:39 +0000 (10:53 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 15 Sep 2023 13:01:30 +0000 (15:01 +0200)
The back-end cannot handle this kind of components even when they are small.

gcc/ada/

* exp_util.adb (Component_May_Be_Bit_Aligned): Do not return false
for a small component of a record type with a variant part.

gcc/ada/exp_util.adb

index b2542d4ae593d2c8b1561023cae0682cdeef074c..2e6a1cf892eb9b623078b0313779a35e83aa04c3 100644 (file)
@@ -4989,12 +4989,15 @@ package body Exp_Util is
          return False;
 
       --  If we know that we have a small (at most the maximum integer size)
-      --  record or bit-packed array, then everything is fine, since the back
-      --  end can handle these cases correctly, except if a slice is involved.
+      --  bit-packed array or record without variant part, then everything is
+      --  fine, since the back end can handle these cases correctly, except if
+      --  a slice is involved.
 
       elsif Known_Esize (Comp)
         and then Esize (Comp) <= System_Max_Integer_Size
-        and then (Is_Record_Type (UT) or else Is_Bit_Packed_Array (UT))
+        and then (Is_Bit_Packed_Array (UT)
+                   or else (Is_Record_Type (UT)
+                             and then not Has_Variant_Part (UT)))
         and then not For_Slice
       then
          return False;