From: Piotr Trojanek Date: Wed, 15 May 2024 08:58:33 +0000 (+0200) Subject: ada: Remove redundant conditions from freezing code X-Git-Tag: basepoints/gcc-16~8069 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09ed91df30102e17ac5c59bab314b8b37606c710;p=thirdparty%2Fgcc.git ada: Remove redundant conditions from freezing code Code cleanup; behavior is unaffected. gcc/ada/ * freeze.adb (Check_Current_Instance): This routine is only called with parameter E being a type entity, so there is no need to check for types just before the equality with E. * sem_ch13.adb (Analyze_Aspect_Specifications): Regroup condition to avoid unnecessary evaluation. (Check_Aspect_At_End_Of_Declarations): If In_Instance is true, then the routine exits early. --- diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 2fcc2ce02e7..2a0a59f5b03 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -3086,7 +3086,6 @@ package body Freeze is when N_Attribute_Reference => if Attribute_Name (N) in Name_Access | Name_Unchecked_Access and then Is_Entity_Name (Prefix (N)) - and then Is_Type (Entity (Prefix (N))) and then Entity (Prefix (N)) = E then if Ada_Version < Ada_2012 then diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index f65217b0b90..d81b7412313 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -4086,12 +4086,12 @@ package body Sem_Ch13 is Error_Msg_N ("aspect% cannot apply to subtype", Id); goto Continue; - elsif A_Id = Aspect_Default_Value - and then not Is_Scalar_Type (E) - then - Error_Msg_N - ("aspect% can only be applied to scalar type", Id); - goto Continue; + elsif A_Id = Aspect_Default_Value then + if not Is_Scalar_Type (E) then + Error_Msg_N + ("aspect% can only be applied to scalar type", Id); + goto Continue; + end if; elsif A_Id = Aspect_Default_Component_Value then if not Is_Array_Type (E) then @@ -11118,7 +11118,7 @@ package body Sem_Ch13 is -- If the end of declarations comes before any other freeze point, -- the Freeze_Expr is not analyzed: no check needed. - if Analyzed (Freeze_Expr) and then not In_Instance then + if Analyzed (Freeze_Expr) then Check_Overloaded_Name; else Err := False;