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] Visibility error of selected component in instance body


This patch fixes a spurious visibility error on a selected component in an
instance body, when the type of the prefix of the selected component is an
actual of the instance, and the desired component is inherited through
one or more derivations

The package derived.ads below must compile quietly:

--
package AST is

   type AST_Node_Type is abstract tagged private;
   type AST_Node_Access is access AST_Node_Type;
   type AST_Node is access all AST_Node_Type'Class;

   procedure Compute_Indent_Level (Node : access AST_Node_Type) is abstract;

private

   type AST_Node_Type is abstract tagged record
      Indent_Level : Natural;
   end record;

end AST;
---
generic
   type Node_Type is abstract new AST_Node_Type with private;
   type Node is access all Node_Type'Class;
package AST.List is

   type List_Type is new AST_Node_Type with record
      N : Node;
   end record;

   overriding
   procedure Compute_Indent_Level (Node : access List_Type);

end AST.List;
package body AST.List is

   overriding
   procedure Compute_Indent_Level (Node : access List_Type) is
   begin
      Node.N.Indent_Level := Node.Indent_Level;
   end Compute_Indent_Level;

end AST.List;
---
with AST; use AST;
with AST.List;

package Derived is

   type Derived_Type is abstract new AST_Node_Type with null record;
   type Derived is access all Derived_Type'Class;

   package Lists is new AST.List
     (Node_Type => Derived_Type,
      Node      => Derived);

end Derived;

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

2015-05-27  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch4.adb (Analyze_Selected_Component): If the type to use
	is a derived type and is a generic actual, the selected component
	appears within an instance body, and the check over the type
	has failed, examine ancestor types for the desired component.
	(Find_Component_In_Instance): If record type is a derived type,
	examine all ancestors in order to locate desired component.

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]