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] Error on conversion of access to incomplete type implementing interface


The compiler gives an error about a wrong interface conversion when
the conversion operand is of an access type designating an incomplete
type even though the full type implements the interface designated by
the target type (or fails with a bug box for a compiler with assertions
enabled). The compiler failed to retrieve the full type of the designated
type, which is corrected here.

The following package must compile quietly:

package Incomp_Interface_Bug is

  type Intface;
  type Acc_Intface is access all Intface'Class;
  type Intface is interface;

  type Implementor;
  type Acc_Implementor is access all Implementor;

  type Implementor is new Intface with record
     I : Integer;
  end record;

  procedure Pass_Intface (AIF : Acc_Intface);
  procedure Initialize (Impl_Acc : in out Acc_Implementor);

end Incomp_Interface_Bug;

package body Incomp_Interface_Bug is

  procedure Pass_Intface (AIF : Acc_Intface) is
  begin
     null;
  end Pass_Intface;

  procedure Initialize (Impl_Acc : in out Acc_Implementor) is
  begin
     Pass_Intface (Acc_Intface (Impl_Acc));
  end Initialize;

end Incomp_Interface_Bug;

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

2010-06-22  Gary Dismukes  <dismukes@adacore.com>

	* exp_util.adb (Find_Interface_ADT): Retrieve Designated_Type instead of
	Directly_Designated_Type when the type argument is an access type.
	(Find_Interface_Tag): Retrieve Designated_Type instead of
	Directly_Designated_Type when the type argument is an access type.
	(Has_Controlled_Coextensions): Retrieve Designated_Type instead of
	Directly_Designated_Type of each access discriminant.
	* sem_res.adb (Resolve_Type_Conversion): Retrieve Designated_Type
	instead of Directly_Designated_Type when the operand and target types
	are access types.

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]