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] Improve error messages with mismatched anonymous access to subprograms


This patch improves the error reporting when the mismatched types between
expression and context involve an anonymous Access_to_Subprogram that is the
type of a formal in a subprogram declaration.

Compiling the following program must yield:

proc.adb:10:16: expected access to subprogram declared in profile of
     "Ada.Containers.Ordered_Sets.Iterate" from instance at line 4
proc.adb:10:16: found type access to procedure "P" defined at line 10
proc.adb:11:16: expected access to subprogram with profile  defined at line 8
proc.adb:11:16: found type access to procedure "P" defined at line 11

---
pragma Ada_2005;
with Ada.Containers.Ordered_Sets;
procedure Proc is
   package Integer_Sets is new Ada.Containers.Ordered_Sets (Integer);
   S : Integer_Sets.Set;

   procedure P (X : Boolean) is begin null; end P;
   Pointer : access Procedure (X : Integer);
begin
   S.Iterate (P'Access); --  ERROR: profile is not conformant
   Pointer := P'access;  --  ERROR
end Proc;

Tested on x86_64-pc-linux-gnu, committed on trunk

2009-11-30  Ed Schonberg  <schonberg@adacore.com>

	* errout.adb (Unwind_Internal_Type): Improve error reporting if the
	type is an anonymous access to subprogram that is the type of a formal
	in a subprogram spec.

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]