https://gcc.gnu.org/g:411c1eeadfbe99efa203097c93fa08256bc72f85

commit r15-9881-g411c1eeadfbe99efa203097c93fa08256bc72f85
Author: Eric Botcazou <ebotca...@adacore.com>
Date:   Tue Apr 22 11:42:00 2025 +0200

    ada: Fix bogus error for pragma No_Component_Reordering on record type
    
    This happens when the record type has an incomplete declaration before its
    full declaration and is fixed by calling Find_Type appropriately.
    
    gcc/ada/ChangeLog:
    
            * sem_prag.adb (Analyze_Pragma) <Pragma_No_Component_Reordering>:
            Call Find_Type on the first argument of the pragma.

Diff:
---
 gcc/ada/sem_prag.adb | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 19e72ab6f38f..b866dba5e152 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -21373,8 +21373,8 @@ package body Sem_Prag is
          --  pragma No_Component_Reordering [([Entity =>] type_LOCAL_NAME)];
 
          when Pragma_No_Component_Reordering => No_Comp_Reordering : declare
-            E    : Entity_Id;
-            E_Id : Node_Id;
+            Typ     : Entity_Id;
+            Type_Id : Node_Id;
 
          begin
             GNAT_Pragma;
@@ -21387,19 +21387,20 @@ package body Sem_Prag is
             else
                Check_Optional_Identifier (Arg2, Name_Entity);
                Check_Arg_Is_Local_Name (Arg1);
-               E_Id := Get_Pragma_Arg (Arg1);
+               Type_Id := Get_Pragma_Arg (Arg1);
 
-               if Etype (E_Id) = Any_Type then
+               Find_Type (Type_Id);
+               Typ := Entity (Type_Id);
+
+               if Typ = Any_Type then
                   return;
                end if;
 
-               E := Entity (E_Id);
-
-               if not Is_Record_Type (E) then
+               if not Is_Record_Type (Typ) then
                   Error_Pragma_Arg ("pragma% requires record type", Arg1);
                end if;
 
-               Set_No_Reordering (Base_Type (E));
+               Set_No_Reordering (Base_Type (Typ));
             end if;
          end No_Comp_Reordering;

Reply via email to