diff options
Diffstat (limited to 'gcc/ada/sem_util.ads')
-rw-r--r-- | gcc/ada/sem_util.ads | 93 |
1 files changed, 58 insertions, 35 deletions
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index fd749c4..e9c1263 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -54,12 +54,12 @@ package Sem_Util is -- Add A to the list of access types to process when expanding the -- freeze node of E. - procedure Add_Global_Declaration (N : Node_Id); - -- These procedures adds a declaration N at the library level, to be + procedure Add_Global_Declaration (Decl : Node_Id); + -- This procedure adds a declaration Decl at the library level, to be -- elaborated before any other code in the unit. It is used for example -- for the entity that marks whether a unit has been elaborated. The -- declaration is added to the Declarations list of the Aux_Decls_Node - -- for the current unit. The declarations are added in the current scope, + -- for the current unit. The declared entity is added to current scope, -- so the caller should push a new scope as required before the call. function Add_Suffix (E : Entity_Id; Suffix : Character) return Name_Id; @@ -619,7 +619,21 @@ package Sem_Util is -- Find whether there is a previous definition for name or identifier N in -- the current scope. Because declarations for a scope are not necessarily -- contiguous (e.g. for packages) the first entry on the visibility chain - -- for N is not necessarily in the current scope. + -- for N is not necessarily in the current scope. Take, for example: + -- + -- package P is + -- X : constant := 13; + -- + -- package Q is + -- X : constant := 67; + -- end Q; + -- + -- Y : constant := X; + -- end P; + -- + -- When the declaration of Y is analyzed, the first entry on the visibility + -- chain is the X equal to 67, but Current_Entity_In_Scope returns the X + -- equal to 13. function Current_Scope return Entity_Id; -- Get entity representing current scope @@ -647,6 +661,10 @@ package Sem_Util is -- as Needs_Finalization except with pragma Restrictions (No_Finalization), -- in which case we know that class-wide objects do not need finalization. + function Default_Constructor (Typ : Entity_Id) return Entity_Id; + -- Determine the default constructor (e.g. the constructor with only one + -- formal parameter) for a given type Typ. + function Defining_Entity (N : Node_Id) return Entity_Id; -- Given a declaration N, returns the associated defining entity. If the -- declaration has a specification, the entity is obtained from the @@ -880,14 +898,18 @@ package Sem_Util is -- loop are nested within the block. procedure Find_Overlaid_Entity - (N : Node_Id; - Ent : out Entity_Id; - Off : out Boolean); + (N : Node_Id; + Ent : out Entity_Id; + Ovrl_Typ : out Entity_Id; + Off : out Boolean); -- The node N should be an address representation clause. Determines if the -- target expression is the address of an entity with an optional offset. -- If so, set Ent to the entity and, if there is an offset, set Off to -- True, otherwise to False. If it is not possible to determine that the -- address is of this form, then set Ent to Empty. + -- Ovrl_Typ is set to the type being overlaid and can be different than the + -- type of Ent, for example when the address clause is applied to a record + -- component or to an element of an array. function Find_Parameter_Type (Param : Node_Id) return Entity_Id; -- Return the type of formal parameter Param as determined by its @@ -1117,15 +1139,27 @@ package Sem_Util is -- identifier provided as the external name. Letters in the name are -- according to the setting of Opt.External_Name_Default_Casing. + function Get_Enclosing_Ghost_Entity (N : Node_Id) return Entity_Id; + -- If expression N references a name of either an object or of a + -- subprogram, then return its outermost entity that determines + -- whether this name denotes a ghost object. + function Get_Enclosing_Object (N : Node_Id) return Entity_Id; -- If expression N references a part of an object, return this object. -- Otherwise return Empty. Expression N should have been resolved already. - function Get_Enclosing_Deep_Object (N : Node_Id) return Entity_Id; - -- If expression N references a reachable part of an object (as defined in - -- SPARK RM 6.9), return this object. Otherwise return Empty. It is similar - -- to Get_Enclosing_Object, but treats pointer dereference like component - -- selection. Expression N should have been resolved already. + function Get_Enum_Lit_From_Pos + (T : Entity_Id; + Pos : Uint; + Loc : Source_Ptr) return Node_Id; + -- This function returns an identifier denoting the E_Enumeration_Literal + -- entity for the specified value from the enumeration type or subtype T. + -- The second argument is the Pos value. Constraint_Error is raised if + -- argument Pos is not in range. The third argument supplies a source + -- location for constructed nodes returned by this function. If No_Location + -- is supplied as source location, the location of the returned node is + -- copied from the original source location for the enumeration literal, + -- when available. function Get_Generic_Entity (N : Node_Id) return Entity_Id; -- Returns the true generic entity in an instantiation. If the name in the @@ -1192,19 +1226,6 @@ package Sem_Util is -- When flag Do_Checks is set, this routine will flag duplicate uses of -- aspects. - function Get_Enum_Lit_From_Pos - (T : Entity_Id; - Pos : Uint; - Loc : Source_Ptr) return Node_Id; - -- This function returns an identifier denoting the E_Enumeration_Literal - -- entity for the specified value from the enumeration type or subtype T. - -- The second argument is the Pos value. Constraint_Error is raised if - -- argument Pos is not in range. The third argument supplies a source - -- location for constructed nodes returned by this function. If No_Location - -- is supplied as source location, the location of the returned node is - -- copied from the original source location for the enumeration literal, - -- when available. - function Get_Iterable_Type_Primitive (Typ : Entity_Id; Nam : Name_Id) return Entity_Id; @@ -2095,6 +2116,10 @@ package Sem_Util is -- Determine whether arbitrary declaration Decl denotes a generic package, -- a generic subprogram or a generic body. + function Is_In_Context_Clause (N : Node_Id) return Boolean; + -- Returns True if N appears within the context clause of a unit, and False + -- for any other placement. + function Is_Independent_Object (N : Node_Id) return Boolean; -- Determine whether arbitrary node N denotes a reference to an independent -- object as per RM C.6(8). @@ -2377,6 +2402,7 @@ package Sem_Util is -- Pre -- Pre_Class -- Precondition + -- Program_Exit -- Refined_Depends -- Refined_Global -- Refined_Post @@ -2417,15 +2443,15 @@ package Sem_Util is -- Determine whether an arbitrary entity denotes an instance of function -- Ada.Unchecked_Conversion. - function Is_Universal_Numeric_Type (T : Entity_Id) return Boolean; - pragma Inline (Is_Universal_Numeric_Type); - -- True if T is Universal_Integer or Universal_Real - function Is_Unconstrained_Or_Tagged_Item (Item : Entity_Id) return Boolean; -- Subsidiary to Collect_Subprogram_Inputs_Outputs and the analysis of -- pragma Depends. Determine whether the type of dependency item Item is -- tagged, unconstrained array or unconstrained record. + function Is_Universal_Numeric_Type (T : Entity_Id) return Boolean; + pragma Inline (Is_Universal_Numeric_Type); + -- True if T is Universal_Integer or Universal_Real + function Is_User_Defined_Equality (Id : Entity_Id) return Boolean; -- Determine whether an entity denotes a user-defined equality @@ -2536,12 +2562,6 @@ package Sem_Util is -- if the entity Ent is not for an object. Last_Assignment_Only has the -- same meaning as for the call with no Ent. - procedure Kill_Size_Check_Code (E : Entity_Id); - -- Called when an address clause or pragma Import is applied to an entity. - -- If the entity is a variable or a constant, and size check code is - -- present, this size check code is killed, since the object will not be - -- allocated by the program. - function Known_Non_Null (N : Node_Id) return Boolean; -- Given a node N for a subexpression of an access type, determines if -- this subexpression yields a value that is known at compile time to @@ -2862,6 +2882,9 @@ package Sem_Util is -- WARNING: this routine should be used in debugging scenarios such as -- tracking down undefined symbols as it is fairly low level. + function Parameter_Count (Subp : Entity_Id) return Nat; + -- Return the number of parameters for a given subprogram Subp. + function Param_Entity (N : Node_Id) return Entity_Id; -- Given an expression N, determines if the expression is a reference -- to a formal (of a subprogram or entry), and if so returns the Id |