SCIL_Tag_Value,
SCIL_Target_Prim,
Scope,
+ Scope_Link,
Select_Alternatives,
Selector_Name,
Selector_Names,
Cc (N_Expression_With_Actions, N_Subexpr,
(Sy (Actions, List_Id, Default_No_List),
- Sy (Expression, Node_Id, Default_Empty)));
+ Sy (Expression, Node_Id, Default_Empty),
+ Sm (Scope_Link, Node_Id)));
Cc (N_External_Initializer, N_Subexpr,
(Sy (File_Index, Source_File_Index)));
Error_Msg_N ("object renaming or constant declaration expected", A);
end Check_Action_OK;
+ -- Local variables
+
A : Node_Id;
EWA_Scop : Entity_Id;
Set_Parent (EWA_Scop, N);
Push_Scope (EWA_Scop);
+ Set_Scope_Link (N, EWA_Scop);
+
-- If this Expression_With_Actions node comes from source, then it
-- represents a declare_expression; increment the counter to take note
-- of that.
Analyze_Expression (Expression (N));
Set_Etype (N, Etype (Expression (N)));
- End_Scope;
if Comes_From_Source (N) then
In_Declare_Expr := In_Declare_Expr - 1;
end if;
+
+ pragma Assert (Current_Scope = Scope_Link (N));
+ End_Scope;
end Analyze_Expression_With_Actions;
---------------------------
-- statements. On success, the return value is the entity of the loop
-- referenced by the statement.
- function Has_Sec_Stack_Call (N : Node_Id) return Boolean;
- -- N is the node for an arbitrary construct. This function searches the
- -- construct N to see if it contains a function call that returns on the
- -- secondary stack, returning True if any such call is found, and False
- -- otherwise.
-
- -- ??? The implementation invokes Sem_Util.Requires_Transient_Scope so it
- -- will return True if N contains a function call that needs finalization,
- -- in addition to the above specification. See Analyze_Loop_Statement for
- -- a similar comment about this entanglement.
-
procedure Preanalyze_Range (R_Copy : Node_Id);
-- Determine expected type of range or domain of iteration of Ada 2012
-- loop by analyzing separate copy. Do the analysis and resolution of the
-- checks to see if the statement is followed by some other statement, and
-- if so generates an appropriate warning for unreachable code.
+ function Has_Sec_Stack_Call (N : Node_Id) return Boolean;
+ -- N is the node for an arbitrary construct. This function searches the
+ -- construct N to see if it contains a function call that returns on the
+ -- secondary stack, returning True if any such call is found, and False
+ -- otherwise.
+
+ -- ??? The implementation invokes Sem_Util.Requires_Transient_Scope so it
+ -- will return True if N contains a function call that needs finalization,
+ -- in addition to the above specification. See Analyze_Loop_Statement for
+ -- a similar comment about this entanglement.
+
end Sem_Ch5;
-- Start of processing for Resolve_Declare_Expression
begin
+ -- Create a transient scope if the type of this declare-expression
+ -- or its expression requires it; this must be done before we push
+ -- in the scope stack the scope of this declare expression (in order
+ -- to properly remove it from the stack on exit from this routine).
+ -- Given that we don't know yet if secondary stack management will
+ -- be needed, we assume the worst case.
+
+ if not Preanalysis_Active
+ and then (Requires_Transient_Scope (Typ)
+ or else Has_Sec_Stack_Call (Expr))
+ then
+ Establish_Transient_Scope (N, Manage_Sec_Stack => True);
+ end if;
+
+ Push_Scope (Scope_Link (N));
+
Decl := First (Actions (N));
while Present (Decl) loop
Next_Elmt (Cursor);
end loop;
end;
+
+ pragma Assert (Current_Scope = Scope_Link (N));
+ End_Scope;
end Resolve_Declare_Expression;
-----------------------------------
-- scope all use this field to reference the corresponding scope entity.
-- See Einfo for further details.
+ -- Scope_Link
+ -- Present in N_Expression_With_Actions nodes. References the internally
+ -- built scope created to provide proper visibility of the declare_items
+ -- to the expander.
+
-- Selector_Name
-- Present in N_Expanded_Name N_Selected_Component,
-- N_Generic_Association, and N_Parameter_Association nodes.
-- N_Expression_With_Actions
-- Actions
-- Expression
+ -- Scope_Link
-- plus fields for expression
-- Note: In the final generated tree presented to the code generator,