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] Some corner-case fixes related to generics

Tested on x86-linux, committed on mainline.

If the front-end uses the same node as the defining identifier for both a
formal package and the corresponding expanded package, this makes a problem
for ASIS when it tries to compute the enclosing element for an element
based on this defining identifier node. By adding a separate copy of
a defining identifier node for a formal package, we do not change anything
in the semantic processing but simplify the tree structure for ASIS.

In addition, when a child generic is instantiated, the instantiation takes
place in the context of an instance of each ancestor. These ancestor instances
are placed on the scope stack before the current instantiation is analyzed
and removed afterwards. If the instantiation takes place within an
instance of some other generic from the same family tree, ancestors are
already on the scope stack, and their private declarations may be
accessible.  Their status must be preserved on exit, so that the
instantiation of the sibling can proceed correctly.

Test case:
$ gcc -c essai_tri_fusion.adb  # should compile successfully
with List_Gen.Tri_Fusion;
procedure Essai_Tri_Fusion is
    package Liste_Int is new List_Gen (Integer);
    procedure Trier is new Liste_Int.Tri_Fusion ("<=");
begin null; end;

procedure List_Gen.Fusionner
  (Gauche, Droite : in out A_Boite ; Dans : out A_Boite) is
begin null; end;

    with function "<=" (Gauche, Droite : Element) return Boolean;
procedure List_Gen.Fusionner
   (Gauche, Droite : in out A_Boite ; Dans : out A_Boite);

with List_Gen.Fusionner;
procedure List_Gen.Tri_Fusion (L : in out Liste) is
    procedure Fusionner is new List_Gen.Fusionner ("<=" => "<=") ;
    Reste : A_Boite := L.Tete;
    L := (Tete => Reste);

    with function "<=" (Gauche, Droite : Element) return Boolean;
procedure List_Gen.Tri_Fusion (L : in out Liste);

    type Element is private;
package List_Gen is
    type Liste is limited private;
    type Boite;
    type A_Boite is access Boite;
    type Liste is record Tete : A_Boite; end record;
    type Boite is record null; end record;
end List_Gen;

2005-01-03  Ed Schonberg  <>
	    Sergey Rybin  <>

	* sem_ch12.adb (Analyze_Package_Instantiation): Create a separate node
	to use as the defining identifier for a formal package.
	(Remove_Parent): If the instance takes place within (an instance of)
	a sibling, preserve private declarations of common parent.

Attachment: difs.21
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]