+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
-- 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.
-- 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,
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;
-- 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
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;