]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Do not build dispatch tables for generics
authorRonan Desplanques <desplanques@adacore.com>
Wed, 5 Mar 2025 15:18:49 +0000 (16:18 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 9 Jun 2025 06:32:08 +0000 (08:32 +0200)
Before this patch, Build_Static_Dispatch_Tables was called on generic
package bodies. While this has not been proved to cause any actual bug,
it was clearly inappropriate and also useless, so this patch removes
those calls.

gcc/ada/ChangeLog:

* sem_ch10.adb (Analyze_Compilation_Unit): Check for generic bodies.
* exp_disp.adb (Build_Dispatch_Tables): Likewise.

gcc/ada/exp_disp.adb
gcc/ada/sem_ch10.adb

index 458b32c1730ebb40c6b1e22e2de1dbdeba7bba2b..080a2e1a6c168096371bee3ee42fafd9022183c8 100644 (file)
@@ -413,7 +413,9 @@ package body Exp_Disp is
             if Nkind (D) = N_Package_Declaration then
                Build_Package_Dispatch_Tables (D);
 
-            elsif Nkind (D) = N_Package_Body then
+            elsif Nkind (D) = N_Package_Body
+              and then Ekind (Corresponding_Spec (D)) /= E_Generic_Package
+            then
                Build_Dispatch_Tables (Declarations (D));
 
             elsif Nkind (D) = N_Package_Body_Stub
index 25bba9b607597fa387bd1de00d34f8ed7a46e458..45aabadf21f8edfc6a0d4b4fb97f867d1274fdc2 100644 (file)
@@ -1225,9 +1225,15 @@ package body Sem_Ch10 is
 
       if Expander_Active and then Tagged_Type_Expansion then
          case Nkind (Unit_Node) is
-            when N_Package_Declaration | N_Package_Body =>
+            when N_Package_Declaration =>
                Build_Static_Dispatch_Tables (Unit_Node);
 
+            when N_Package_Body =>
+               if Ekind (Corresponding_Spec (Unit_Node)) /= E_Generic_Package
+               then
+                  Build_Static_Dispatch_Tables (Unit_Node);
+               end if;
+
             when N_Package_Instantiation =>
                Build_Static_Dispatch_Tables (Instance_Spec (Unit_Node));