diff mbox series

[Ada] Reorder processing of default expressions to avoid repeated calls

Message ID 20220705083007.GA3195473@adacore.com
State New
Headers show
Series [Ada] Reorder processing of default expressions to avoid repeated calls | expand

Commit Message

Pierre-Marie de Rodat July 5, 2022, 8:30 a.m. UTC
Code cleanup related to improved detection of uninitialised objects;
semantics is unaffected.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

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

Patch

diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -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)) /=