From: Ronan Desplanques <desplanq...@adacore.com> 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. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_disp.adb | 4 +++- gcc/ada/sem_ch10.adb | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb index 458b32c1730..080a2e1a6c1 100644 --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -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 diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb index 25bba9b6075..45aabadf21f 100644 --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -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)); -- 2.43.0