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] Inherited subprograms may be both abstract and need overriding


AI05-0028 indicates that an inherited operation can be abstract, even if it
is overridden in a currently non-visible private part, and also require
overriding when the derived type is non-abstract. GNAT has always iplemented
this properly. This patch improves on the error message when this error is
encountered, by indicating that the overriding subprogram is not visible and
therefore not inherited.

Compiling r.ads below in Ada2005 mode must yield:

   r.ads:3:09: type must be declared abstract or "Op" overridden
   r.ads:3:09: "Op" has been inherited at line 3
   r.ads:3:09: "Op" has been inherited at q.ads:3
   r.ads:3:09: "Op" subprogram at q.ads:7 is not visible

package P is
   type I is interface;
   procedure Op (X : I) is abstract;
end P;
---
with P;
package Q is
   type T is abstract new P.I with private;
   -- Op inherited here.
private
   type T is new P.I with null record;
   procedure Op (X : T) is null;
end Q;
---
with Q;
package R is
   type T2 is new Q.T with null record;
   -- Legal? (No.) 
end R;

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

2011-08-05  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch3.adb: (Check_Private_Overriding): better error message,
	suggested by AI95-0068.

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]