aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhjuvan Lacambre <lacambre@adacore.com>2020-07-06 15:56:28 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-19 05:53:38 -0400
commit08b0a5e2002f7f43d7f5aa3b55e7c6c22ec3926d (patch)
tree451d6a17b6b4903d8286200d3c9b1668218b8e45
parentec28faefe1fed756e3a4daee73533984d569b570 (diff)
downloadgcc-08b0a5e2002f7f43d7f5aa3b55e7c6c22ec3926d.zip
gcc-08b0a5e2002f7f43d7f5aa3b55e7c6c22ec3926d.tar.gz
gcc-08b0a5e2002f7f43d7f5aa3b55e7c6c22ec3926d.tar.bz2
[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.
-rw-r--r--gcc/ada/exp_attr.adb6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index 827704b..70f353f 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),