This is the mail archive of the 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] Better warning for failure to override an abstract operation in an instance

An operation declared in the private part of a generic package is overriding
in an instane only if it was overriding in the generic. If an instantiation
fails because a non-abstract type has a remaining abstract inherited operation
it may be because of a failure to override. This patch produces a warning in
this case, that clarifies the resulting error message.

compiling must yield: instantiation error at type must be declared abstract or "Change" overridden "Change" has been inherited at, instance at line 5 "Change" has been inherited from subprogram at line 4 warning: in instantiation at warning: private operation "Change" in generic unit does not
    override any primitive operation of "Der" (RM 12.3 (18))

with P1; with Gen;
package Inst is
   type Act is abstract new P1.Root with null record;
   procedure Change (Obj : Act) is abstract;
   package Prob is new Gen (Act);
end Inst;
package P1 is
   type Root is abstract tagged null record;
end P1;
with P1;
   type Ext is abstract new P1.Root with private;
package Gen is
   type Der is new Ext with private;
   type Der is new Ext with null record;
   procedure Change (Obj : Der);
end Gen;

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

2012-02-17  Ed Schonberg  <>

	* sem_ch6.adb (Is_Non_Overriding_Operation): Add warning if the
	old operation is abstract, the relevant type is not abstract,
	and the new subprogram fails to override.

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]