-- a procedure with an in-out parameter, and expanded as such.
procedure Expand_Formal_Container_Loop (N : Node_Id);
- -- Use the primitives specified in an Iterable aspect to expand a loop
- -- over a so-called formal container, primarily for SPARK usage.
+ -- Use the primitives specified in an Iterable aspect to expand a loop.
+ -- The Iterable aspect is used by the SPARK formal containers, and can
+ -- also be used by user code.
procedure Expand_Formal_Container_Element_Loop (N : Node_Id);
- -- Same, for an iterator of the form " For E of C". In this case the
+ -- Same, for an iterator of the form "for E of C". In this case the
-- iterator provides the name of the element, and the cursor is generated
-- internally.
Make_Handled_Sequence_Of_Statements (Loc,
Statements => New_List (New_Loop))));
- -- The loop parameter is declared by an object declaration, but within
- -- the loop we must prevent user assignments to it, so we analyze the
- -- declaration and reset the entity kind, before analyzing the rest of
- -- the loop.
+ -- The loop parameter is declared by an object declaration (Init_Decl),
+ -- but within the loop we must prevent user assignments to it, so we
+ -- analyze Init_Decl and reset the entity kind, before analyzing the
+ -- rest of the loop. First Preanalyze the block statement, to set its
+ -- Identifier, and then push that as the scope in which to analyze
+ -- Init_Decl.
+
+ Preanalyze (N);
+ Push_Scope (Entity (Identifier (N)));
Analyze (Init_Decl);
Init_Name := Defining_Identifier (Init_Decl);
Reinit_Field_To_Zero (Init_Name, F_SPARK_Pragma_Inherited);
Mutate_Ekind (Init_Name, E_Loop_Parameter);
+ Pop_Scope;
+
-- Wrap the block statements with the condition specified in the
-- iterator filter when one is present.
Set_Assignment_OK (Name (Advance));
Analyze (N);
-
- -- Because we have to analyze the initial declaration of the loop
- -- parameter multiple times its scope is incorrectly set at this point
- -- to the one surrounding the block statement - so set the scope
- -- manually to be the actual block statement, and indicate that it is
- -- not visible after the block has been analyzed.
-
- Set_Scope (Init_Name, Entity (Identifier (N)));
- Set_Is_Immediately_Visible (Init_Name, False);
end Expand_Formal_Container_Loop;
------------------------------------------
Obj_Ref : Node_Id;
Obj_Typ : Entity_Id;
- -- Start of processing for Process_Object_Declaration
-
begin
-- Handle the object type and the reference to the object. Note
-- that objects having simple protected components or of a CW type
Push_Scope (Scope (Obj_Id));
- -- Avoid generating duplicate names for master nodes
-
- if Ekind (Obj_Id) = E_Loop_Parameter
- and then
- Present (Current_Entity_In_Scope (Chars (Master_Node_Id)))
- then
- Set_Chars (Master_Node_Id,
- New_External_Name (Chars (Obj_Id),
- Suffix => "MN",
- Suffix_Index => -1));
- end if;
-
if not Has_Strict_Ctrl_Objs or else Count = 1 then
Prepend_To (Decls, Master_Node_Decl);
else
begin
-- No messages if warnings are suppressed, or if we have detected any
-- real errors so far (this last check avoids junk messages resulting
- -- from errors, e.g. a subunit that is not loaded).
+ -- from errors, e.g. a subunit that is not loaded). No messages if
+ -- we are in preanalysis (warnings will be detected properly later,
+ -- during analysis).
- if Warning_Mode = Suppress or else Serious_Errors_Detected /= 0 then
+ if Warning_Mode = Suppress
+ or else Serious_Errors_Detected /= 0
+ or else not Full_Analysis
+ then
return;
end if;