begin
GNAT_Pragma;
Check_No_Identifiers;
- Check_Arg_Count (1);
+ Check_At_Most_N_Arguments (1);
-- Ensure the proper placement of the pragma. Program_Exit must be
-- associated with a subprogram declaration or a body that acts as
is
Subp_Decl : constant Node_Id := Find_Related_Declaration_Or_Body (N);
Spec_Id : constant Entity_Id := Unique_Defining_Entity (Subp_Decl);
-
- Expr : constant Node_Id := Expression (Get_Argument (N, Spec_Id));
+ Arg1 : constant Node_Id :=
+ First (Pragma_Argument_Associations (N));
Saved_GM : constant Ghost_Mode_Type := Ghost_Mode;
Saved_IGR : constant Node_Id := Ignored_Ghost_Region;
"for subprograms with side effects", N);
end if;
- -- Set the Ghost mode in effect from the pragma. Due to the delayed
- -- analysis of the pragma, the Ghost mode at point of declaration and
- -- point of analysis may not necessarily be the same. Use the mode in
- -- effect at the point of declaration.
+ if Present (Arg1) then
- Set_Ghost_Mode (N);
+ -- Set the Ghost mode in effect from the pragma. Due to the delayed
+ -- analysis of the pragma, the Ghost mode at point of declaration and
+ -- point of analysis may not necessarily be the same. Use the mode in
+ -- effect at the point of declaration.
- -- Ensure that the subprogram and its formals are visible when analyzing
- -- the expression of the pragma.
+ Set_Ghost_Mode (N);
- if not In_Open_Scopes (Spec_Id) then
- Restore_Scope := True;
+ -- Ensure that the subprogram and its formals are visible when
+ -- analyzing the expression of the pragma.
- if Is_Generic_Subprogram (Spec_Id) then
- Push_Scope (Spec_Id);
- Install_Generic_Formals (Spec_Id);
- else
- Push_Scope (Spec_Id);
- Install_Formals (Spec_Id);
+ if not In_Open_Scopes (Spec_Id) then
+ Restore_Scope := True;
+
+ if Is_Generic_Subprogram (Spec_Id) then
+ Push_Scope (Spec_Id);
+ Install_Generic_Formals (Spec_Id);
+ else
+ Push_Scope (Spec_Id);
+ Install_Formals (Spec_Id);
+ end if;
end if;
- end if;
- Errors := Serious_Errors_Detected;
+ Errors := Serious_Errors_Detected;
- -- Preanalyze_And_Resolve_Assert_Expression enforcing the expression
- -- type.
+ -- Preanalyze_And_Resolve_Assert_Expression enforcing the expression
+ -- type.
- Preanalyze_And_Resolve_Assert_Expression (Expr, Any_Boolean);
+ Preanalyze_And_Resolve_Assert_Expression
+ (Expression (Arg1), Any_Boolean);
- -- Emit a clarification message when the expression contains at least
- -- one undefined reference, possibly due to contract freezing.
+ -- Emit a clarification message when the expression contains at least
+ -- one undefined reference, possibly due to contract freezing.
- if Errors /= Serious_Errors_Detected
- and then Present (Freeze_Id)
- and then Has_Undefined_Reference (Expr)
- then
- Contract_Freeze_Error (Spec_Id, Freeze_Id);
- end if;
+ if Errors /= Serious_Errors_Detected
+ and then Present (Freeze_Id)
+ and then Has_Undefined_Reference (Expression (Arg1))
+ then
+ Contract_Freeze_Error (Spec_Id, Freeze_Id);
+ end if;
- if Restore_Scope then
- End_Scope;
- end if;
+ if Restore_Scope then
+ End_Scope;
+ end if;
- -- Currently it is not possible to inline pre/postconditions on a
- -- subprogram subject to pragma Inline_Always.
+ -- Currently it is not possible to inline pre/postconditions on a
+ -- subprogram subject to pragma Inline_Always.
- Check_Postcondition_Use_In_Inlined_Subprogram (N, Spec_Id);
- Set_Is_Analyzed_Pragma (N);
+ Check_Postcondition_Use_In_Inlined_Subprogram (N, Spec_Id);
- Restore_Ghost_Region (Saved_GM, Saved_IGR);
+ Restore_Ghost_Region (Saved_GM, Saved_IGR);
+ end if;
+
+ Set_Is_Analyzed_Pragma (N);
end Analyze_Program_Exit_In_Decl_Part;
------------------------------------------