This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Missing error on formal package


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  <schonberg@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.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]