-- Generate:
-- <Comp_Typ>Invariant (_object (<Indices>));
- -- Note that the invariant procedure may have a null body if
- -- assertions are disabled or Assertion_Policy Ignore is in
- -- effect.
+ -- The invariant procedure has a null body if assertions are
+ -- disabled or Assertion_Policy Ignore is in effect.
if not Has_Null_Body (Proc_Id) then
Append_New_To (Comp_Checks,
function Make_Invariant_Call (Expr : Node_Id) return Node_Id is
Loc : constant Source_Ptr := Sloc (Expr);
Typ : constant Entity_Id := Base_Type (Etype (Expr));
-
- Proc_Id : Entity_Id;
-
- begin
pragma Assert (Has_Invariants (Typ));
-
- Proc_Id := Invariant_Procedure (Typ);
+ Proc_Id : constant Entity_Id := Invariant_Procedure (Typ);
pragma Assert (Present (Proc_Id));
+ begin
+ -- The invariant procedure has a null body if assertions are disabled or
+ -- Assertion_Policy Ignore is in effect. In that case, generate a null
+ -- statement instead of a call to the invariant procedure.
- return
- Make_Procedure_Call_Statement (Loc,
- Name => New_Occurrence_Of (Proc_Id, Loc),
- Parameter_Associations => New_List (Relocate_Node (Expr)));
+ if Has_Null_Body (Proc_Id) then
+ return Make_Null_Statement (Loc);
+ else
+ return
+ Make_Procedure_Call_Statement (Loc,
+ Name => New_Occurrence_Of (Proc_Id, Loc),
+ Parameter_Associations => New_List (Relocate_Node (Expr)));
+ end if;
end Make_Invariant_Call;
------------------------
return;
end if;
- -- If invariants should be ignored, delete the pragma and then
- -- return. We do this here, after checking for errors, and before
- -- generating anything that has a run-time effect.
-
- if Present (Check_Policy_List)
- and then
- (Policy_In_Effect (Name_Invariant) = Name_Ignore
- and then
- Policy_In_Effect (Name_Type_Invariant) = Name_Ignore)
- then
- Rewrite (N, Make_Null_Statement (Loc));
- return;
- end if;
-
-- A pragma that applies to a Ghost entity becomes Ghost for the
-- purposes of legality checks and removal of ignored Ghost code.