From bc3fb397fd7be2935d9122bb9d1972e701aae83f Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Wed, 23 May 2018 10:23:39 +0000 Subject: [PATCH] [Ada] Fix various defects found by static analysis 2018-05-23 Arnaud Charlet gcc/ada/ * checks.adb (Minimize_Eliminate_Overflows): Default initialize Lo and Hi. * sem_elab.adb: Make "out" parameters instead of "in out" when relevant. From-SVN: r260594 --- gcc/ada/ChangeLog | 7 +++++++ gcc/ada/checks.adb | 6 ++++++ gcc/ada/sem_elab.adb | 16 ++++++++-------- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d77cecb125a..5a34deeb7de 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2018-05-23 Arnaud Charlet + + * checks.adb (Minimize_Eliminate_Overflows): Default initialize Lo and + Hi. + * sem_elab.adb: Make "out" parameters instead of "in out" when + relevant. + 2018-05-23 Bob Duff * gnatbind.adb (List_Applicable_Restrictions): Add diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index d88caad49a7..9fb775f500a 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -8379,6 +8379,12 @@ package body Checks is -- Start of processing for Minimize_Eliminate_Overflows begin + -- Default initialize Lo and Hi since these are not guaranteed to be + -- set otherwise. + + Lo := No_Uint; + Hi := No_Uint; + -- Case where we do not have a signed integer arithmetic operation if not Is_Signed_Integer_Arithmetic_Op (N) then diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb index 0b369ea91f6..cfc21b1fb95 100644 --- a/gcc/ada/sem_elab.adb +++ b/gcc/ada/sem_elab.adb @@ -4494,27 +4494,27 @@ package body Sem_Elab is procedure Transition_Body_Declarations (Bod : Node_Id; - Curr : in out Node_Id); + Curr : out Node_Id); pragma Inline (Transition_Body_Declarations); -- Update the Curr and Start pointers when construct Bod denotes a block -- statement or a suitable body. This routine raises ECR_Found. procedure Transition_Handled_Statements (HSS : Node_Id; - Curr : in out Node_Id); + Curr : out Node_Id); pragma Inline (Transition_Handled_Statements); -- Update the Curr and Start pointers when node HSS denotes a handled -- sequence of statements. This routine raises ECR_Found. procedure Transition_Spec_Declarations (Spec : Node_Id; - Curr : in out Node_Id); + Curr : out Node_Id); pragma Inline (Transition_Spec_Declarations); -- Update the Curr and Start pointers when construct Spec denotes -- a concurrent definition or a package spec. This routine raises -- ECR_Found. - procedure Transition_Unit (Unit : Node_Id; Curr : in out Node_Id); + procedure Transition_Unit (Unit : Node_Id; Curr : out Node_Id); pragma Inline (Transition_Unit); -- Update the Curr and Start pointers when node Unit denotes a potential -- compilation unit. This routine raises ECR_Found. @@ -4907,7 +4907,7 @@ package body Sem_Elab is procedure Transition_Body_Declarations (Bod : Node_Id; - Curr : in out Node_Id) + Curr : out Node_Id) is Decls : constant List_Id := Declarations (Bod); @@ -4935,7 +4935,7 @@ package body Sem_Elab is procedure Transition_Handled_Statements (HSS : Node_Id; - Curr : in out Node_Id) + Curr : out Node_Id) is Bod : constant Node_Id := Parent (HSS); Decls : constant List_Id := Declarations (Bod); @@ -4986,7 +4986,7 @@ package body Sem_Elab is procedure Transition_Spec_Declarations (Spec : Node_Id; - Curr : in out Node_Id) + Curr : out Node_Id) is Prv_Decls : constant List_Id := Private_Declarations (Spec); Vis_Decls : constant List_Id := Visible_Declarations (Spec); @@ -5048,7 +5048,7 @@ package body Sem_Elab is procedure Transition_Unit (Unit : Node_Id; - Curr : in out Node_Id) + Curr : out Node_Id) is Context : constant Node_Id := Parent (Unit); -- 2.30.2