aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_util.ads
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2021-09-13 10:37:49 -0700
committerIan Lance Taylor <iant@golang.org>2021-09-13 10:37:49 -0700
commite252b51ccde010cbd2a146485d8045103cd99533 (patch)
treee060f101cdc32bf5e520de8e5275db9d4236b74c /gcc/ada/sem_util.ads
parentf10c7c4596dda99d2ee872c995ae4aeda65adbdf (diff)
parent104c05c5284b7822d770ee51a7d91946c7e56d50 (diff)
downloadgcc-e252b51ccde010cbd2a146485d8045103cd99533.zip
gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.gz
gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.bz2
Merge from trunk revision 104c05c5284b7822d770ee51a7d91946c7e56d50.
Diffstat (limited to 'gcc/ada/sem_util.ads')
-rw-r--r--gcc/ada/sem_util.ads311
1 files changed, 202 insertions, 109 deletions
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
index 6560180..b0d6a2a 100644
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2020, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2021, 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- --
@@ -25,16 +25,17 @@
-- Package containing utility procedures used throughout the semantics
-with Aspects; use Aspects;
-with Atree; use Atree;
-with Einfo; use Einfo;
-with Exp_Tss; use Exp_Tss;
-with Namet; use Namet;
-with Opt; use Opt;
-with Snames; use Snames;
-with Types; use Types;
-with Uintp; use Uintp;
-with Urealp; use Urealp;
+with Aspects; use Aspects;
+with Atree; use Atree;
+with Einfo; use Einfo;
+with Einfo.Entities; use Einfo.Entities;
+with Exp_Tss; use Exp_Tss;
+with Namet; use Namet;
+with Opt; use Opt;
+with Snames; use Snames;
+with Types; use Types;
+with Uintp; use Uintp;
+with Urealp; use Urealp;
package Sem_Util is
@@ -64,15 +65,19 @@ package Sem_Util is
function Accessibility_Level
(Expr : Node_Id;
Level : Accessibility_Level_Kind;
- In_Return_Context : Boolean := False) return Node_Id;
+ In_Return_Context : Boolean := False;
+ Allow_Alt_Model : Boolean := True) return Node_Id;
-- Centralized accessibility level calculation routine for finding the
-- accessibility level of a given expression Expr.
- -- In_Return_Context forcing the Accessibility_Level calculations to be
+ -- In_Return_Context forces the Accessibility_Level calculations to be
-- carried out "as if" Expr existed in a return value. This is useful for
-- calculating the accessibility levels for discriminant associations
-- and return aggregates.
+ -- The Allow_Alt_Model parameter allows the alternative level calculation
+ -- under the restriction No_Dynamic_Accessibility_Checks to be performed.
+
function Acquire_Warning_Match_String (Str_Lit : Node_Id) return String;
-- Used by pragma Warnings (Off, string), and Warn_As_Error (string) to get
-- the given string argument, adding leading and trailing asterisks if they
@@ -156,14 +161,14 @@ package Sem_Util is
-- part of the current package.
procedure Apply_Compile_Time_Constraint_Error
- (N : Node_Id;
- Msg : String;
- Reason : RT_Exception_Code;
- Ent : Entity_Id := Empty;
- Typ : Entity_Id := Empty;
- Loc : Source_Ptr := No_Location;
- Rep : Boolean := True;
- Warn : Boolean := False);
+ (N : Node_Id;
+ Msg : String;
+ Reason : RT_Exception_Code;
+ Ent : Entity_Id := Empty;
+ Typ : Entity_Id := Empty;
+ Loc : Source_Ptr := No_Location;
+ Warn : Boolean := False;
+ Emit_Message : Boolean := True);
-- N is a subexpression that will raise Constraint_Error when evaluated
-- at run time. Msg is a message that explains the reason for raising the
-- exception. The last character is ? if the message is always a warning,
@@ -171,21 +176,21 @@ package Sem_Util is
-- (because of violation of static expression rules) in Ada 95 (but not
-- in Ada 83). Typically this routine posts all messages at the Sloc of
-- node N. However, if Loc /= No_Location, Loc is the Sloc used to output
- -- the message. After posting the appropriate message, and if the flag
- -- Rep is set, this routine replaces the expression with an appropriate
- -- N_Raise_Constraint_Error node using the given Reason code. This node
- -- is then marked as being static if the original node is static, but
- -- sets the flag Raises_Constraint_Error, preventing further evaluation.
- -- The error message may contain a } or & insertion character. This
- -- normally references Etype (N), unless the Ent argument is given
- -- explicitly, in which case it is used instead. The type of the raise
- -- node that is built is normally Etype (N), but if the Typ parameter
- -- is present, this is used instead. Warn is normally False. If it is
- -- True then the message is treated as a warning even though it does
- -- not end with a ? (this is used when the caller wants to parameterize
- -- whether an error or warning is given), or when the message should be
- -- treated as a warning even when SPARK_Mode is On (which otherwise would
- -- force an error).
+ -- the message. After posting the appropriate message, this routine
+ -- replaces the expression with an appropriate N_Raise_Constraint_Error
+ -- node using the given Reason code. This node is then marked as being
+ -- static if the original node is static, but sets the flag
+ -- Raises_Constraint_Error, preventing further evaluation. The error
+ -- message may contain a } or & insertion character. This normally
+ -- references Etype (N), unless the Ent argument is given explicitly, in
+ -- which case it is used instead. The type of the raise node that is built
+ -- is normally Etype (N), but if the Typ parameter is present, this is used
+ -- instead. Warn is normally False. If it is True then the message is
+ -- treated as a warning even though it does not end with a ? (this is used
+ -- when the caller wants to parameterize whether an error or warning is
+ -- given), or when the message should be treated as a warning even when
+ -- SPARK_Mode is On (which otherwise would force an error).
+ -- If Emit_Message is False, then do not emit any message.
function Async_Readers_Enabled (Id : Entity_Id) return Boolean;
-- Id should be the entity of a state abstraction, an object, or a type.
@@ -381,7 +386,7 @@ package Sem_Util is
-- means that for sure CE cannot be raised.
procedure Check_Ambiguous_Aggregate (Call : Node_Id);
- -- Additional information on an ambiguous call in Ada_2020 when a
+ -- Additional information on an ambiguous call in Ada_2022 when a
-- subprogram call has an actual that is an aggregate, and the
-- presence of container aggregates (or types with the correwponding
-- aspect) provides an additional interpretation. Message indicates
@@ -583,6 +588,21 @@ package Sem_Util is
-- emitted immediately after the main message (and before output of any
-- message indicating that Constraint_Error will be raised).
+ procedure Compute_Returns_By_Ref (Func : Entity_Id);
+ -- Set the Returns_By_Ref flag on Func if appropriate
+
+ generic
+ with function Predicate (Typ : Entity_Id) return Boolean;
+ function Collect_Types_In_Hierarchy
+ (Typ : Entity_Id;
+ Examine_Components : Boolean := False) return Elist_Id;
+ -- Inspect the ancestor and progenitor types of Typ and Typ itself -
+ -- collecting those for which function Predicate is True. The resulting
+ -- list is ordered in a type-to-ultimate-ancestor fashion.
+
+ -- When Examine_Components is True, components types in the hierarchy also
+ -- get collected.
+
procedure Conditional_Delay (New_Ent, Old_Ent : Entity_Id);
-- Sets the Has_Delayed_Freeze flag of New_Ent if the Delayed_Freeze flag
-- of Old_Ent is set and Old_Ent has not yet been Frozen (i.e. Is_Frozen is
@@ -642,7 +662,16 @@ package Sem_Util is
-- Current_Scope is returned. The returned value is Empty if this is called
-- from a library package which is not within any subprogram.
- function Deepest_Type_Access_Level (Typ : Entity_Id) return Uint;
+ function CW_Or_Has_Controlled_Part (T : Entity_Id) return Boolean;
+ -- True if T is a class-wide type, or if it has controlled parts ("part"
+ -- means T or any of its subcomponents). Same as Needs_Finalization, except
+ -- when pragma Restrictions (No_Finalization) applies, in which case we
+ -- know that class-wide objects do not contain controlled parts.
+
+ function Deepest_Type_Access_Level
+ (Typ : Entity_Id;
+ Allow_Alt_Model : Boolean := True) return Uint;
+
-- Same as Type_Access_Level, except that if the type is the type of an Ada
-- 2012 stand-alone object of an anonymous access type, then return the
-- static accessibility level of the object. In that case, the dynamic
@@ -652,9 +681,10 @@ package Sem_Util is
-- in the case of a descendant of a generic formal type (returns Int'Last
-- instead of 0).
- function Defining_Entity
- (N : Node_Id;
- Empty_On_Errors : Boolean := False) return Entity_Id;
+ -- The Allow_Alt_Model parameter allows the alternative level calculation
+ -- under the restriction No_Dynamic_Accessibility_Checks to be performed.
+
+ 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
-- specification. If the declaration has a defining unit name, then the
@@ -665,19 +695,13 @@ package Sem_Util is
-- local entities declared during loop expansion. These entities need
-- debugging information, generated through Qualify_Entity_Names, and
-- the loop declaration must be placed in the table Name_Qualify_Units.
- --
- -- Set flag Empty_On_Errors to change the behavior of this routine as
- -- follows:
- --
- -- * True - A declaration that lacks a defining entity returns Empty.
- -- A node that does not allow for a defining entity returns Empty.
- --
- -- * False - A declaration that lacks a defining entity is given a new
- -- internally generated entity which is subsequently returned. A node
- -- that does not allow for a defining entity raises Program_Error
-- WARNING: There is a matching C declaration of this subprogram in fe.h
+ function Defining_Entity_Or_Empty (N : Node_Id) return Entity_Id;
+ -- This is equivalent to Defining_Entity but it returns Empty for nodes
+ -- without an entity instead of raising Program_Error.
+
function Denotes_Discriminant
(N : Node_Id;
Check_Concurrent : Boolean := False) return Boolean;
@@ -897,12 +921,11 @@ package Sem_Util is
(N : Node_Id;
Ent : 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 N is not an address representation
- -- clause, or if it is not possible to determine that the address is of
- -- this form, then set Ent to Empty.
+ -- 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.
function Find_Parameter_Type (Param : Node_Id) return Entity_Id;
-- Return the type of formal parameter Param as determined by its
@@ -1076,7 +1099,8 @@ package Sem_Util is
-- to its tail.
--
-- Report_Errors is set to True if the values of the discriminants are
- -- non-static.
+ -- insufficiently static (see body for details of what that means).
+
--
-- Allow_Compile_Time if set to True, allows compile time known values in
-- Governed_By expressions in addition to static expressions.
@@ -1164,6 +1188,26 @@ package Sem_Util is
-- the index type turns out to be a partial view; this case should not
-- arise during normal compilation of semantically correct programs.
+ type Range_Nodes is record
+ First, Last : Node_Id; -- First and Last nodes of a discrete_range
+ end record;
+
+ type Range_Values is record
+ First, Last : Uint; -- First and Last values of a discrete_range
+ end record;
+
+ function Get_Index_Bounds
+ (N : Node_Id;
+ Use_Full_View : Boolean := False) return Range_Nodes;
+ -- Same as the above procedure, but returns the result as a record.
+ -- ???This should probably replace the procedure.
+
+ function Get_Index_Bounds
+ (N : Node_Id;
+ Use_Full_View : Boolean := False) return Range_Values;
+ -- Same as the above function, but returns the values, which must be known
+ -- at compile time.
+
procedure Get_Interfacing_Aspects
(Iface_Asp : Node_Id;
Conv_Asp : out Node_Id;
@@ -1305,18 +1349,18 @@ package Sem_Util is
function Get_Fullest_View
(E : Entity_Id; Include_PAT : Boolean := True) return Entity_Id;
- -- Get the fullest possible view of E, looking through private,
- -- limited, packed array and other implementation types. If Include_PAT
- -- is False, don't look inside packed array types.
+ -- Get the fullest possible view of E, looking through private, limited,
+ -- packed array and other implementation types. If Include_PAT is False,
+ -- don't look inside packed array types.
function Has_Access_Values (T : Entity_Id) return Boolean;
- -- Returns true if type or subtype T is an access type, or has a component
- -- (at any recursive level) that is an access type. This is a conservative
- -- predicate, if it is not known whether or not T contains access values
- -- (happens for generic formals in some cases), then False is returned.
- -- Note that tagged types return False. Even though the tag is implemented
- -- as an access type internally, this function tests only for access types
- -- known to the programmer. See also Has_Tagged_Component.
+ -- Returns true if the underlying type of T is an access type, or has a
+ -- component (at any recursive level) that is an access type. This is a
+ -- conservative predicate, if it is not known whether or not T contains
+ -- access values (happens for generic formals in some cases), then False is
+ -- returned. Note that tagged types return False. Even though the tag is
+ -- implemented as an access type internally, this function tests only for
+ -- access types known to the programmer. See also Has_Tagged_Component.
function Has_Anonymous_Access_Discriminant (Typ : Entity_Id) return Boolean;
-- Returns True if Typ has one or more anonymous access discriminants
@@ -1390,6 +1434,17 @@ package Sem_Util is
-- Determine whether type Typ has a suitable Default_Initial_Condition
-- pragma which provides the full default initialization of the type.
+ function Has_Inferable_Discriminants (N : Node_Id) return Boolean;
+ -- Ada 2005 (AI-216): A view of an Unchecked_Union object has inferable
+ -- discriminants if it has a constrained nominal type, unless the object
+ -- is a component of an enclosing Unchecked_Union object that is subject
+ -- to a per-object constraint and the enclosing object lacks inferable
+ -- discriminants.
+ --
+ -- An expression of an Unchecked_Union type has inferable discriminants
+ -- if it is either a name of an object with inferable discriminants or a
+ -- qualified expression whose subtype mark denotes a constrained subtype.
+
function Has_Infinities (E : Entity_Id) return Boolean;
-- Determines if the range of the floating-point type E includes
-- infinities. Returns False if E is not a floating-point type.
@@ -1463,6 +1518,12 @@ package Sem_Util is
-- integer for use in compile-time checking. Note: Level is restricted to
-- be non-dynamic.
+ function Is_Prim_Of_Abst_Type_With_Nonstatic_CW_Pre_Post
+ (Subp : Entity_Id) return Boolean;
+ -- Return True if Subp is a primitive of an abstract type, where the
+ -- primitive has a class-wide pre- or postcondition whose expression
+ -- is nonstatic.
+
function Has_Overriding_Initialize (T : Entity_Id) return Boolean;
-- Predicate to determine whether a controlled type has a user-defined
-- Initialize primitive (and, in Ada 2012, whether that primitive is
@@ -1581,9 +1642,11 @@ package Sem_Util is
function In_Pragma_Expression (N : Node_Id; Nam : Name_Id) return Boolean;
-- Returns true if the expression N occurs within a pragma with name Nam
- function In_Pre_Post_Condition (N : Node_Id) return Boolean;
+ function In_Pre_Post_Condition
+ (N : Node_Id; Class_Wide_Only : Boolean := False) return Boolean;
-- Returns True if node N appears within a pre/postcondition pragma. Note
- -- the pragma Check equivalents are NOT considered.
+ -- the pragma Check equivalents are NOT considered. If Class_Wide_Only is
+ -- True, then tests for N appearing within a class-wide pre/postcondition.
function In_Quantified_Expression (N : Node_Id) return Boolean;
-- Returns true if the expression N occurs within a quantified expression
@@ -1712,7 +1775,7 @@ package Sem_Util is
-- subprogram call.
function Is_Actual_Parameter (N : Node_Id) return Boolean;
- -- Determines if N is an actual parameter in a subprogram call
+ -- Determines if N is an actual parameter in a subprogram or entry call
function Is_Actual_Tagged_Parameter (N : Node_Id) return Boolean;
-- Determines if N is an actual parameter of a formal of tagged type in a
@@ -1987,7 +2050,7 @@ package Sem_Util is
function Is_Full_Access_Object (N : Node_Id) return Boolean;
-- Determine whether arbitrary node N denotes a reference to a full access
- -- object as per Ada 2020 RM C.6(8.2).
+ -- object as per Ada 2022 RM C.6(8.2).
function Is_Fully_Initialized_Type (Typ : Entity_Id) return Boolean;
-- Typ is a type entity. This function returns true if this type is fully
@@ -2060,9 +2123,8 @@ package Sem_Util is
-- limited view must be treated in the same way.
function Is_Local_Variable_Reference (Expr : Node_Id) return Boolean;
- -- Determines whether Expr is a reference to a variable or IN OUT mode
- -- parameter of the current enclosing subprogram.
- -- Why are OUT parameters not considered here ???
+ -- Determines whether Expr is a reference to a variable or formal parameter
+ -- of mode OUT or IN OUT of the current enclosing subprogram.
function Is_Master (N : Node_Id) return Boolean;
-- Determine if the given node N constitutes a finalization master
@@ -2083,9 +2145,28 @@ package Sem_Util is
-- assertion expression of pragma Default_Initial_Condition and if it does,
-- the encapsulated expression is nontrivial.
- function Is_Null_Record_Type (T : Entity_Id) return Boolean;
- -- Determine whether T is declared with a null record definition or a
- -- null component list.
+ function Is_Null_Extension
+ (T : Entity_Id; Ignore_Privacy : Boolean := False) return Boolean;
+ -- Given a tagged type, returns True if argument is a type extension
+ -- that introduces no new components (discriminant or nondiscriminant).
+ -- Ignore_Privacy should be True for use in implementing dynamic semantics.
+
+ function Is_Null_Extension_Of
+ (Descendant, Ancestor : Entity_Id) return Boolean;
+ -- Given two tagged types, the first a descendant of the second,
+ -- returns True if every component of Descendant is inherited
+ -- (directly or indirectly) from Ancestor. Privacy is ignored.
+
+ function Is_Null_Record_Definition (Record_Def : Node_Id) return Boolean;
+ -- Returns True for an N_Record_Definition node that has no user-defined
+ -- components (and no variant part).
+
+ function Is_Null_Record_Type
+ (T : Entity_Id; Ignore_Privacy : Boolean := False) return Boolean;
+ -- Determine whether T is declared with a null record definition, a
+ -- null component list, or as a type derived from a null record type
+ -- (with a null extension if tagged). Returns True for interface types,
+ -- False for discriminated types.
function Is_Object_Image (Prefix : Node_Id) return Boolean;
-- Returns True if an 'Img, 'Image, 'Wide_Image, or 'Wide_Wide_Image
@@ -2103,11 +2184,16 @@ package Sem_Util is
-- conversions and hence variables.
function Is_OK_Volatile_Context
- (Context : Node_Id;
- Obj_Ref : Node_Id) return Boolean;
+ (Context : Node_Id;
+ Obj_Ref : Node_Id;
+ Check_Actuals : Boolean) return Boolean;
-- Determine whether node Context denotes a "non-interfering context" (as
-- defined in SPARK RM 7.1.3(10)) where volatile reference Obj_Ref can
- -- safely reside.
+ -- safely reside. When examining references that might be located within
+ -- actual parameters of a subprogram call that has not been resolved yet,
+ -- Check_Actuals should be False; such references will be assumed to be
+ -- legal. They will need to be checked again after subprogram call has
+ -- been resolved.
function Is_Package_Contract_Annotation (Item : Node_Id) return Boolean;
-- Determine whether aspect specification or pragma Item is one of the
@@ -2375,7 +2461,7 @@ package Sem_Util is
-- Initialize/Adjust/Finalize subprogram does not override the inherited
-- one.
- function Is_Volatile_Full_Access_Object (N : Node_Id) return Boolean;
+ function Is_Volatile_Full_Access_Object_Ref (N : Node_Id) return Boolean;
-- Determine whether arbitrary node N denotes a reference to an object
-- which is Volatile_Full_Access.
@@ -2384,7 +2470,7 @@ package Sem_Util is
-- pragma Volatile_Function. Protected functions are treated as volatile
-- (SPARK RM 7.1.2).
- function Is_Volatile_Object (N : Node_Id) return Boolean;
+ function Is_Volatile_Object_Ref (N : Node_Id) return Boolean;
-- Determine whether arbitrary node N denotes a reference to a volatile
-- object as per RM C.6(8). Note that the test here is for something that
-- is actually declared as volatile, not for an object that gets treated
@@ -2517,8 +2603,7 @@ package Sem_Util is
-- entity E. If no such instance exits, return Empty.
function Needs_Finalization (Typ : Entity_Id) return Boolean;
- -- Determine whether type Typ is controlled and thus requires finalization
- -- actions.
+ -- True if Typ requires finalization actions
function Needs_One_Actual (E : Entity_Id) return Boolean;
-- Returns True if a function has defaults for all but its first formal,
@@ -2826,9 +2911,9 @@ package Sem_Util is
procedure Propagate_Concurrent_Flags
(Typ : Entity_Id;
Comp_Typ : Entity_Id);
- -- Set Has_Task, Has_Protected and Has_Timing_Event on Typ when the flags
- -- are set on Comp_Typ. This follows the definition of these flags which
- -- are set (recursively) on any composite type which has a component marked
+ -- Set Has_Task, Has_Protected, and Has_Timing_Event on Typ when the flags
+ -- are set on Comp_Typ. This follows the definition of these flags, which
+ -- are set (recursively) on any composite type that has a component marked
-- by one of these flags. This procedure can only set flags for Typ, and
-- never clear them. Comp_Typ is the type of a component or a parent.
@@ -2841,14 +2926,14 @@ package Sem_Util is
procedure Propagate_Invariant_Attributes
(Typ : Entity_Id;
From_Typ : Entity_Id);
- -- Inherit all invariant-related attributes form type From_Typ. Typ is the
+ -- Inherit all invariant-related attributes from type From_Typ. Typ is the
-- destination type.
procedure Propagate_Predicate_Attributes
(Typ : Entity_Id;
From_Typ : Entity_Id);
- -- Inherit some predicate-related attributes form type From_Typ. Typ is the
- -- destination type. Probably to be completed with more attributes???
+ -- Inherit predicate functions and Has_Predicates flag from type From_Typ.
+ -- Typ is the destination type.
procedure Record_Possible_Part_Of_Reference
(Var_Id : Entity_Id;
@@ -2941,9 +3026,9 @@ package Sem_Util is
-- the value is valid) for the given entity Ent. This value can only be
-- captured if sequential execution semantics can be properly guaranteed so
-- that a subsequent reference will indeed be sure that this current value
- -- indication is correct. The node N is the construct which resulted in
- -- the possible capture of the value (this is used to check if we are in
- -- a conditional).
+ -- indication is correct. The node N is the construct that resulted in the
+ -- possible capture of the value (this is used to check if we are in a
+ -- conditional).
--
-- Cond is used to skip the test for being inside a conditional. It is used
-- in the case of capturing values from if/while tests, which already do a
@@ -3005,13 +3090,6 @@ package Sem_Util is
-- the same scope. Note that scopes are partially ordered, so Scope_Within
-- (A, B) and Scope_Within (B, A) may both return False.
- procedure Set_Convention (E : Entity_Id; Val : Convention_Id);
- -- Same as Basic_Set_Convention, but with an extra check for access types.
- -- In particular, if E is an access-to-subprogram type, and Val is a
- -- foreign convention, then we set Can_Use_Internal_Rep to False on E.
- -- Also, if the Etype of E is set and is an anonymous access type with
- -- no convention set, this anonymous type inherits the convention of E.
-
procedure Set_Current_Entity (E : Entity_Id);
pragma Inline (Set_Current_Entity);
-- Establish the entity E as the currently visible definition of its
@@ -3187,9 +3265,19 @@ package Sem_Util is
-- returned, i.e. Traverse_More_Func is called and the result is simply
-- discarded.
- function Type_Access_Level (Typ : Entity_Id) return Uint;
+ function Type_Access_Level
+ (Typ : Entity_Id;
+ Allow_Alt_Model : Boolean := True;
+ Assoc_Ent : Entity_Id := Empty) return Uint;
-- Return the accessibility level of Typ
+ -- The Allow_Alt_Model parameter allows the alternative level calculation
+ -- under the restriction No_Dynamic_Accessibility_Checks to be performed.
+
+ -- Assoc_Ent allows for the optional specification of the entity associated
+ -- with Typ. This gets utilized mostly for anonymous access type
+ -- processing, where context matters in interpreting Typ's level.
+
function Type_Without_Stream_Operation
(T : Entity_Id;
Op : TSS_Name_Type := TSS_Null) return Entity_Id;
@@ -3201,6 +3289,15 @@ package Sem_Util is
-- prevents the construction of a composite stream operation. If Op is
-- specified we check only for the given stream operation.
+ function Ultimate_Overlaid_Entity (E : Entity_Id) return Entity_Id;
+ -- If entity E is overlaying some other entity via an Address clause (which
+ -- possibly overlays yet another entity via its own Address clause), then
+ -- return the ultimate overlaid entity. If entity E is not overlaying any
+ -- other entity (or the overlaid entity cannot be determined statically),
+ -- then return Empty.
+ --
+ -- Subsidiary to the analysis of object overlays in SPARK.
+
function Ultimate_Prefix (N : Node_Id) return Node_Id;
-- Obtain the "outermost" prefix of arbitrary node N. Return N if no such
-- prefix exists.
@@ -3258,7 +3355,7 @@ package Sem_Util is
function Validated_View (Typ : Entity_Id) return Entity_Id;
-- Obtain the "validated view" of arbitrary type Typ which is suitable for
- -- verification by attributes 'Valid_Scalars. This view is the type itself
+ -- verification by attribute 'Valid_Scalars. This view is the type itself
-- or its full view while stripping away concurrency, derivations, and
-- privacy.
@@ -3278,10 +3375,6 @@ package Sem_Util is
function Within_Scope (E : Entity_Id; S : Entity_Id) return Boolean;
-- Returns True if entity E is declared within scope S
- function Within_Subprogram_Call (N : Node_Id) return Boolean;
- -- Determine whether arbitrary node N appears in an entry, function, or
- -- procedure call.
-
procedure Wrong_Type (Expr : Node_Id; Expected_Type : Entity_Id);
-- Output error message for incorrectly typed expression. Expr is the node
-- for the incorrectly typed construct (Etype (Expr) is the type found),
@@ -3341,7 +3434,7 @@ package Sem_Util is
-- Returns True iff every value belonging to some interval of
-- Subset also belongs to some interval of Of_Set.
- -- TBD: When we get around to implementing "is statically compatible"
+ -- When we get around to implementing "is statically compatible"
-- correctly for real types with static predicates, we may need
-- an analogous Real_Interval_List type. Most of the language
-- rules that reference "is statically compatible" pertain to
@@ -3366,7 +3459,7 @@ package Sem_Util is
-- (typically a 'Old attribute reference), returns True if
-- - the expression is conditionally evaluated; and
-- - its determining expressions are all known on entry; and
- -- - Ada_Version >= Ada_2020.
+ -- - Ada_Version >= Ada_2022.
-- See RM 6.1.1 for definitions of these terms.
--
-- Also returns True if Expr is of an anonymous access type;