diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2023-12-01 18:47:01 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-06-10 11:03:58 +0200 |
commit | 8ce93cc22e06639ff82d2ec9e75da1f998dc70ad (patch) | |
tree | 77ad556f47f52cd9e68733e48f4a23ed89eb47ed /gcc | |
parent | a53e5e7aee9af007943f8a96aec00fce343dab57 (diff) | |
download | gcc-8ce93cc22e06639ff82d2ec9e75da1f998dc70ad.zip gcc-8ce93cc22e06639ff82d2ec9e75da1f998dc70ad.tar.gz gcc-8ce93cc22e06639ff82d2ec9e75da1f998dc70ad.tar.bz2 |
ada: Refactor common code for dynamic and static class-wide preconditions
Code cleanup; semantics is unaffected.
gcc/ada/
* exp_ch6.adb (Install_Class_Preconditions_Check): Refactor
common code for checking if precondition fails, since the
difference is only in raising an exception or calling the
Raise_Assert_Failure procedure.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/exp_ch6.adb | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index e433891..b5c5865 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -7868,6 +7868,7 @@ package body Exp_Ch6 is Present (Controlling_Argument (Call_Node)); Class_Subp : Entity_Id; Cond : Node_Id; + Fail : Node_Id; Subp : Entity_Id; -- Start of processing for Install_Class_Preconditions_Check @@ -7913,30 +7914,29 @@ package body Exp_Ch6 is end if; if Exception_Locations_Suppressed then - Insert_Action (Call_Node, - Make_If_Statement (Loc, - Condition => Make_Op_Not (Loc, Cond), - Then_Statements => New_List ( - Make_Raise_Statement (Loc, - Name => - New_Occurrence_Of - (RTE (RE_Assert_Failure), Loc))))); + Fail := + Make_Raise_Statement (Loc, + Name => + New_Occurrence_Of + (RTE (RE_Assert_Failure), Loc)); -- Failed check with message indicating the failed precondition and the -- call that caused it. else - Insert_Action (Call_Node, - Make_If_Statement (Loc, - Condition => Make_Op_Not (Loc, Cond), - Then_Statements => New_List ( - Make_Procedure_Call_Statement (Loc, - Name => - New_Occurrence_Of - (RTE (RE_Raise_Assert_Failure), Loc), - Parameter_Associations => - New_List (Build_Error_Message (Subp)))))); + Fail := + Make_Procedure_Call_Statement (Loc, + Name => + New_Occurrence_Of + (RTE (RE_Raise_Assert_Failure), Loc), + Parameter_Associations => + New_List (Build_Error_Message (Subp))); end if; + + Insert_Action (Call_Node, + Make_If_Statement (Loc, + Condition => Make_Op_Not (Loc, Cond), + Then_Statements => New_List (Fail))); end Install_Class_Preconditions_Check; ------------------------------ |