-- The following exception is raised by routine Prepare_Loop_Statement
-- to avoid further analysis of a transformed loop.
- Skip_Analysis : exception;
-
function Disable_Constant (N : Node_Id) return Traverse_Result;
-- If N represents an E_Variable entity, set Is_True_Constant To False
-- Helper for Analyze_Loop_Statement, to unset Is_True_Constant on
-- variables referenced within an OpenACC construct.
- procedure Prepare_Loop_Statement (Iter : Node_Id);
+ procedure Prepare_Loop_Statement
+ (Iter : Node_Id;
+ Stop_Processing : out Boolean);
-- Determine whether loop statement N with iteration scheme Iter must be
- -- transformed prior to analysis, and if so, perform it. The routine
- -- raises Skip_Analysis to prevent further analysis of the transformed
- -- loop.
+ -- transformed prior to analysis, and if so, perform it.
+ -- If Stop_Processing is set to True, should stop further processing.
----------------------
-- Disable_Constant --
-- Prepare_Loop_Statement --
----------------------------
- procedure Prepare_Loop_Statement (Iter : Node_Id) is
+ procedure Prepare_Loop_Statement
+ (Iter : Node_Id;
+ Stop_Processing : out Boolean)
+ is
function Has_Sec_Stack_Default_Iterator
(Cont_Typ : Entity_Id) return Boolean;
pragma Inline (Has_Sec_Stack_Default_Iterator);
-- Determine whether arbitrary statement Stmt is the sole statement
-- wrapped within some block, excluding pragmas.
- procedure Prepare_Iterator_Loop (Iter_Spec : Node_Id);
+ procedure Prepare_Iterator_Loop
+ (Iter_Spec : Node_Id;
+ Stop_Processing : out Boolean);
pragma Inline (Prepare_Iterator_Loop);
-- Prepare an iterator loop with iteration specification Iter_Spec
-- for transformation if needed.
+ -- If Stop_Processing is set to True, should stop further processing.
- procedure Prepare_Param_Spec_Loop (Param_Spec : Node_Id);
+ procedure Prepare_Param_Spec_Loop
+ (Param_Spec : Node_Id;
+ Stop_Processing : out Boolean);
pragma Inline (Prepare_Param_Spec_Loop);
-- Prepare a discrete loop with parameter specification Param_Spec
-- for transformation if needed.
+ -- If Stop_Processing is set to True, should stop further processing.
procedure Wrap_Loop_Statement (Manage_Sec_Stack : Boolean);
- pragma Inline (Wrap_Loop_Statement);
- pragma No_Return (Wrap_Loop_Statement);
+ pragma Inline (Wrap_Loop_Statement);
-- Wrap loop statement N within a block. Flag Manage_Sec_Stack must
-- be set when the block must mark and release the secondary stack.
+ -- Should stop further processing after calling this procedure.
------------------------------------
-- Has_Sec_Stack_Default_Iterator --
-- Prepare_Iterator_Loop --
---------------------------
- procedure Prepare_Iterator_Loop (Iter_Spec : Node_Id) is
+ procedure Prepare_Iterator_Loop
+ (Iter_Spec : Node_Id;
+ Stop_Processing : out Boolean)
+ is
Cont_Typ : Entity_Id;
Nam : Node_Id;
Nam_Copy : Node_Id;
begin
+ Stop_Processing := False;
+
-- The iterator specification has syntactic errors. Transform the
-- loop into an infinite loop in order to safely perform at least
-- some minor analysis. This check must come first.
if Error_Posted (Iter_Spec) then
Set_Iteration_Scheme (N, Empty);
Analyze (N);
-
- raise Skip_Analysis;
+ Stop_Processing := True;
-- Nothing to do when the loop is already wrapped in a block
(Cont_Typ, Name_First)
or else Is_Sec_Stack_Iteration_Primitive
(Cont_Typ, Name_Next));
+ Stop_Processing := True;
end if;
end if;
end Prepare_Iterator_Loop;
-- Prepare_Param_Spec_Loop --
-----------------------------
- procedure Prepare_Param_Spec_Loop (Param_Spec : Node_Id) is
+ procedure Prepare_Param_Spec_Loop
+ (Param_Spec : Node_Id;
+ Stop_Processing : out Boolean)
+ is
High : Node_Id;
Low : Node_Id;
Rng : Node_Id;
Rng_Typ : Entity_Id;
begin
+ Stop_Processing := False;
Rng := Discrete_Subtype_Definition (Param_Spec);
-- Nothing to do when the loop is already wrapped in a block
-- on the secondary stack. Note that the loop must be wrapped
-- only when such a call exists.
- if Has_Sec_Stack_Call (Low)
- or else
- Has_Sec_Stack_Call (High)
+ if Has_Sec_Stack_Call (Low) or else Has_Sec_Stack_Call (High)
then
Wrap_Loop_Statement (Manage_Sec_Stack => True);
+ Stop_Processing := True;
end if;
-- Otherwise the parameter specification appears in the form
and then Needs_Finalization (Rng_Typ))
then
Wrap_Loop_Statement (Manage_Sec_Stack => True);
+ Stop_Processing := True;
end if;
end if;
end Prepare_Param_Spec_Loop;
Rewrite (N, Blk);
Analyze (N);
-
- raise Skip_Analysis;
end Wrap_Loop_Statement;
-- Local variables
-- Start of processing for Prepare_Loop_Statement
begin
+ Stop_Processing := False;
+
if Present (Iter_Spec) then
- Prepare_Iterator_Loop (Iter_Spec);
+ Prepare_Iterator_Loop (Iter_Spec, Stop_Processing);
elsif Present (Param_Spec) then
- Prepare_Param_Spec_Loop (Param_Spec);
+ Prepare_Param_Spec_Loop (Param_Spec, Stop_Processing);
end if;
end Prepare_Loop_Statement;
-- wrapped within a block in order to manage the secondary stack.
if Present (Iter) then
- Prepare_Loop_Statement (Iter);
+ declare
+ Stop_Processing : Boolean;
+ begin
+ Prepare_Loop_Statement (Iter, Stop_Processing);
+
+ if Stop_Processing then
+ return;
+ end if;
+ end;
end if;
-- Kill current values on entry to loop, since statements in the body of
if Is_OpenAcc_Environment (Stmt) then
Disable_Constants (Stmt);
end if;
-
- exception
- when Skip_Analysis =>
- null;
end Analyze_Loop_Statement;
----------------------------