From: Ghjuvan Lacambre Date: Mon, 6 Jul 2020 13:56:28 +0000 (+0200) Subject: [Ada] Do not replace bounds for packed arrays that depend on discriminants X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=08b0a5e2002f7f43d7f5aa3b55e7c6c22ec3926d;p=gcc.git [Ada] Do not replace bounds for packed arrays that depend on discriminants gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference): Check if type depends on discriminant. --- diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 827704bdb67..70f353fe3c3 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -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),