diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2020-12-01 15:18:34 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-12-17 05:49:24 -0500 |
commit | 445032728dd46e3692a9aed879c6cf350259a53a (patch) | |
tree | dd8295c90c06c0e12fac6921babc3b50e5690e84 | |
parent | 7948214670c90dfdb656b7c71779745776f74f41 (diff) | |
download | gcc-445032728dd46e3692a9aed879c6cf350259a53a.zip gcc-445032728dd46e3692a9aed879c6cf350259a53a.tar.gz gcc-445032728dd46e3692a9aed879c6cf350259a53a.tar.bz2 |
[Ada] Reduce scopes of local variables for case and if statements
gcc/ada/
* sem_ch5.adb (Analyze_Case_Statement): Change local variable
Exp to constant; remove unreferenced Last_Choice variable;
reduce scope of other variables.
(Analyze_If_Statement): Reduce scope of a local variable; add
comment.
-rw-r--r-- | gcc/ada/sem_ch5.adb | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 0b1db85..380d601 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -1389,16 +1389,7 @@ package body Sem_Ch5 is ---------------------------- procedure Analyze_Case_Statement (N : Node_Id) is - Exp : Node_Id; - Exp_Type : Entity_Id; - Exp_Btype : Entity_Id; - Last_Choice : Nat; - - Others_Present : Boolean; - -- Indicates if Others was present - - pragma Warnings (Off, Last_Choice); - -- Don't care about assigned value + Exp : constant Node_Id := Expression (N); Statements_Analyzed : Boolean := False; -- Set True if at least some statement sequences get analyzed. If False @@ -1406,9 +1397,6 @@ package body Sem_Ch5 is -- the case statement, and as a result it is not a good idea to output -- warning messages about unreachable code. - Save_Unblocked_Exit_Count : constant Nat := Unblocked_Exit_Count; - -- Recursively save value of this global, will be restored on exit - procedure Non_Static_Choice_Error (Choice : Node_Id); -- Error routine invoked by the generic instantiation below when the -- case statement has a non static choice. @@ -1492,11 +1480,21 @@ package body Sem_Ch5 is Analyze_Statements (Statements (Alternative)); end Process_Statements; + -- Local variables + + Exp_Type : Entity_Id; + Exp_Btype : Entity_Id; + + Others_Present : Boolean; + -- Indicates if Others was present + + Save_Unblocked_Exit_Count : constant Nat := Unblocked_Exit_Count; + -- Recursively save value of this global, will be restored on exit + -- Start of processing for Analyze_Case_Statement begin Unblocked_Exit_Count := 0; - Exp := Expression (N); Analyze (Exp); -- The expression must be of any discrete type. In rare cases, the @@ -1775,8 +1773,6 @@ package body Sem_Ch5 is -- on which they depend will not be available at the freeze point. procedure Analyze_If_Statement (N : Node_Id) is - E : Node_Id; - Save_Unblocked_Exit_Count : constant Nat := Unblocked_Exit_Count; -- Recursively save value of this global, will be restored on exit @@ -1841,6 +1837,11 @@ package body Sem_Ch5 is end if; end Analyze_Cond_Then; + -- Local variables + + E : Node_Id; + -- For iterating over elsif parts + -- Start of processing for Analyze_If_Statement begin |