diff options
author | Justin Squirek <squirek@adacore.com> | 2020-12-23 13:06:22 -0500 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-05-03 05:28:22 -0400 |
commit | 3ffe57d4b11ca8daab277d94c86db2b95feafa9d (patch) | |
tree | 73f9ae627dd71a8d35e3b7bbd2a0f797b5762a7b /gcc/ada/contracts.adb | |
parent | 5b48ea9dacdae9edae491d72b5db8864109a48a1 (diff) | |
download | gcc-3ffe57d4b11ca8daab277d94c86db2b95feafa9d.zip gcc-3ffe57d4b11ca8daab277d94c86db2b95feafa9d.tar.gz gcc-3ffe57d4b11ca8daab277d94c86db2b95feafa9d.tar.bz2 |
[Ada] Expansion in _postconditions confusing CodePeer
gcc/ada/
* contracts.adb (Build_Postconditions_Procedure): Remove
internally generated if statement used to control finalization
actions.
* exp_ch6.adb (Add_Return, Expand_Non_Function_Return,
Expand_Simple_Function_Return): Add if statement around
_postconditions to control finalization.
* exp_ch7.adb (Build_Finalizer): Likewise.
* sem_prag.adb (Find_Related_Declaration_Or_Body): Add case to
handle Context itself being a handled sequence of statements.
Diffstat (limited to 'gcc/ada/contracts.adb')
-rw-r--r-- | gcc/ada/contracts.adb | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb index 29557ec..f42a950 100644 --- a/gcc/ada/contracts.adb +++ b/gcc/ada/contracts.adb @@ -2367,6 +2367,10 @@ package body Contracts is -- postconditions until finalization has been performed when cleanup -- actions are present. + -- NOTE: This flag could be made into a predicate since we should be + -- able at compile time to recognize when finalization and cleanup + -- actions occur, but in practice this is not possible ??? + -- Generate: -- -- Postcond_Enabled : Boolean := True; @@ -2405,16 +2409,16 @@ package body Contracts is -- the postconditions: this would cause confusing debug info to be -- produced, interfering with coverage-analysis tools. - -- Also, wrap the postcondition checks in a conditional which can be - -- used to delay their evaluation when clean-up actions are present. + -- NOTE: Coverage-analysis and static-analysis tools rely on the + -- postconditions procedure being free of internally generated code + -- since some of these tools, like CodePeer, treat _postconditions + -- as original source. -- Generate: -- -- procedure _postconditions is -- begin - -- if Postcond_Enabled and then Return_Success_For_Postcond then - -- [Stmts]; - -- end if; + -- [Stmts]; -- end; Proc_Bod := @@ -2425,19 +2429,7 @@ package body Contracts is Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, End_Label => Make_Identifier (Loc, Chars (Proc_Id)), - Statements => New_List ( - Make_If_Statement (Loc, - Condition => - Make_And_Then (Loc, - Left_Opnd => - New_Occurrence_Of - (Defining_Identifier - (Postcond_Enabled_Decl), Loc), - Right_Opnd => - New_Occurrence_Of - (Defining_Identifier - (Return_Success_Decl), Loc)), - Then_Statements => Stmts)))); + Statements => Stmts)); Insert_After_And_Analyze (Last_Decl, Proc_Bod); end Build_Postconditions_Procedure; |