diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2019-12-12 10:02:55 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-12-12 10:02:55 +0000 |
commit | 955379e4ed77883365cd041840bb17245810c095 (patch) | |
tree | 7201b41fb940173e82ed415219cb5e03390d695b /gcc | |
parent | 16b5f07b5d210a7ae55576043855f50fa72f55db (diff) | |
download | gcc-955379e4ed77883365cd041840bb17245810c095.zip gcc-955379e4ed77883365cd041840bb17245810c095.tar.gz gcc-955379e4ed77883365cd041840bb17245810c095.tar.bz2 |
[Ada] Fix wrong value of 'Size for slices of bit-packed arrays (2)
2019-12-12 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* exp_attr.adb (Expand_Size_Attribute): Look directly at the
prefix to detect the bit-packed slices. Apply the checks last
in case the attribute needs to be processed by the back-end.
* exp_ch4.adb (Expand_N_Slice): Do not create a temporary for
a prefix of the Size attribute.
From-SVN: r279293
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/ada/exp_attr.adb | 9 | ||||
-rw-r--r-- | gcc/ada/exp_ch4.adb | 6 |
3 files changed, 16 insertions, 7 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index c2e4c36..cf79c7d 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,11 @@ +2019-12-12 Eric Botcazou <ebotcazou@adacore.com> + + * exp_attr.adb (Expand_Size_Attribute): Look directly at the + prefix to detect the bit-packed slices. Apply the checks last + in case the attribute needs to be processed by the back-end. + * exp_ch4.adb (Expand_N_Slice): Do not create a temporary for + a prefix of the Size attribute. + 2019-12-12 Steve Baird <baird@adacore.com> * sem_ch12.adb diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 1459cfc..c7b6451 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -7455,8 +7455,6 @@ package body Exp_Attr is -- All other cases are handled by the back end else - Apply_Universal_Integer_Attribute_Checks (N); - -- If Size is applied to a formal parameter that is of a packed -- array subtype, then apply Size to the actual subtype. @@ -7489,9 +7487,7 @@ package body Exp_Attr is -- System.Unsigned_Types.Packed_Byte for code generation purposes so -- the size is always rounded up in the back end. - elsif Nkind (Original_Node (Pref)) = N_Slice - and then Is_Bit_Packed_Array (Ptyp) - then + elsif Nkind (Pref) = N_Slice and then Is_Bit_Packed_Array (Ptyp) then Rewrite (N, Make_Op_Multiply (Loc, Make_Attribute_Reference (Loc, @@ -7503,6 +7499,9 @@ package body Exp_Attr is Analyze_And_Resolve (N, Typ); end if; + -- Apply the required checks last, after rewriting has taken place + + Apply_Universal_Integer_Attribute_Checks (N); return; end if; diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 158dcb5..20b3bab 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -11013,7 +11013,8 @@ package body Exp_Ch4 is -- 5. Prefix of an address attribute (this is an error which is caught -- elsewhere, and the expansion would interfere with generating the - -- error message). + -- error message) or of a size attribute (because 'Size may change + -- when applied to the temporary instead of the slice directly). if not Is_Packed (Typ) then @@ -11039,7 +11040,8 @@ package body Exp_Ch4 is return; elsif Nkind (Parent (N)) = N_Attribute_Reference - and then Attribute_Name (Parent (N)) = Name_Address + and then (Attribute_Name (Parent (N)) = Name_Address + or else Attribute_Name (Parent (N)) = Name_Size) then return; |