Merge from mainline (168000:168310).
[official-gcc/graphite-test-results.git] / gcc / ada / sem_aux.adb
blobe9a47a3bfdedfccdfd9af9a97e6a8c104b01f2f1
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S E M _ A U X --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- As a special exception, if other files instantiate generics from this --
22 -- unit, or you link this unit with other files to produce an executable, --
23 -- this unit does not by itself cause the resulting executable to be --
24 -- covered by the GNU General Public License. This exception does not --
25 -- however invalidate any other reasons why the executable file might be --
26 -- covered by the GNU Public License. --
27 -- --
28 -- GNAT was originally developed by the GNAT team at New York University. --
29 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 -- --
31 ------------------------------------------------------------------------------
33 with Atree; use Atree;
34 with Einfo; use Einfo;
35 with Namet; use Namet;
36 with Sinfo; use Sinfo;
37 with Snames; use Snames;
38 with Stand; use Stand;
40 package body Sem_Aux is
42 ----------------------
43 -- Ancestor_Subtype --
44 ----------------------
46 function Ancestor_Subtype (Typ : Entity_Id) return Entity_Id is
47 begin
48 -- If this is first subtype, or is a base type, then there is no
49 -- ancestor subtype, so we return Empty to indicate this fact.
51 if Is_First_Subtype (Typ) or else Is_Base_Type (Typ) then
52 return Empty;
53 end if;
55 declare
56 D : constant Node_Id := Declaration_Node (Typ);
58 begin
59 -- If we have a subtype declaration, get the ancestor subtype
61 if Nkind (D) = N_Subtype_Declaration then
62 if Nkind (Subtype_Indication (D)) = N_Subtype_Indication then
63 return Entity (Subtype_Mark (Subtype_Indication (D)));
64 else
65 return Entity (Subtype_Indication (D));
66 end if;
68 -- If not, then no subtype indication is available
70 else
71 return Empty;
72 end if;
73 end;
74 end Ancestor_Subtype;
76 --------------------
77 -- Available_View --
78 --------------------
80 function Available_View (Typ : Entity_Id) return Entity_Id is
81 begin
82 if Is_Incomplete_Type (Typ)
83 and then Present (Non_Limited_View (Typ))
84 then
85 -- The non-limited view may itself be an incomplete type, in which
86 -- case get its full view.
88 return Get_Full_View (Non_Limited_View (Typ));
90 elsif Is_Class_Wide_Type (Typ)
91 and then Is_Incomplete_Type (Etype (Typ))
92 and then Present (Non_Limited_View (Etype (Typ)))
93 then
94 return Class_Wide_Type (Non_Limited_View (Etype (Typ)));
96 else
97 return Typ;
98 end if;
99 end Available_View;
101 --------------------
102 -- Constant_Value --
103 --------------------
105 function Constant_Value (Ent : Entity_Id) return Node_Id is
106 D : constant Node_Id := Declaration_Node (Ent);
107 Full_D : Node_Id;
109 begin
110 -- If we have no declaration node, then return no constant value. Not
111 -- clear how this can happen, but it does sometimes and this is the
112 -- safest approach.
114 if No (D) then
115 return Empty;
117 -- Normal case where a declaration node is present
119 elsif Nkind (D) = N_Object_Renaming_Declaration then
120 return Renamed_Object (Ent);
122 -- If this is a component declaration whose entity is a constant, it is
123 -- a prival within a protected function (and so has no constant value).
125 elsif Nkind (D) = N_Component_Declaration then
126 return Empty;
128 -- If there is an expression, return it
130 elsif Present (Expression (D)) then
131 return (Expression (D));
133 -- For a constant, see if we have a full view
135 elsif Ekind (Ent) = E_Constant
136 and then Present (Full_View (Ent))
137 then
138 Full_D := Parent (Full_View (Ent));
140 -- The full view may have been rewritten as an object renaming
142 if Nkind (Full_D) = N_Object_Renaming_Declaration then
143 return Name (Full_D);
144 else
145 return Expression (Full_D);
146 end if;
148 -- Otherwise we have no expression to return
150 else
151 return Empty;
152 end if;
153 end Constant_Value;
155 -----------------------------
156 -- Enclosing_Dynamic_Scope --
157 -----------------------------
159 function Enclosing_Dynamic_Scope (Ent : Entity_Id) return Entity_Id is
160 S : Entity_Id;
162 begin
163 -- The following test is an error defense against some syntax errors
164 -- that can leave scopes very messed up.
166 if Ent = Standard_Standard then
167 return Ent;
168 end if;
170 -- Normal case, search enclosing scopes
172 -- Note: the test for Present (S) should not be required, it defends
173 -- against an ill-formed tree.
175 S := Scope (Ent);
176 loop
177 -- If we somehow got an empty value for Scope, the tree must be
178 -- malformed. Rather than blow up we return Standard in this case.
180 if No (S) then
181 return Standard_Standard;
183 -- Quit if we get to standard or a dynamic scope
185 elsif S = Standard_Standard
186 or else Is_Dynamic_Scope (S)
187 then
188 return S;
190 -- Otherwise keep climbing
192 else
193 S := Scope (S);
194 end if;
195 end loop;
196 end Enclosing_Dynamic_Scope;
198 ------------------------
199 -- First_Discriminant --
200 ------------------------
202 function First_Discriminant (Typ : Entity_Id) return Entity_Id is
203 Ent : Entity_Id;
205 begin
206 pragma Assert
207 (Has_Discriminants (Typ) or else Has_Unknown_Discriminants (Typ));
209 Ent := First_Entity (Typ);
211 -- The discriminants are not necessarily contiguous, because access
212 -- discriminants will generate itypes. They are not the first entities
213 -- either, because tag and controller record must be ahead of them.
215 if Chars (Ent) = Name_uTag then
216 Ent := Next_Entity (Ent);
217 end if;
219 if Chars (Ent) = Name_uController then
220 Ent := Next_Entity (Ent);
221 end if;
223 -- Skip all hidden stored discriminants if any
225 while Present (Ent) loop
226 exit when Ekind (Ent) = E_Discriminant
227 and then not Is_Completely_Hidden (Ent);
229 Ent := Next_Entity (Ent);
230 end loop;
232 pragma Assert (Ekind (Ent) = E_Discriminant);
234 return Ent;
235 end First_Discriminant;
237 -------------------------------
238 -- First_Stored_Discriminant --
239 -------------------------------
241 function First_Stored_Discriminant (Typ : Entity_Id) return Entity_Id is
242 Ent : Entity_Id;
244 function Has_Completely_Hidden_Discriminant
245 (Typ : Entity_Id) return Boolean;
246 -- Scans the Discriminants to see whether any are Completely_Hidden
247 -- (the mechanism for describing non-specified stored discriminants)
249 ----------------------------------------
250 -- Has_Completely_Hidden_Discriminant --
251 ----------------------------------------
253 function Has_Completely_Hidden_Discriminant
254 (Typ : Entity_Id) return Boolean
256 Ent : Entity_Id;
258 begin
259 pragma Assert (Ekind (Typ) = E_Discriminant);
261 Ent := Typ;
262 while Present (Ent) and then Ekind (Ent) = E_Discriminant loop
263 if Is_Completely_Hidden (Ent) then
264 return True;
265 end if;
267 Ent := Next_Entity (Ent);
268 end loop;
270 return False;
271 end Has_Completely_Hidden_Discriminant;
273 -- Start of processing for First_Stored_Discriminant
275 begin
276 pragma Assert
277 (Has_Discriminants (Typ)
278 or else Has_Unknown_Discriminants (Typ));
280 Ent := First_Entity (Typ);
282 if Chars (Ent) = Name_uTag then
283 Ent := Next_Entity (Ent);
284 end if;
286 if Chars (Ent) = Name_uController then
287 Ent := Next_Entity (Ent);
288 end if;
290 if Has_Completely_Hidden_Discriminant (Ent) then
292 while Present (Ent) loop
293 exit when Is_Completely_Hidden (Ent);
294 Ent := Next_Entity (Ent);
295 end loop;
297 end if;
299 pragma Assert (Ekind (Ent) = E_Discriminant);
301 return Ent;
302 end First_Stored_Discriminant;
304 -------------------
305 -- First_Subtype --
306 -------------------
308 function First_Subtype (Typ : Entity_Id) return Entity_Id is
309 B : constant Entity_Id := Base_Type (Typ);
310 F : constant Node_Id := Freeze_Node (B);
311 Ent : Entity_Id;
313 begin
314 -- If the base type has no freeze node, it is a type in Standard, and
315 -- always acts as its own first subtype, except where it is one of the
316 -- predefined integer types. If the type is formal, it is also a first
317 -- subtype, and its base type has no freeze node. On the other hand, a
318 -- subtype of a generic formal is not its own first subtype. Its base
319 -- type, if anonymous, is attached to the formal type decl. from which
320 -- the first subtype is obtained.
322 if No (F) then
323 if B = Base_Type (Standard_Integer) then
324 return Standard_Integer;
326 elsif B = Base_Type (Standard_Long_Integer) then
327 return Standard_Long_Integer;
329 elsif B = Base_Type (Standard_Short_Short_Integer) then
330 return Standard_Short_Short_Integer;
332 elsif B = Base_Type (Standard_Short_Integer) then
333 return Standard_Short_Integer;
335 elsif B = Base_Type (Standard_Long_Long_Integer) then
336 return Standard_Long_Long_Integer;
338 elsif Is_Generic_Type (Typ) then
339 if Present (Parent (B)) then
340 return Defining_Identifier (Parent (B));
341 else
342 return Defining_Identifier (Associated_Node_For_Itype (B));
343 end if;
345 else
346 return B;
347 end if;
349 -- Otherwise we check the freeze node, if it has a First_Subtype_Link
350 -- then we use that link, otherwise (happens with some Itypes), we use
351 -- the base type itself.
353 else
354 Ent := First_Subtype_Link (F);
356 if Present (Ent) then
357 return Ent;
358 else
359 return B;
360 end if;
361 end if;
362 end First_Subtype;
364 -------------------------
365 -- First_Tag_Component --
366 -------------------------
368 function First_Tag_Component (Typ : Entity_Id) return Entity_Id is
369 Comp : Entity_Id;
370 Ctyp : Entity_Id;
372 begin
373 Ctyp := Typ;
374 pragma Assert (Is_Tagged_Type (Ctyp));
376 if Is_Class_Wide_Type (Ctyp) then
377 Ctyp := Root_Type (Ctyp);
378 end if;
380 if Is_Private_Type (Ctyp) then
381 Ctyp := Underlying_Type (Ctyp);
383 -- If the underlying type is missing then the source program has
384 -- errors and there is nothing else to do (the full-type declaration
385 -- associated with the private type declaration is missing).
387 if No (Ctyp) then
388 return Empty;
389 end if;
390 end if;
392 Comp := First_Entity (Ctyp);
393 while Present (Comp) loop
394 if Is_Tag (Comp) then
395 return Comp;
396 end if;
398 Comp := Next_Entity (Comp);
399 end loop;
401 -- No tag component found
403 return Empty;
404 end First_Tag_Component;
406 ----------------
407 -- Initialize --
408 ----------------
410 procedure Initialize is
411 begin
412 Obsolescent_Warnings.Init;
413 end Initialize;
415 ---------------------
416 -- Is_By_Copy_Type --
417 ---------------------
419 function Is_By_Copy_Type (Ent : Entity_Id) return Boolean is
420 begin
421 -- If Id is a private type whose full declaration has not been seen,
422 -- we assume for now that it is not a By_Copy type. Clearly this
423 -- attribute should not be used before the type is frozen, but it is
424 -- needed to build the associated record of a protected type. Another
425 -- place where some lookahead for a full view is needed ???
427 return
428 Is_Elementary_Type (Ent)
429 or else (Is_Private_Type (Ent)
430 and then Present (Underlying_Type (Ent))
431 and then Is_Elementary_Type (Underlying_Type (Ent)));
432 end Is_By_Copy_Type;
434 --------------------------
435 -- Is_By_Reference_Type --
436 --------------------------
438 function Is_By_Reference_Type (Ent : Entity_Id) return Boolean is
439 Btype : constant Entity_Id := Base_Type (Ent);
441 begin
442 if Error_Posted (Ent)
443 or else Error_Posted (Btype)
444 then
445 return False;
447 elsif Is_Private_Type (Btype) then
448 declare
449 Utyp : constant Entity_Id := Underlying_Type (Btype);
450 begin
451 if No (Utyp) then
452 return False;
453 else
454 return Is_By_Reference_Type (Utyp);
455 end if;
456 end;
458 elsif Is_Incomplete_Type (Btype) then
459 declare
460 Ftyp : constant Entity_Id := Full_View (Btype);
461 begin
462 if No (Ftyp) then
463 return False;
464 else
465 return Is_By_Reference_Type (Ftyp);
466 end if;
467 end;
469 elsif Is_Concurrent_Type (Btype) then
470 return True;
472 elsif Is_Record_Type (Btype) then
473 if Is_Limited_Record (Btype)
474 or else Is_Tagged_Type (Btype)
475 or else Is_Volatile (Btype)
476 then
477 return True;
479 else
480 declare
481 C : Entity_Id;
483 begin
484 C := First_Component (Btype);
485 while Present (C) loop
486 if Is_By_Reference_Type (Etype (C))
487 or else Is_Volatile (Etype (C))
488 then
489 return True;
490 end if;
492 C := Next_Component (C);
493 end loop;
494 end;
496 return False;
497 end if;
499 elsif Is_Array_Type (Btype) then
500 return
501 Is_Volatile (Btype)
502 or else Is_By_Reference_Type (Component_Type (Btype))
503 or else Is_Volatile (Component_Type (Btype))
504 or else Has_Volatile_Components (Btype);
506 else
507 return False;
508 end if;
509 end Is_By_Reference_Type;
511 ---------------------
512 -- Is_Derived_Type --
513 ---------------------
515 function Is_Derived_Type (Ent : E) return B is
516 Par : Node_Id;
518 begin
519 if Is_Type (Ent)
520 and then Base_Type (Ent) /= Root_Type (Ent)
521 and then not Is_Class_Wide_Type (Ent)
522 then
523 if not Is_Numeric_Type (Root_Type (Ent)) then
524 return True;
526 else
527 Par := Parent (First_Subtype (Ent));
529 return Present (Par)
530 and then Nkind (Par) = N_Full_Type_Declaration
531 and then Nkind (Type_Definition (Par)) =
532 N_Derived_Type_Definition;
533 end if;
535 else
536 return False;
537 end if;
538 end Is_Derived_Type;
540 -----------------------
541 -- Is_Generic_Formal --
542 -----------------------
544 function Is_Generic_Formal (E : Entity_Id) return Boolean is
545 Kind : Node_Kind;
546 begin
547 if No (E) then
548 return False;
549 else
550 Kind := Nkind (Parent (E));
551 return
552 Nkind_In (Kind, N_Formal_Object_Declaration,
553 N_Formal_Package_Declaration,
554 N_Formal_Type_Declaration)
555 or else Is_Formal_Subprogram (E);
556 end if;
557 end Is_Generic_Formal;
559 ---------------------------
560 -- Is_Indefinite_Subtype --
561 ---------------------------
563 function Is_Indefinite_Subtype (Ent : Entity_Id) return Boolean is
564 K : constant Entity_Kind := Ekind (Ent);
566 begin
567 if Is_Constrained (Ent) then
568 return False;
570 elsif K in Array_Kind
571 or else K in Class_Wide_Kind
572 or else Has_Unknown_Discriminants (Ent)
573 then
574 return True;
576 -- Known discriminants: indefinite if there are no default values
578 elsif K in Record_Kind
579 or else Is_Incomplete_Or_Private_Type (Ent)
580 or else Is_Concurrent_Type (Ent)
581 then
582 return (Has_Discriminants (Ent)
583 and then
584 No (Discriminant_Default_Value (First_Discriminant (Ent))));
586 else
587 return False;
588 end if;
589 end Is_Indefinite_Subtype;
591 -------------------------------
592 -- Is_Immutably_Limited_Type --
593 -------------------------------
595 function Is_Immutably_Limited_Type (Ent : Entity_Id) return Boolean is
596 Btype : constant Entity_Id := Base_Type (Ent);
598 begin
599 if Is_Limited_Record (Btype) then
600 return True;
602 elsif Ekind (Btype) = E_Limited_Private_Type
603 and then Nkind (Parent (Btype)) = N_Formal_Type_Declaration
604 then
605 return not In_Package_Body (Scope ((Btype)));
606 end if;
608 if Is_Private_Type (Btype) then
610 -- AI05-0063: A type derived from a limited private formal type is
611 -- not immutably limited in a generic body.
613 if Is_Derived_Type (Btype)
614 and then Is_Generic_Type (Etype (Btype))
615 then
616 if not Is_Limited_Type (Etype (Btype)) then
617 return False;
619 -- A descendant of a limited formal type is not immutably limited
620 -- in the generic body, or in the body of a generic child.
622 elsif Ekind (Scope (Etype (Btype))) = E_Generic_Package then
623 return not In_Package_Body (Scope (Btype));
625 else
626 return False;
627 end if;
629 else
630 declare
631 Utyp : constant Entity_Id := Underlying_Type (Btype);
632 begin
633 if No (Utyp) then
634 return False;
635 else
636 return Is_Immutably_Limited_Type (Utyp);
637 end if;
638 end;
639 end if;
641 elsif Is_Concurrent_Type (Btype) then
642 return True;
644 elsif Is_Record_Type (Btype) then
646 -- Note that we return True for all limited interfaces, even though
647 -- (unsynchronized) limited interfaces can have descendants that are
648 -- nonlimited, because this is a predicate on the type itself, and
649 -- things like functions with limited interface results need to be
650 -- handled as build in place even though they might return objects
651 -- of a type that is not inherently limited.
653 if Is_Class_Wide_Type (Btype) then
654 return Is_Immutably_Limited_Type (Root_Type (Btype));
656 else
657 declare
658 C : Entity_Id;
660 begin
661 C := First_Component (Btype);
662 while Present (C) loop
664 -- Don't consider components with interface types (which can
665 -- only occur in the case of a _parent component anyway).
666 -- They don't have any components, plus it would cause this
667 -- function to return true for nonlimited types derived from
668 -- limited interfaces.
670 if not Is_Interface (Etype (C))
671 and then Is_Immutably_Limited_Type (Etype (C))
672 then
673 return True;
674 end if;
676 C := Next_Component (C);
677 end loop;
678 end;
680 return False;
681 end if;
683 elsif Is_Array_Type (Btype) then
684 return Is_Immutably_Limited_Type (Component_Type (Btype));
686 else
687 return False;
688 end if;
689 end Is_Immutably_Limited_Type;
691 ---------------------
692 -- Is_Limited_Type --
693 ---------------------
695 function Is_Limited_Type (Ent : Entity_Id) return Boolean is
696 Btype : constant E := Base_Type (Ent);
697 Rtype : constant E := Root_Type (Btype);
699 begin
700 if not Is_Type (Ent) then
701 return False;
703 elsif Ekind (Btype) = E_Limited_Private_Type
704 or else Is_Limited_Composite (Btype)
705 then
706 return True;
708 elsif Is_Concurrent_Type (Btype) then
709 return True;
711 -- The Is_Limited_Record flag normally indicates that the type is
712 -- limited. The exception is that a type does not inherit limitedness
713 -- from its interface ancestor. So the type may be derived from a
714 -- limited interface, but is not limited.
716 elsif Is_Limited_Record (Ent)
717 and then not Is_Interface (Ent)
718 then
719 return True;
721 -- Otherwise we will look around to see if there is some other reason
722 -- for it to be limited, except that if an error was posted on the
723 -- entity, then just assume it is non-limited, because it can cause
724 -- trouble to recurse into a murky erroneous entity!
726 elsif Error_Posted (Ent) then
727 return False;
729 elsif Is_Record_Type (Btype) then
731 if Is_Limited_Interface (Ent) then
732 return True;
734 -- AI-419: limitedness is not inherited from a limited interface
736 elsif Is_Limited_Record (Rtype) then
737 return not Is_Interface (Rtype)
738 or else Is_Protected_Interface (Rtype)
739 or else Is_Synchronized_Interface (Rtype)
740 or else Is_Task_Interface (Rtype);
742 elsif Is_Class_Wide_Type (Btype) then
743 return Is_Limited_Type (Rtype);
745 else
746 declare
747 C : E;
749 begin
750 C := First_Component (Btype);
751 while Present (C) loop
752 if Is_Limited_Type (Etype (C)) then
753 return True;
754 end if;
756 C := Next_Component (C);
757 end loop;
758 end;
760 return False;
761 end if;
763 elsif Is_Array_Type (Btype) then
764 return Is_Limited_Type (Component_Type (Btype));
766 else
767 return False;
768 end if;
769 end Is_Limited_Type;
771 ----------------------
772 -- Nearest_Ancestor --
773 ----------------------
775 function Nearest_Ancestor (Typ : Entity_Id) return Entity_Id is
776 D : constant Node_Id := Declaration_Node (Typ);
778 begin
779 -- If we have a subtype declaration, get the ancestor subtype
781 if Nkind (D) = N_Subtype_Declaration then
782 if Nkind (Subtype_Indication (D)) = N_Subtype_Indication then
783 return Entity (Subtype_Mark (Subtype_Indication (D)));
784 else
785 return Entity (Subtype_Indication (D));
786 end if;
788 -- If derived type declaration, find who we are derived from
790 elsif Nkind (D) = N_Full_Type_Declaration
791 and then Nkind (Type_Definition (D)) = N_Derived_Type_Definition
792 then
793 declare
794 DTD : constant Entity_Id := Type_Definition (D);
795 SI : constant Entity_Id := Subtype_Indication (DTD);
796 begin
797 if Is_Entity_Name (SI) then
798 return Entity (SI);
799 else
800 return Entity (Subtype_Mark (SI));
801 end if;
802 end;
804 -- Otherwise, nothing useful to return, return Empty
806 else
807 return Empty;
808 end if;
809 end Nearest_Ancestor;
811 ---------------------------
812 -- Nearest_Dynamic_Scope --
813 ---------------------------
815 function Nearest_Dynamic_Scope (Ent : Entity_Id) return Entity_Id is
816 begin
817 if Is_Dynamic_Scope (Ent) then
818 return Ent;
819 else
820 return Enclosing_Dynamic_Scope (Ent);
821 end if;
822 end Nearest_Dynamic_Scope;
824 ------------------------
825 -- Next_Tag_Component --
826 ------------------------
828 function Next_Tag_Component (Tag : Entity_Id) return Entity_Id is
829 Comp : Entity_Id;
831 begin
832 pragma Assert (Is_Tag (Tag));
834 -- Loop to look for next tag component
836 Comp := Next_Entity (Tag);
837 while Present (Comp) loop
838 if Is_Tag (Comp) then
839 pragma Assert (Chars (Comp) /= Name_uTag);
840 return Comp;
841 end if;
843 Comp := Next_Entity (Comp);
844 end loop;
846 -- No tag component found
848 return Empty;
849 end Next_Tag_Component;
851 --------------------------
852 -- Number_Discriminants --
853 --------------------------
855 function Number_Discriminants (Typ : Entity_Id) return Pos is
856 N : Int;
857 Discr : Entity_Id;
859 begin
860 N := 0;
861 Discr := First_Discriminant (Typ);
862 while Present (Discr) loop
863 N := N + 1;
864 Discr := Next_Discriminant (Discr);
865 end loop;
867 return N;
868 end Number_Discriminants;
870 ---------------
871 -- Tree_Read --
872 ---------------
874 procedure Tree_Read is
875 begin
876 Obsolescent_Warnings.Tree_Read;
877 end Tree_Read;
879 ----------------
880 -- Tree_Write --
881 ----------------
883 procedure Tree_Write is
884 begin
885 Obsolescent_Warnings.Tree_Write;
886 end Tree_Write;
888 --------------------
889 -- Ultimate_Alias --
890 --------------------
892 function Ultimate_Alias (Prim : Entity_Id) return Entity_Id is
893 E : Entity_Id := Prim;
895 begin
896 while Present (Alias (E)) loop
897 pragma Assert (Alias (E) /= E);
898 E := Alias (E);
899 end loop;
901 return E;
902 end Ultimate_Alias;
904 end Sem_Aux;