]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix internal error on address of element of packed array component
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 10 Oct 2023 09:13:59 +0000 (11:13 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 7 Nov 2023 09:15:00 +0000 (10:15 +0100)
This occurs when the component is part of a discriminated type and its
offset depends on a discriminant, the problem being that the front-end
generates an incomplete Bit_Position attribute reference.

gcc/ada/

* exp_pakd.adb (Get_Base_And_Bit_Offset): Use the full component
reference instead of just the selector name for 'Bit_Position.

gcc/ada/exp_pakd.adb

index c3908a54538dbe6108d62a20b276052d3e003eca..ad12aec1e23e21a3b3416f60fbf3ab0fb3e594e9 100644 (file)
@@ -2112,8 +2112,8 @@ package body Exp_Pakd is
 
       --  We build up an expression serially that has the form
 
-      --    linear-subscript * component_size       for each array reference
-      --      +  field'Bit_Position                 for each record field
+      --    linear-subscript * component_size     for each array component ref
+      --      +  pref.component'Bit_Position      for each record component ref
       --      +  ...
 
       loop
@@ -2135,7 +2135,7 @@ package body Exp_Pakd is
          elsif Nkind (Base) = N_Selected_Component then
             Term :=
               Make_Attribute_Reference (Loc,
-                Prefix         => Selector_Name (Base),
+                Prefix         => Base,
                 Attribute_Name => Name_Bit_Position);
 
          else