]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix bogus error for pragma No_Component_Reordering on record type
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 22 Apr 2025 09:42:00 +0000 (11:42 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Mon, 30 Jun 2025 17:17:24 +0000 (19:17 +0200)
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.

gcc/ada/sem_prag.adb

index 19e72ab6f38f0784b112c6c9583a4ae3a6e8863c..b866dba5e15261669d1b7b16b2de682d2a91cb52 100644 (file)
@@ -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;