This patch fixes an omission in the analysis of formal package declarations. Actuals in the instance are properly rejected if their name does not correspond to any of the actuals, and there are box associations for existing formals.
Compiling gcc -c c_test.ads must yield generic_p_level_2.ads:7:53: unmatched actual "C_Test" generic_p_level_2.ads:7:53: in instantiation of "Generic_P_Level_1" declared at generic_p_level_1.ads:5 --- -------------------------- generic type Param is (<>); package Generic_P_Level_1 is Var : Integer; end; -------------------------- with Generic_P_Level_1; generic with package P_Level_1 is new Generic_P_Level_1 (C_Test => 2, Param => <>); package Generic_P_Level_2 is Var : Integer; end; ------------------------ with Generic_P_Level_1; with Generic_P_Level_2; package test is package P_Level_1 is new Generic_P_Level_1(Integer); package P_Level_2 is new Generic_P_Level_2(P_Level_1); end; Tested on x86_64-pc-linux-gnu, committed on trunk 2016-06-14 Ed Schonberg <schonb...@adacore.com> * sem_ch12.adb (Analyze_Associations): An actual parameter with a box must be included in the count of actuals, to detect possible superfluous named actuals that do not match any of the formals of the generic unit in a formal package declaration.
Index: sem_ch12.adb =================================================================== --- sem_ch12.adb (revision 237432) +++ sem_ch12.adb (working copy) @@ -1496,10 +1496,13 @@ -- A named association may lack an actual parameter, if it was -- introduced for a default subprogram that turns out to be local - -- to the outer instantiation. + -- to the outer instantiation. If it has a box association it must + -- correspond to some formal in the generic. if Nkind (Named) /= N_Others_Choice - and then Present (Explicit_Generic_Actual_Parameter (Named)) + and then + (Present (Explicit_Generic_Actual_Parameter (Named)) + or else Box_Present (Named)) then Num_Actuals := Num_Actuals + 1; end if;