]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Reorder processing of default expressions to avoid repeated calls
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 8 Jun 2022 18:49:57 +0000 (20:49 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 5 Jul 2022 08:28:20 +0000 (08:28 +0000)
Code cleanup related to improved detection of uninitialised objects;
semantics is unaffected.

gcc/ada/

* sem_ch6.adb (Process_Formals): Avoid repeated calls to
Expression.

gcc/ada/sem_ch6.adb

index 440770ad8bf2c0fac5aacea47b616b5fa1b0369b..1efc8842db9e700d8e0067daf8dc4ab8d423c1f3 100644 (file)
@@ -12985,10 +12985,10 @@ package body Sem_Ch6 is
          Set_Formal_Mode (Formal);
 
          if Ekind (Formal) = E_In_Parameter then
-            Set_Default_Value (Formal, Expression (Param_Spec));
+            Default := Expression (Param_Spec);
 
-            if Present (Expression (Param_Spec)) then
-               Default := Expression (Param_Spec);
+            if Present (Default) then
+               Set_Default_Value (Formal, Default);
 
                if Is_Scalar_Type (Etype (Default)) then
                   if Nkind (Parameter_Type (Param_Spec)) /=