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] Spurious errors on inherited class-wide preconditions

This patch fixes some spurious errors arising when class-wide preconditions
in an generic instance are overridden in a child instance.

The following must compile quietly:

   gcc -c

generic package P is

  type T1 is abstract tagged private;

  procedure P1 (This : in out T1)
     with Pre'Class => T1'Class (This).F1 and then

  function F1 (This : in T1)
     return Boolean is abstract;

  function F2 (This : in T1)
     return Boolean;


  type T1 is abstract tagged
        B : Boolean;
     end record;

  function F2 (This : in T1)
     return Boolean is

end P;
package body P is

  procedure P1 (This : in out T1) is
     This.B := False;
  end P1;

end P;
generic package P.Q is

  type T2 is abstract new T1 with null record;

  overriding function F1 (This : in T2)
     return Boolean is (True);

end P.Q;
with P.Q;

package R is

  package P_Instance is new P;
  package Q_Instance is new P_Instance.Q;

  type T3 is new Q_Instance.T2 with null record;

end R;

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

2016-07-07  Ed Schonberg  <>

	*, sem_prag.adb (Build_Classwide_Expression): Include
	overridden operation as parameter, in order to map formals of
	the overridden and overring operation properly prior to rewriting
	the inherited condition.
	* freeze.adb (Check_Inherited_Cnonditions): Change call to
	Build_Class_Wide_Expression accordingly.  In Spark_Mode, add
	call to analyze the contract of the parent operation, prior to
	mapping formals between operations.

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]