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] Unresolved discriminant selector of private overloaded prefix


The compiler rejects a selected component naming a discriminant of a private
type when the prefix is overloaded. Prefixes of private types were not being
accounted for in analysis and resolution of an overloaded selected component.

The following test must compile quietly:

procedure Overloaded_Discrim_Selector is

   package Pkg is
      
      type Some_Rec is null record;
   
      function Func (I : Integer) return Some_Rec;

      type Another_Rec (Exists : Boolean := False) is private;      
      
      function Func (I : Integer) return Another_Rec;

   private
      
      type Another_Rec (Exists : Boolean := False) is null record;
      
   end Pkg;

   package body Pkg is
      
      function Func (I : Integer) return Some_Rec is
         S : Some_Rec;
      begin
         return S;
      end Func;         
      
      function Func (I : Integer) return Another_Rec is
         A : Another_Rec ;
      begin
         return A;
      end Func;
      
   end Pkg;
   
   use Pkg;

   B : Boolean := Func (123).Exists;

begin
   null;
end Overloaded_Discrim_Selector;

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

2011-08-03  Gary Dismukes  <dismukes@adacore.com>

	* sem_ch4.adb (Analyze_Overloaded_Selected_Component): Consider
	prefixes of private types along with records, since the selector may be
	a discriminant.
	* sem_res.adb (Resolve_Selected_Component): Consider prefixes of
	private types along with records, since the selector may be a
	discriminant.

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]