]> gcc.gnu.org Git - gcc.git/commitdiff
[Ada] Do not replace bounds for packed arrays that depend on discriminants
authorGhjuvan Lacambre <lacambre@adacore.com>
Mon, 6 Jul 2020 13:56:28 +0000 (15:56 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 19 Oct 2020 09:53:38 +0000 (05:53 -0400)
gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference): Check if type
depends on discriminant.

gcc/ada/exp_attr.adb

index 827704bdb67627a9fd8548c307ff65a9f1327a9c..70f353fe3c39a9981b4a4177a1c9b033cdacc7d3 100644 (file)
@@ -3456,8 +3456,12 @@ package body Exp_Attr is
          --  replace this attribute with a direct reference to the attribute of
          --  the appropriate index subtype (since otherwise the back end will
          --  try to give us the value of 'First for this implementation type).
+         --  Do not do this if Ptyp depends on a discriminant as its bounds
+         --  are only available through N.
 
-         if Is_Constrained_Packed_Array (Ptyp) then
+         if Is_Constrained_Packed_Array (Ptyp)
+           and then not Size_Depends_On_Discriminant (Ptyp)
+         then
             Rewrite (N,
               Make_Attribute_Reference (Loc,
                 Attribute_Name => Attribute_Name (N),
This page took 0.070728 seconds and 5 git commands to generate.