aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2020-08-18 11:49:35 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-22 08:11:23 -0400
commitcda800dd90c3dcc6452b0567c62327c651c628dd (patch)
tree30852f13a86ad09a14f06ac7a1c2f4b5a5c39360 /gcc/ada
parentea56c18c501657906e72a693dba7775b2f39a004 (diff)
downloadgcc-cda800dd90c3dcc6452b0567c62327c651c628dd.zip
gcc-cda800dd90c3dcc6452b0567c62327c651c628dd.tar.gz
gcc-cda800dd90c3dcc6452b0567c62327c651c628dd.tar.bz2
[Ada] Refactor appending to possibly empty lists
gcc/ada/ * exp_prag.adb (Expand_Pragma_Contract_Cases, Expand_Pragma_Loop_Variant): Reuse Append_New_To. * sem_prag.adb (Analyze_Contract_Cases_In_Decl_Part): Fix typo. (Analyze_Pre_Post_Condition): Refactor repeated calls to Defining_Entity.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/exp_prag.adb18
-rw-r--r--gcc/ada/sem_prag.adb4
2 files changed, 5 insertions, 17 deletions
diff --git a/gcc/ada/exp_prag.adb b/gcc/ada/exp_prag.adb
index 050b05c..d3c63f4 100644
--- a/gcc/ada/exp_prag.adb
+++ b/gcc/ada/exp_prag.adb
@@ -1831,11 +1831,7 @@ package body Exp_Prag is
-- Raise Assertion_Error when the corresponding consequence of a case
-- guard that evaluated to True fails.
- if No (Stmts) then
- Stmts := New_List;
- end if;
-
- Append_To (Stmts, Conseq_Checks);
+ Append_New_To (Stmts, Conseq_Checks);
In_Assertion_Expr := In_Assertion_Expr - 1;
end Expand_Pragma_Contract_Cases;
@@ -2451,28 +2447,20 @@ package body Exp_Prag is
-- Step 3: Store value of the expression from the previous iteration
- if No (Old_Assign) then
- Old_Assign := New_List;
- end if;
-
-- Generate:
-- Old := Curr;
- Append_To (Old_Assign,
+ Append_New_To (Old_Assign,
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (Old_Id, Loc),
Expression => New_Occurrence_Of (Curr_Id, Loc)));
-- Step 4: Store the current value of the expression
- if No (Curr_Assign) then
- Curr_Assign := New_List;
- end if;
-
-- Generate:
-- Curr := <Expr>;
- Append_To (Curr_Assign,
+ Append_New_To (Curr_Assign,
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (Curr_Id, Loc),
Expression => Relocate_Node (Expr)));
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 4c7131a..b4744bf 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -544,7 +544,7 @@ package body Sem_Prag is
Set_Ghost_Mode (N);
-- Single and multiple contract cases must appear in aggregate form. If
- -- this is not the case, then either the parser of the analysis of the
+ -- this is not the case, then either the parser or the analysis of the
-- pragma failed to produce an aggregate.
pragma Assert (Nkind (CCases) = N_Aggregate);
@@ -4798,7 +4798,7 @@ package body Sem_Prag is
-- Chain the pragma on the contract for further processing by
-- Analyze_Pre_Post_Condition_In_Decl_Part.
- Add_Contract_Item (N, Defining_Entity (Subp_Decl));
+ Add_Contract_Item (N, Subp_Id);
-- Fully analyze the pragma when it appears inside an entry or
-- subprogram body because it cannot benefit from forward references.