]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Remove redundant conditions from freezing code
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 15 May 2024 08:58:33 +0000 (10:58 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Thu, 20 Jun 2024 08:50:53 +0000 (10:50 +0200)
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.

gcc/ada/freeze.adb
gcc/ada/sem_ch13.adb

index 2fcc2ce02e71acc2448fa3d65d84b4d2ee33d9f8..2a0a59f5b0303cda6438dba9b601ed1223b5ea2e 100644 (file)
@@ -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
index f65217b0b9088e69899e78cf8673b003fed89771..d81b741231302d8724e95abd07f722e830e430c9 100644 (file)
@@ -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;