Check_E0;
Address_Checks;
Check_Not_Incomplete_Type;
- Set_Etype (N, RTE (RE_Address));
+
+ -- If the prefix is a dereference of a value whose associated access
+ -- type has been specified with aspect Designated_Storage_Model, then
+ -- use the associated Storage_Model_Type's address type as the type
+ -- of the attribute. Otherwise we use System.Address as usual. This
+ -- isn't normally legit for a predefined attribute, but this is for
+ -- our own extension to addressing and currently requires extensions
+ -- to be enabled (such as with -gnatX0).
+
+ declare
+ Prefix_Obj : constant Node_Id := Get_Referenced_Object (P);
+ Addr_Type : Entity_Id := RTE (RE_Address);
+ begin
+ if Nkind (Prefix_Obj) = N_Explicit_Dereference then
+ declare
+ P_Type : constant Entity_Id := Etype (Prefix (Prefix_Obj));
+
+ use Storage_Model_Support;
+ begin
+ if Has_Designated_Storage_Model_Aspect (P_Type) then
+ Addr_Type := Storage_Model_Address_Type
+ (Storage_Model_Object (P_Type));
+ end if;
+ end;
+ end if;
+
+ Set_Etype (N, Addr_Type);
+ end;
------------------
-- Address_Size --