https://gcc.gnu.org/g:09ed91df30102e17ac5c59bab314b8b37606c710

commit r15-1484-g09ed91df30102e17ac5c59bab314b8b37606c710
Author: Piotr Trojanek <troja...@adacore.com>
Date:   Wed May 15 10:58:33 2024 +0200

    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:
---
 gcc/ada/freeze.adb   |  1 -
 gcc/ada/sem_ch13.adb | 14 +++++++-------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 2fcc2ce02e71..2a0a59f5b030 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 f65217b0b908..d81b74123130 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;

Reply via email to