+2010-10-11 Arnaud Charlet <charlet@adacore.com>
+
+ * gnat_rm.texi, exp_attr.adb, sem_attr.adb, sem_attr.ads,
+ snames.ads-tmpl (Analyze_Attribute, Expand_N_Attribute_Reference): Add
+ handling of Attribute_Ref. Add missing blanks in some error messages.
+ (Attribute_Ref, Name_Ref): Declare.
+ Document 'Ref attribute.
+
2010-10-11 Robert Dewar <dewar@adacore.com>
* sem_attr.adb: Minor reformatting.
Rewrite_Stream_Proc_Call (Pname);
end Read;
+ ---------
+ -- Ref --
+ ---------
+
+ -- Ref is identical to To_Address, see To_Address for processing
+
---------------
-- Remainder --
---------------
-- To_Address --
----------------
- -- Transforms System'To_Address (X) into unchecked conversion
- -- from (integral) type of X to type address.
+ -- Transforms System'To_Address (X) and System.Address'Ref (X) into
+ -- unchecked conversion from (integral) type of X to type address.
- when Attribute_To_Address =>
+ when Attribute_To_Address | Attribute_Ref =>
Rewrite (N,
Unchecked_Convert_To (RTE (RE_Address),
Relocate_Node (First (Exprs))));
* Passed_By_Reference::
* Pool_Address::
* Range_Length::
+* Ref::
* Result::
* Safe_Emax::
* Safe_Large::
applied to the index subtype of a one dimensional array always gives the
same result as @code{Range} applied to the array itself.
+@node Ref
+@unnumberedsec Ref
+@findex Ref
+@noindent
+The @code{System.Address'Ref}
+(@code{System.Address} is the only permissible prefix)
+denotes a function identical to
+@code{System.Storage_Elements.To_Address} except that
+it is a static attribute. See @ref{To_Address} for more details.
+
@node Result
@unnumberedsec Result
@findex Result
Ekind (Entity (P)) /= E_Enumeration_Literal)
then
Error_Attr_P
- ("prefix of %attribute must be " &
+ ("prefix of % attribute must be " &
"discrete type/object or enum literal");
end if;
end if;
elsif UI_To_Int (Intval (E1)) > Number_Formals (Entity (P))
or else UI_To_Int (Intval (E1)) < 0
then
- Error_Attr ("invalid parameter number for %attribute", E1);
+ Error_Attr ("invalid parameter number for % attribute", E1);
end if;
end if;
Resolve (N, Standard_Void_Type);
Note_Possible_Modification (E2, Sure => True);
+ ---------
+ -- Ref --
+ ---------
+
+ when Attribute_Ref =>
+ Check_E1;
+ Analyze (P);
+
+ if Nkind (P) /= N_Expanded_Name
+ or else not Is_RTE (P_Type, RE_Address)
+ then
+ Error_Attr_P ("prefix of % attribute must be System.Address");
+ end if;
+
+ Analyze_And_Resolve (E1, Any_Integer);
+ Set_Etype (N, RTE (RE_Address));
+
---------------
-- Remainder --
---------------
if Nkind (P) /= N_Identifier
or else Chars (P) /= Name_System
then
- Error_Attr_P ("prefix of %attribute must be System");
+ Error_Attr_P ("prefix of % attribute must be System");
end if;
Generate_Reference (RTE (RE_Address), P);
Attribute_Position |
Attribute_Priority |
Attribute_Read |
+ Attribute_Ref |
Attribute_Result |
Attribute_Storage_Pool |
Attribute_Storage_Size |
-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- as Range applied to the array itself. The result is of type universal
-- integer.
+ ---------
+ -- Ref --
+ ---------
+
+ Attribute_Ref => True,
+ -- System.Address'Ref (Address is the only permissible prefix) is
+ -- equivalent to System'To_Address, provided for compatibility with
+ -- other compilers.
+
------------------
-- Storage_Unit --
------------------
----------------
Attribute_To_Address => True,
- -- System'To_Address (Address is the only permissible prefix) is a
+ -- System'To_Address (System is the only permissible prefix) is a
-- function that takes any integer value, and converts it into an
-- address value. The semantics is to first convert the integer value to
-- type Integer_Address according to normal conversion rules, and then
Name_Priority : constant Name_Id := N + $; -- Ada 05
Name_Range : constant Name_Id := N + $;
Name_Range_Length : constant Name_Id := N + $; -- GNAT
+ Name_Ref : constant Name_Id := N + $; -- GNAT
Name_Result : constant Name_Id := N + $; -- GNAT
Name_Round : constant Name_Id := N + $;
Name_Safe_Emax : constant Name_Id := N + $; -- Ada 83
Attribute_Priority,
Attribute_Range,
Attribute_Range_Length,
+ Attribute_Ref,
Attribute_Result,
Attribute_Round,
Attribute_Safe_Emax,