@@ -1176,7 +1176,7 @@ package Aspects is
Class_Present : Boolean := False;
Or_Rep_Item : Boolean := False) return Node_Id;
-- Find the aspect specification of aspect A (or A'Class if Class_Present)
- -- associated with entity I.
+ -- associated with entity Id.
-- If found, then return the aspect specification.
-- If not found and Or_Rep_Item is true, then look for a representation
-- item (as opposed to an N_Aspect_Specification node) which specifies
@@ -664,12 +664,22 @@ package body Einfo.Utils is
function Base_Type (Id : E) return E is
begin
- if Is_Base_Type (Id) then
- return Id;
- else
- pragma Assert (Is_Type (Id));
- return Etype (Id);
- end if;
+ return Result : E do
+ if Is_Base_Type (Id) then
+ Result := Id;
+ else
+ pragma Assert (Is_Type (Id));
+ Result := Etype (Id);
+ if False then
+ pragma Assert (Is_Base_Type (Result));
+ -- ???It seems like Base_Type should return a base type,
+ -- but this assertion is disabled because it is not always
+ -- true. Hence the need to say "Base_Type (Base_Type (...))"
+ -- in some cases; Base_Type is not idempotent as one might
+ -- expect.
+ end if;
+ end if;
+ end return;
end Base_Type;
----------------------
@@ -2018,10 +2028,11 @@ package body Einfo.Utils is
----------------
function Next_Index (Id : N) return Node_Id is
- begin
pragma Assert (Nkind (Id) in N_Is_Index);
- pragma Assert (No (Next (Id)) or else Nkind (Next (Id)) in N_Is_Index);
- return Next (Id);
+ Result : constant Node_Id := Next (Id);
+ pragma Assert (No (Result) or else Nkind (Result) in N_Is_Index);
+ begin
+ return Result;
end Next_Index;
------------------
@@ -1334,7 +1334,7 @@ package Einfo is
-- First_Component (synthesized)
-- Applies to incomplete, private, protected, record and task types.
-- Returns the first component by following the chain of declared
+-- entities for the type until a component is found (one with an Ekind of
-- E_Component). The discriminants are skipped. If the record is null,
-- then Empty is returned.
@@ -1342,6 +1342,10 @@ package Einfo is
-- Similar to First_Component, but discriminants are not skipped, so will
-- find the first discriminant if discriminants are present.
+-- First_Discriminant (synthesized)
+-- Defined for types with discriminants or unknown discriminants.
+-- Returns the first in the Next_Discriminant chain; see Sem_Aux.
+
-- First_Entity
-- Defined in all entities that act as scopes to which a list of
-- associated entities is attached, and also in all [sub]types. Some
@@ -1375,12 +1379,11 @@ package Einfo is
-- First_Index
-- Defined in array types and subtypes. By introducing implicit subtypes
-- for the index constraints, we have the same structure for constrained
+-- and unconstrained arrays, subtype marks and discrete ranges are both
+-- represented by a subtype. This function returns the N_Is_Index tree
+-- node corresponding to the first index (not an entity). Subsequent
+-- indices are obtained using Next_Index. Note that this field is defined
+-- for the case of string literal subtypes, but is always Empty.
-- First_Literal
-- Defined in all enumeration types, including character and boolean
@@ -3749,13 +3752,11 @@ package Einfo is
-- all the extra formals (see description of Extra_Formal field)
-- Next_Index (synthesized)
+-- Applies to the N_Is_Index node returned by First_Index/Next_Index;
+-- returns the next N_Is_Index node in the chain. Empty is returned to
+-- indicate that there are no more indexes. Note that unlike most
+-- attributes in this package, Next_Index applies to nodes for the
+-- indexes, not to entities.
-- Next_Inlined_Subprogram
-- Defined in subprograms. Used to chain inlined subprograms used in
@@ -2939,8 +2939,8 @@ package body Exp_Ch6 is
-- If the aspect is inherited, convert the pointer to the
-- parent type that specifies the contract.
-- If the original access_to_subprogram has defaults for
- -- in_parameters, the call may include named associations, so
- -- we create one for the pointer as well.
+ -- in-mode parameters, the call may include named associations,
+ -- so we create one for the pointer as well.
if Is_Derived_Type (Ptr_Type)
and then Ptr_Type /= Etype (Last_Formal (Wrapper))
@@ -915,8 +915,7 @@ begin -- Gen_IL.Gen.Gen_Nodes
Cc (N_Generic_Package_Declaration, N_Generic_Declaration,
(Sy (Specification, Node_Id),
Sy (Generic_Formal_Declarations, List_Id),
- Sy (Aspect_Specifications, List_Id, Default_No_List),
- Sm (Activation_Chain_Entity, Node_Id)));
+ Sy (Aspect_Specifications, List_Id, Default_No_List)));
Cc (N_Generic_Subprogram_Declaration, N_Generic_Declaration,
(Sy (Specification, Node_Id),
@@ -1250,8 +1250,8 @@ package body Sem_Ch3 is
-- to incomplete types declared in some enclosing scope, not to limited
-- views from other packages.
- -- Prior to Ada 2012, access to functions parameters must be of mode
- -- 'in'.
+ -- Prior to Ada 2012, all parameters of an access-to-function type must
+ -- be of mode 'in'.
if Present (Formals) then
Formal := First_Formal (Desig_Type);
@@ -2304,6 +2304,10 @@ package Sinfo is
-- scope all use this field to reference the corresponding scope entity.
-- See Einfo for further details.
+ -- Selector_Name
+ -- Present in N_Expanded_Name N_Selected_Component,
+ -- N_Generic_Association, and N_Parameter_Association nodes.
+
-- Shift_Count_OK
-- A flag present in shift nodes to indicate that the shift count is
-- known to be in range, i.e. is in the range from zero to word length
@@ -7013,7 +7017,7 @@ package Sinfo is
-- GENERIC_FORMAL_PART SUBPROGRAM_SPECIFICATION
-- [ASPECT_SPECIFICATIONS];
- -- Note: Generic_Formal_Declarations can include pragmas
+ -- Note: Generic_Formal_Declarations can include pragmas and use clauses
-- N_Generic_Subprogram_Declaration
-- Sloc points to GENERIC
@@ -7030,11 +7034,7 @@ package Sinfo is
-- GENERIC_FORMAL_PART PACKAGE_SPECIFICATION
-- [ASPECT_SPECIFICATIONS];
- -- Note: when we do generics right, the Activation_Chain_Entity entry
- -- for this node can be removed (since the expander won't see generic
- -- units any more)???.
-
- -- Note: Generic_Formal_Declarations can include pragmas
+ -- Note: Generic_Formal_Declarations can include pragmas and use clauses
-- N_Generic_Package_Declaration
-- Sloc points to GENERIC
@@ -7042,7 +7042,6 @@ package Sinfo is
-- Corresponding_Body
-- Generic_Formal_Declarations from generic formal part
-- Parent_Spec
- -- Activation_Chain_Entity
-------------------------------
-- 12.1 Generic Formal Part --
@@ -7143,16 +7142,19 @@ package Sinfo is
-- Note: unlike the procedure call case, a generic association node
-- is generated for every association, even if no formal parameter
- -- selector name is present. In this case the parser will leave the
- -- Selector_Name field set to Empty, to be filled in later by the
- -- semantic pass.
+ -- selector name is present, in which case Selector_Name is Empty.
-- In Ada 2005, a formal may be associated with a box, if the
-- association is part of the list of actuals for a formal package.
- -- If the association is given by OTHERS => <>, the association is
+ -- If the association is given by OTHERS => <>, the association is
-- an N_Others_Choice (not an N_Generic_Association whose Selector_Name
-- is an N_Others_Choice).
+ -- In source nodes, either Explicit_Generic_Actual_Parameter is present,
+ -- or Box_Present is True. However, Sem_Ch12 generates "dummy" nodes
+ -- with Explicit_Generic_Actual_Parameter = Empty and Box_Present =
+ -- False.
+
-- N_Generic_Association
-- Sloc points to first token of generic association
-- Selector_Name (set to Empty if no formal
@@ -7382,13 +7384,15 @@ package Sinfo is
-- Default_Name (set to Empty if no subprogram default)
-- Box_Present
-- Expression (set to Empty if no expression present)
+ -- If the default is "is null", then Null_Present is set
+ -- on the Specification of this node.
-- Note: If no subprogram default is present, then Name is set
-- to Empty, and Box_Present is False.
- -- Note: The Expression field is only used for the GNAT extension
- -- that allows a FORMAL_CONCRETE_SUBPROGRAM_DECLARATION to specify
- -- an expression default for generic formal functions.
+ -- Note: The Expression field is for the GNAT extension that allows a
+ -- FORMAL_CONCRETE_SUBPROGRAM_DECLARATION to specify an expression
+ -- default for generic formal functions.
--------------------------------------------------
-- 12.6 Formal Abstract Subprogram Declaration --
From: Bob Duff <duff@adacore.com> The only substantive change is to remove Activation_Chain_Entity from N_Generic_Package_Declaration. The comment in sinfo.ads suggesting this change was written in 1993! Various pieces of missing documentation are added to Sinfo and Einfo. Also other minor cleanups. gcc/ada/ * gen_il-gen-gen_nodes.adb (N_Generic_Package_Declaration): Remove Activation_Chain_Entity. * sinfo.ads: Comment improvements. Add missing doc. Remove obsolete comment about Activation_Chain_Entity. * einfo.ads: Comment improvements. Add missing doc. * einfo-utils.adb (Base_Type): Add Assert (disabled for now). (Next_Index): Minor cleanup. * aspects.ads: Minor comment fix. * exp_ch6.adb: Likewise. * sem_ch3.adb: Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/aspects.ads | 2 +- gcc/ada/einfo-utils.adb | 29 ++++++++++++++++++++--------- gcc/ada/einfo.ads | 29 +++++++++++++++-------------- gcc/ada/exp_ch6.adb | 4 ++-- gcc/ada/gen_il-gen-gen_nodes.adb | 3 +-- gcc/ada/sem_ch3.adb | 4 ++-- gcc/ada/sinfo.ads | 32 ++++++++++++++++++-------------- 7 files changed, 59 insertions(+), 44 deletions(-)