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] 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 inst.ads must yield:

inst.ads:5:04: instantiation error at gen.ads:7
inst.ads:5:04: type must be declared abstract or "Change" overridden
inst.ads:5:04: "Change" has been inherited at gen.ads:5, instance at line 5
inst.ads:5:04: "Change" has been inherited from subprogram at line 4
inst.ads:5:04: warning: in instantiation at gen.ads:8
inst.ads:5:04: 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;
generic
   type Ext is abstract new P1.Root with private;
package Gen is
   type Der is new Ext with private;
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  <schonberg@adacore.com>

	* 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]