aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2020-03-08 17:50:49 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-10 09:35:00 -0400
commitb9daf13c9350cc02c120971a472092d474d63e8f (patch)
treedfccfc4a98120fae5644c202994f1af491dfc4da /gcc
parent9c62140e826a5cda62b49ad7712e7bc297ab77f6 (diff)
downloadgcc-b9daf13c9350cc02c120971a472092d474d63e8f.zip
gcc-b9daf13c9350cc02c120971a472092d474d63e8f.tar.gz
gcc-b9daf13c9350cc02c120971a472092d474d63e8f.tar.bz2
[Ada] Disable unwanted warnings in Assertion_Policy(Ignore) mode
2020-06-10 Bob Duff <duff@adacore.com> gcc/ada/ * sem_prag.adb (Invariant): Remove the pragma removing code. It doesn't work to remove the pragma, because various flags are set during Build_Invariant_Procedure_Declaration and Build_Invariant_Procedure_Body that need to be set to avoid the spurious warnings. * exp_util.adb (Make_Invariant_Call): Avoid calling the invariant-checking procedure if the body is empty. This is an optimization.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_util.adb28
-rw-r--r--gcc/ada/sem_prag.adb14
2 files changed, 15 insertions, 27 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 7fce77a..5e186ec 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -2298,9 +2298,8 @@ package body Exp_Util is
-- 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,
@@ -9360,19 +9359,22 @@ package body Exp_Util is
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;
------------------------
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 2dfe9e0..d05b8fe 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -18607,20 +18607,6 @@ package body Sem_Prag is
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.