diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2018-05-24 13:07:11 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-05-24 13:07:11 +0000 |
commit | 672dfc39f1dedd8b00fb10f6b7b01671b27c0f86 (patch) | |
tree | 48c2ae6e2323e23bbbbf9593876067f4ef349d56 /gcc | |
parent | 63a329f81c83b58694571cebb39c3ab8cec935c4 (diff) | |
download | gcc-672dfc39f1dedd8b00fb10f6b7b01671b27c0f86.zip gcc-672dfc39f1dedd8b00fb10f6b7b01671b27c0f86.tar.gz gcc-672dfc39f1dedd8b00fb10f6b7b01671b27c0f86.tar.bz2 |
[Ada] Simplify routines with a local Result variable
Local variable Result that is modified inside IF statements makes a seemingly
trivial code slightly hard to understand. This patch rewrites such a pattern.
Semantics unaffected.
2018-05-24 Piotr Trojanek <trojanek@adacore.com>
gcc/ada/
* sem_elab.adb (Non_Private_View): Simplify by removing a local Result
variable.
* sem_prag.adb (Get_Base_Subprogram): Same as above.
From-SVN: r260670
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/sem_elab.adb | 12 | ||||
-rw-r--r-- | gcc/ada/sem_prag.adb | 16 |
3 files changed, 16 insertions, 18 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 5ebe69e..66dfa8e 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2018-05-24 Piotr Trojanek <trojanek@adacore.com> + + * sem_elab.adb (Non_Private_View): Simplify by removing a local Result + variable. + * sem_prag.adb (Get_Base_Subprogram): Same as above. + 2018-05-24 Eric Botcazou <ebotcazou@adacore.com> * fe.h (Set_Normalized_First_Bit): Declare. diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb index 9525f7f..e316995 100644 --- a/gcc/ada/sem_elab.adb +++ b/gcc/ada/sem_elab.adb @@ -8077,16 +8077,12 @@ package body Sem_Elab is ---------------------- function Non_Private_View (Typ : Entity_Id) return Entity_Id is - Result : Entity_Id; - begin - Result := Typ; - - if Is_Private_Type (Result) and then Present (Full_View (Result)) then - Result := Full_View (Result); + if Is_Private_Type (Typ) and then Present (Full_View (Typ)) then + return Full_View (Typ); + else + return Typ; end if; - - return Result; end Non_Private_View; ----------------------------- diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index c85d26f..cd46404 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -29765,23 +29765,19 @@ package body Sem_Prag is ------------------------- function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id is - Result : Entity_Id; - begin -- Follow subprogram renaming chain - Result := Def_Id; - - if Is_Subprogram (Result) + if Is_Subprogram (Def_Id) and then - Nkind (Parent (Declaration_Node (Result))) = + Nkind (Parent (Declaration_Node (Def_Id))) = N_Subprogram_Renaming_Declaration - and then Present (Alias (Result)) + and then Present (Alias (Def_Id)) then - Result := Alias (Result); + return Alias (Def_Id); + else + return Def_Id; end if; - - return Result; end Get_Base_Subprogram; ----------------------- |