1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1998-2024, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Atree
; use Atree
;
27 with Csets
; use Csets
;
28 with Einfo
; use Einfo
;
29 with Einfo
.Utils
; use Einfo
.Utils
;
30 with Elists
; use Elists
;
31 with Errout
; use Errout
;
32 with Exp_Tss
; use Exp_Tss
;
33 with Lib
.Util
; use Lib
.Util
;
34 with Nlists
; use Nlists
;
36 with Restrict
; use Restrict
;
37 with Rident
; use Rident
;
39 with Sem_Aux
; use Sem_Aux
;
40 with Sem_Prag
; use Sem_Prag
;
41 with Sem_Util
; use Sem_Util
;
42 with Sem_Warn
; use Sem_Warn
;
43 with Sinfo
; use Sinfo
;
44 with Sinfo
.Nodes
; use Sinfo
.Nodes
;
45 with Sinfo
.Utils
; use Sinfo
.Utils
;
46 with Sinput
; use Sinput
;
47 with Snames
; use Snames
;
48 with Stringt
; use Stringt
;
49 with Stand
; use Stand
;
50 with Table
; use Table
;
51 with Warnsw
; use Warnsw
;
53 with GNAT
.Heap_Sort_G
;
56 package body Lib
.Xref
is
62 -- The Xref table is used to record references. The Loc field is set
63 -- to No_Location for a definition entry.
65 subtype Xref_Entry_Number
is Int
;
67 type Xref_Key
is record
68 -- These are the components of Xref_Entry that participate in hash
72 -- Entity referenced (E parameter to Generate_Reference)
75 -- Location of reference (Original_Location (Sloc field of N parameter
76 -- to Generate_Reference)). Set to No_Location for the case of a
77 -- defining occurrence.
80 -- Reference type (Typ param to Generate_Reference)
82 Eun
: Unit_Number_Type
;
83 -- Unit number corresponding to Ent
85 Lun
: Unit_Number_Type
;
86 -- Unit number corresponding to Loc. Value is undefined and not
87 -- referenced if Loc is set to No_Location.
89 -- The following components are only used for SPARK cross-references
91 Ref_Scope
: Entity_Id
;
92 -- Entity of the closest subprogram or package enclosing the reference
94 Ent_Scope
: Entity_Id
;
95 -- Entity of the closest subprogram or package enclosing the definition,
96 -- which should be located in the same file as the definition itself.
99 type Xref_Entry
is record
102 Ent_Scope_File
: Unit_Number_Type
;
103 -- File for entity Ent_Scope
106 -- Original source location for entity being referenced. Note that these
107 -- values are used only during the output process, they are not set when
108 -- the entries are originally built. This is because private entities
109 -- can be swapped when the initial call is made.
111 HTable_Next
: Xref_Entry_Number
;
112 -- For use only by Static_HTable
115 package Xrefs
is new Table
.Table
(
116 Table_Component_Type
=> Xref_Entry
,
117 Table_Index_Type
=> Xref_Entry_Number
,
118 Table_Low_Bound
=> 1,
119 Table_Initial
=> Alloc
.Xrefs_Initial
,
120 Table_Increment
=> Alloc
.Xrefs_Increment
,
121 Table_Name
=> "Xrefs");
127 -- We keep a set of xref entries, in order to avoid inserting duplicate
128 -- entries into the above Xrefs table. An entry is in Xref_Set if and only
129 -- if it is in Xrefs.
131 Num_Buckets
: constant := 2**16;
133 subtype Header_Num
is Integer range 0 .. Num_Buckets
- 1;
134 type Null_Type
is null record;
135 pragma Unreferenced
(Null_Type
);
137 function Hash
(F
: Xref_Entry_Number
) return Header_Num
;
139 function Equal
(F1
, F2
: Xref_Entry_Number
) return Boolean;
141 procedure HT_Set_Next
(E
: Xref_Entry_Number
; Next
: Xref_Entry_Number
);
143 function HT_Next
(E
: Xref_Entry_Number
) return Xref_Entry_Number
;
145 function Get_Key
(E
: Xref_Entry_Number
) return Xref_Entry_Number
;
147 pragma Inline
(Hash
, Equal
, HT_Set_Next
, HT_Next
, Get_Key
);
149 package Xref_Set
is new GNAT
.HTable
.Static_HTable
(
151 Element
=> Xref_Entry
,
152 Elmt_Ptr
=> Xref_Entry_Number
,
154 Set_Next
=> HT_Set_Next
,
156 Key
=> Xref_Entry_Number
,
161 -----------------------------
162 -- SPARK Xrefs Information --
163 -----------------------------
165 package body SPARK_Specific
is separate;
167 ------------------------
168 -- Local Subprograms --
169 ------------------------
171 procedure Add_Entry
(Key
: Xref_Key
; Ent_Scope_File
: Unit_Number_Type
);
172 -- Add an entry to the tables of Xref_Entries, avoiding duplicates
174 procedure Generate_Prim_Op_References
(Typ
: Entity_Id
);
175 -- For a tagged type, generate implicit references to its primitive
176 -- operations, for source navigation. This is done right before emitting
177 -- cross-reference information rather than at the freeze point of the type
178 -- in order to handle late bodies that are primitive operations.
180 function Lt
(T1
, T2
: Xref_Entry
) return Boolean;
181 -- Order cross-references
187 procedure Add_Entry
(Key
: Xref_Key
; Ent_Scope_File
: Unit_Number_Type
) is
189 Xrefs
.Increment_Last
; -- tentative
190 Xrefs
.Table
(Xrefs
.Last
).Key
:= Key
;
192 -- Set the entry in Xref_Set, and if newly set, keep the above
193 -- tentative increment.
195 if Xref_Set
.Set_If_Not_Present
(Xrefs
.Last
) then
196 Xrefs
.Table
(Xrefs
.Last
).Ent_Scope_File
:= Ent_Scope_File
;
197 -- Leave Def and HTable_Next uninitialized
199 Set_Has_Xref_Entry
(Key
.Ent
);
201 -- It was already in Xref_Set, so throw away the tentatively-added entry
204 Xrefs
.Decrement_Last
;
212 function Equal
(F1
, F2
: Xref_Entry_Number
) return Boolean is
213 Result
: constant Boolean :=
214 Xrefs
.Table
(F1
).Key
= Xrefs
.Table
(F2
).Key
;
219 -------------------------
220 -- Generate_Definition --
221 -------------------------
223 procedure Generate_Definition
(E
: Entity_Id
) is
225 pragma Assert
(Nkind
(E
) in N_Entity
);
227 -- Note that we do not test Xref_Entity_Letters here. It is too early
228 -- to do so, since we are often called before the entity is fully
229 -- constructed, so that the Ekind is still E_Void.
233 -- Definition must come from source
235 -- We make an exception for subprogram child units that have no spec.
236 -- For these we generate a subprogram declaration for library use,
237 -- and the corresponding entity does not come from source.
238 -- Nevertheless, all references will be attached to it and we have
239 -- to treat is as coming from user code.
241 and then (Comes_From_Source
(E
) or else Is_Child_Unit
(E
))
243 -- And must have a reasonable source location that is not
244 -- within an instance (all entities in instances are ignored)
246 and then Sloc
(E
) > No_Location
247 and then Instantiation_Location
(Sloc
(E
)) = No_Location
249 -- And must be a non-internal name from the main source unit
251 and then In_Extended_Main_Source_Unit
(E
)
252 and then not Is_Internal_Name
(Chars
(E
))
258 Eun
=> Get_Source_Unit
(Original_Location
(Sloc
(E
))),
262 Ent_Scope_File
=> No_Unit
);
264 if In_Inlined_Body
then
268 end Generate_Definition
;
270 ---------------------------------
271 -- Generate_Operator_Reference --
272 ---------------------------------
274 procedure Generate_Operator_Reference
279 if not In_Extended_Main_Source_Unit
(N
) then
283 -- If the operator is not a Standard operator, then we generate a real
284 -- reference to the user defined operator.
286 if Sloc
(Entity
(N
)) /= Standard_Location
then
287 Generate_Reference
(Entity
(N
), N
);
289 -- A reference to an implicit inequality operator is also a reference
290 -- to the user-defined equality.
292 if Nkind
(N
) = N_Op_Ne
293 and then not Comes_From_Source
(Entity
(N
))
294 and then Present
(Corresponding_Equality
(Entity
(N
)))
296 Generate_Reference
(Corresponding_Equality
(Entity
(N
)), N
);
299 -- For the case of Standard operators, we mark the result type as
300 -- referenced. This ensures that in the case where we are using a
301 -- derived operator, we mark an entity of the unit that implicitly
302 -- defines this operator as used. Otherwise we may think that no entity
303 -- of the unit is used. The actual entity marked as referenced is the
304 -- first subtype, which is the relevant user defined entity.
306 -- Note: we only do this for operators that come from source. The
307 -- generated code sometimes reaches for entities that do not need to be
308 -- explicitly visible (for example, when we expand the code for
309 -- comparing two record objects, the fields of the record may not be
312 elsif Comes_From_Source
(N
) then
313 Set_Referenced
(First_Subtype
(T
));
315 end Generate_Operator_Reference
;
317 ---------------------------------
318 -- Generate_Prim_Op_References --
319 ---------------------------------
321 procedure Generate_Prim_Op_References
(Typ
: Entity_Id
) is
324 Prim_List
: Elist_Id
;
327 -- Handle subtypes of synchronized types
329 if Ekind
(Typ
) = E_Protected_Subtype
330 or else Ekind
(Typ
) = E_Task_Subtype
332 Base_T
:= Etype
(Typ
);
337 -- References to primitive operations are only relevant for tagged types
339 if not Is_Tagged_Type
(Base_T
)
340 or else Is_Class_Wide_Type
(Base_T
)
345 -- Ada 2005 (AI-345): For synchronized types generate reference to the
346 -- wrapper that allow us to dispatch calls through their implemented
347 -- abstract interface types.
349 -- The check for Present here is to protect against previously reported
352 Prim_List
:= Primitive_Operations
(Base_T
);
354 if No
(Prim_List
) then
358 Prim
:= First_Elmt
(Prim_List
);
359 while Present
(Prim
) loop
361 -- If the operation is derived, get the original for cross-reference
362 -- reference purposes (it is the original for which we want the xref
363 -- and for which the comes_from_source test must be performed).
366 (Typ
, Ultimate_Alias
(Node
(Prim
)), 'p', Set_Ref
=> False);
369 end Generate_Prim_Op_References
;
371 ------------------------
372 -- Generate_Reference --
373 ------------------------
375 procedure Generate_Reference
378 Typ
: Character := 'r';
379 Set_Ref
: Boolean := True;
380 Force
: Boolean := False)
382 Actual_Typ
: Character := Typ
;
386 Ent_Scope
: Entity_Id
;
391 Ref_Scope
: Entity_Id
;
393 function Get_Through_Renamings
(E
: Entity_Id
) return Entity_Id
;
394 -- Get the enclosing entity through renamings, which may come from
395 -- source or from the translation of generic instantiations.
397 function OK_To_Set_Referenced
return Boolean;
398 -- Returns True if the Referenced flag can be set. There are a few
399 -- exceptions where we do not want to set this flag, see body for
400 -- details of these exceptional cases.
402 ---------------------------
403 -- Get_Through_Renamings --
404 ---------------------------
406 function Get_Through_Renamings
(E
: Entity_Id
) return Entity_Id
is
410 -- For subprograms we just need to check once if they are have a
411 -- Renamed_Entity, because Renamed_Entity is set transitively.
413 when Subprogram_Kind
=>
415 Renamed
: constant Entity_Id
:= Renamed_Entity
(E
);
418 if Present
(Renamed
) then
425 -- For objects we need to repeatedly call Renamed_Object, because
426 -- it is not transitive.
430 Obj
: Entity_Id
:= E
;
434 pragma Assert
(Present
(Obj
));
437 Renamed
: constant Entity_Id
:= Renamed_Object
(Obj
);
440 if Present
(Renamed
) then
441 Obj
:= Get_Enclosing_Object
(Renamed
);
443 -- The renamed expression denotes a non-object,
444 -- e.g. function call, slicing of a function call,
445 -- pointer dereference, etc.
448 or else Ekind
(Obj
) = E_Enumeration_Literal
463 end Get_Through_Renamings
;
465 ---------------------------
466 -- OK_To_Set_Referenced --
467 ---------------------------
469 function OK_To_Set_Referenced
return Boolean is
473 -- A reference from a pragma Unreferenced or pragma Unmodified or
474 -- pragma Warnings does not cause the Referenced flag to be set.
475 -- This avoids silly warnings about things being referenced and
476 -- not assigned when the only reference is from the pragma.
478 if Nkind
(N
) = N_Identifier
then
481 if Nkind
(P
) = N_Pragma_Argument_Association
then
484 if Nkind
(P
) = N_Pragma
then
485 if Pragma_Name_Unmapped
(P
) in Name_Warnings
493 -- A reference to a formal in a named parameter association does
494 -- not make the formal referenced. Formals that are unused in the
495 -- subprogram body are properly flagged as such, even if calls
496 -- elsewhere use named notation.
498 elsif Nkind
(P
) = N_Parameter_Association
499 and then N
= Selector_Name
(P
)
506 end OK_To_Set_Referenced
;
508 -- Start of processing for Generate_Reference
511 -- If Get_Ignore_Errors, then we are in Preanalyze_Without_Errors, and
512 -- we should not record cross references, because that will cause
513 -- duplicates when we call Analyze.
515 if Get_Ignore_Errors
then
519 -- May happen in case of severe errors
521 if Nkind
(E
) not in N_Entity
then
525 Find_Actual
(N
, Formal
, Call
);
527 if Present
(Formal
) then
528 Kind
:= Ekind
(Formal
);
533 -- Check for obsolescent reference to package ASCII. GNAT treats this
534 -- element of annex J specially since in practice, programs make a lot
535 -- of use of this feature, so we don't include it in the set of features
536 -- diagnosed when Warn_On_Obsolescent_Features mode is set. However we
537 -- are required to note it as a violation of the RM defined restriction.
539 if E
= Standard_ASCII
then
540 Check_Restriction
(No_Obsolescent_Features
, N
);
543 -- Check for reference to entity marked with Is_Obsolescent
545 -- Note that we always allow obsolescent references in the compiler
546 -- itself and the run time, since we assume that we know what we are
547 -- doing in such cases. For example the calls in Ada.Characters.Handling
548 -- to its own obsolescent subprograms are just fine.
550 -- In any case we only generate warnings if we are in the extended main
551 -- source unit, and the entity itself is not in the extended main source
552 -- unit, since we assume the source unit itself knows what is going on
553 -- (and for sure we do not want silly warnings, e.g. on the end line of
554 -- an obsolescent procedure body).
556 if Is_Obsolescent
(E
)
557 and then not GNAT_Mode
558 and then not In_Extended_Main_Source_Unit
(E
)
559 and then In_Extended_Main_Source_Unit
(N
)
561 Check_Restriction
(No_Obsolescent_Features
, N
);
563 if Warn_On_Obsolescent_Feature
then
564 Output_Obsolescent_Entity_Warnings
(N
, E
);
568 -- Warn if reference to Ada 2005 entity not in Ada 2005 mode. We only
569 -- detect real explicit references (modifications and references).
571 if Comes_From_Source
(N
)
572 and then Is_Ada_2005_Only
(E
)
573 and then Ada_Version
< Ada_2005
574 and then Warn_On_Ada_2005_Compatibility
575 and then (Typ
= 'm' or else Typ
= 'r' or else Typ
= 's')
577 Error_Msg_NE
("& is only defined in Ada 2005?y?", N
, E
);
580 -- Warn if reference to Ada 2012 entity not in Ada 2012 mode. We only
581 -- detect real explicit references (modifications and references).
583 if Comes_From_Source
(N
)
584 and then Is_Ada_2012_Only
(E
)
585 and then Ada_Version
< Ada_2012
586 and then Warn_On_Ada_2012_Compatibility
587 and then (Typ
= 'm' or else Typ
= 'r')
589 Error_Msg_NE
("& is only defined in Ada 2012?y?", N
, E
);
592 -- Warn if reference to Ada 2022 entity not in Ada 2022 mode. We only
593 -- detect real explicit references (modifications and references).
595 if Comes_From_Source
(N
)
596 and then Is_Ada_2022_Only
(E
)
597 and then not Is_Subprogram
(E
)
598 and then Ada_Version
< Ada_2022
599 and then Warn_On_Ada_2022_Compatibility
600 and then (Typ
= 'm' or else Typ
= 'r')
602 Error_Msg_NE
("& is only defined in Ada 2022?y?", N
, E
);
604 -- Error on static and dispatching calls to Ada 2022 subprograms that
605 -- require overriding if we are not in Ada 2022 mode (since overriding
606 -- was skipped); warn if the subprogram does not require overriding.
608 elsif Comes_From_Source
(N
)
609 and then Is_Ada_2022_Only
(E
)
610 and then Ada_Version
< Ada_2022
611 and then Is_Subprogram
(E
)
612 and then (Typ
= 'r' or else Typ
= 's' or else Typ
= 'R')
614 if Requires_Overriding
(E
) then
616 ("& is only defined in Ada 2022 and requires overriding", N
, E
);
618 elsif Warn_On_Ada_2022_Compatibility
then
619 Error_Msg_NE
("& is only defined in Ada 2022?y?", N
, E
);
623 -- Never collect references if not in main source unit. However, we omit
624 -- this test if Typ is 'e' or 'k', since these entries are structural,
625 -- and it is useful to have them in units that reference packages as
626 -- well as units that define packages. We also omit the test for the
627 -- case of 'p' since we want to include inherited primitive operations
628 -- from other packages.
630 -- We also omit this test is this is a body reference for a subprogram
631 -- instantiation. In this case the reference is to the generic body,
632 -- which clearly need not be in the main unit containing the instance.
633 -- For the same reason we accept an implicit reference generated for
634 -- a default in an instance.
636 -- We also set the referenced flag in a generic package that is not in
637 -- the main source unit, when the object is of a formal private type,
638 -- to warn in the instance if the corresponding type is not a fully
641 if not In_Extended_Main_Source_Unit
(N
) then
647 or else (Typ
= 'b' and then Is_Generic_Instance
(E
))
649 -- Allow the generation of references to reads, writes and calls
650 -- in SPARK mode when the related context comes from an instance.
654 and then In_Extended_Main_Code_Unit
(N
)
655 and then (Typ
= 'm' or else Typ
= 'r' or else Typ
= 's'))
659 elsif In_Instance_Body
660 and then In_Extended_Main_Code_Unit
(N
)
661 and then Is_Generic_Type
(Etype
(E
))
666 elsif Inside_A_Generic
667 and then Is_Object
(E
)
668 and then Is_Generic_Type
(Etype
(E
))
678 -- For reference type p, the entity must be in main source unit
680 if Typ
= 'p' and then not In_Extended_Main_Source_Unit
(E
) then
684 -- Unless the reference is forced, we ignore references where the
685 -- reference itself does not come from source.
687 if not Force
and then not Comes_From_Source
(N
) then
691 -- Deal with setting entity as referenced, unless suppressed. Note that
692 -- we still do Set_Referenced on entities that do not come from source.
693 -- This situation arises when we have a source reference to a derived
694 -- operation, where the derived operation itself does not come from
695 -- source, but we still want to mark it as referenced, since we really
696 -- are referencing an entity in the corresponding package (this avoids
697 -- wrong complaints that the package contains no referenced entities).
701 -- When E itself is an IN OUT parameter mark it referenced
704 and then Ekind
(E
) = E_In_Out_Parameter
705 and then Known_To_Be_Assigned
(N
)
709 -- For the case where the entity is on the left hand side of an
710 -- assignment statement, we do nothing here.
712 -- The processing for Analyze_Assignment_Statement will set the
713 -- Referenced_As_LHS flag.
715 elsif Is_Assignable
(E
)
716 and then Known_To_Be_Assigned
(N
, Only_LHS
=> True)
720 -- For objects that are renamings, just set as simply referenced.
721 -- We do not try to do assignment type tracking in this case.
723 elsif Is_Assignable
(E
)
724 and then Present
(Renamed_Object
(E
))
728 -- Check for a reference in a pragma that should not count as a
729 -- making the variable referenced for warning purposes.
731 elsif Is_Non_Significant_Pragma_Reference
(N
) then
734 -- A reference in an attribute definition clause does not count as a
735 -- reference except for the case of Address. The reason that 'Address
736 -- is an exception is that it creates an alias through which the
737 -- variable may be referenced.
739 elsif Nkind
(Parent
(N
)) = N_Attribute_Definition_Clause
740 and then Chars
(Parent
(N
)) /= Name_Address
741 and then N
= Name
(Parent
(N
))
745 -- Constant completion does not count as a reference
748 and then Ekind
(E
) = E_Constant
752 -- Record representation clause does not count as a reference
754 elsif Nkind
(N
) = N_Identifier
755 and then Nkind
(Parent
(N
)) = N_Record_Representation_Clause
759 -- Discriminants do not need to produce a reference to record type
762 and then Nkind
(Parent
(N
)) = N_Discriminant_Specification
766 -- Out parameter case
768 elsif Kind
= E_Out_Parameter
769 and then Is_Assignable
(E
)
771 -- If warning mode for all out parameters is set, or this is
772 -- the only warning parameter, then we want to mark this for
773 -- later warning logic by setting Referenced_As_Out_Parameter
775 if Warn_On_Modified_As_Out_Parameter
(Formal
) then
776 Set_Referenced_As_Out_Parameter
(E
, True);
777 Set_Referenced_As_LHS
(E
, False);
779 -- For OUT parameter not covered by the above cases, we simply
780 -- regard it as a reference.
783 Set_Referenced_As_Out_Parameter
(E
);
787 -- Special processing for IN OUT parameters, where we have an
788 -- implicit assignment to a simple variable.
790 elsif Kind
= E_In_Out_Parameter
791 and then Is_Assignable
(E
)
793 -- We count it as a read reference unless we're calling a
794 -- type support subprogram such as deep finalize.
796 if not Is_Entity_Name
(Name
(Call
))
797 or else Get_TSS_Name
(Entity
(Name
(Call
))) = TSS_Null
800 Set_Last_Assignment
(E
, Empty
);
803 -- We count it as being referenced as an out parameter if the
804 -- option is set to warn on all out parameters, except that we
805 -- have a special exclusion for an intrinsic subprogram, which
806 -- is most likely an instantiation of Unchecked_Deallocation
807 -- which we do not want to consider as an assignment since it
808 -- generates false positives. We also exclude the case of an
809 -- IN OUT parameter if the name of the procedure is Free,
810 -- since we suspect similar semantics.
812 if Warn_On_All_Unread_Out_Parameters
813 and then Is_Entity_Name
(Name
(Call
))
814 and then not Is_Intrinsic_Subprogram
(Entity
(Name
(Call
)))
815 and then Chars
(Name
(Call
)) /= Name_Free
817 Set_Referenced_As_Out_Parameter
(E
, True);
818 Set_Referenced_As_LHS
(E
, False);
821 -- Don't count a recursive reference within a subprogram as a
822 -- reference (that allows detection of a recursive subprogram
823 -- whose only references are recursive calls as unreferenced).
825 elsif Is_Subprogram
(E
)
826 and then E
= Nearest_Dynamic_Scope
(Current_Scope
)
830 -- Any other occurrence counts as referencing the entity
832 elsif OK_To_Set_Referenced
then
835 -- If variable, this is an OK reference after an assignment
836 -- so we can clear the Last_Assignment indication.
838 if Is_Assignable
(E
) then
839 Set_Last_Assignment
(E
, Empty
);
843 -- Check for pragma Unreferenced given and reference is within
844 -- this source unit (occasion for possible warning to be issued).
845 -- Note that the entity may be marked as unreferenced by pragma
848 if Has_Unreferenced
(E
)
849 and then In_Same_Extended_Unit
(E
, N
)
851 -- A reference as a named parameter in a call does not count as a
852 -- violation of pragma Unreferenced for this purpose.
854 if Nkind
(N
) = N_Identifier
855 and then Nkind
(Parent
(N
)) = N_Parameter_Association
856 and then Selector_Name
(Parent
(N
)) = N
860 -- Neither does a reference to a variable on the left side of
861 -- an assignment or use of an out parameter with warnings for
862 -- unread out parameters specified (via -gnatw.o).
864 -- The reason for treating unread out parameters in a special
865 -- way is so that when pragma Unreferenced is specified on such
866 -- an out parameter we do not want to issue a warning about the
867 -- pragma being unnecessary - because the purpose of the flag
868 -- is to warn about them not being read (e.g. unreferenced)
871 elsif (Known_To_Be_Assigned
(N
, Only_LHS
=> True)
872 or else (Present
(Formal
)
873 and then Ekind
(Formal
) = E_Out_Parameter
874 and then Warn_On_All_Unread_Out_Parameters
))
875 and then not (Ekind
(E
) = E_In_Out_Parameter
876 and then Known_To_Be_Assigned
(N
))
880 -- Do not consider F'Result as a violation of pragma Unreferenced
881 -- since the attribute acts as an anonymous alias of the function
882 -- result and not as a real reference to the function.
884 elsif Ekind
(E
) in E_Function | E_Generic_Function
885 and then Is_Entity_Name
(N
)
886 and then Is_Attribute_Result
(Parent
(N
))
890 -- No warning if the reference is in a call that does not come
891 -- from source (e.g. a call to a controlled type primitive).
893 elsif not Comes_From_Source
(Parent
(N
))
894 and then Nkind
(Parent
(N
)) = N_Procedure_Call_Statement
898 -- For entry formals, we want to place the warning message on the
899 -- corresponding entity in the accept statement. The current scope
900 -- is the body of the accept, so we find the formal whose name
901 -- matches that of the entry formal (there is no link between the
902 -- two entities, and the one in the accept statement is only used
903 -- for conformance checking).
905 elsif Ekind
(Scope
(E
)) = E_Entry
then
910 BE
:= First_Entity
(Current_Scope
);
911 while Present
(BE
) loop
912 if Chars
(BE
) = Chars
(E
) then
913 if Has_Pragma_Unused
(E
) then
914 Error_Msg_NE
-- CODEFIX
915 ("??aspect Unused specified for&!", N
, BE
);
917 Error_Msg_NE
-- CODEFIX
918 ("??aspect Unreferenced specified for&!", N
, BE
);
927 -- Here we issue the warning, since this is a real reference
929 elsif Has_Pragma_Unused
(E
) then
930 Error_Msg_NE
-- CODEFIX
931 ("??aspect Unused specified for&!", N
, E
);
933 Error_Msg_NE
-- CODEFIX
934 ("??aspect Unreferenced specified for&!", N
, E
);
938 -- If this is a subprogram instance, mark as well the internal
939 -- subprogram in the wrapper package, which may be a visible
942 if Is_Overloadable
(E
)
943 and then Is_Generic_Instance
(E
)
944 and then Present
(Alias
(E
))
946 Set_Referenced
(Alias
(E
));
950 -- Generate reference if all conditions are met:
953 -- Cross referencing must be active
957 -- The entity must be one for which we collect references
959 and then Xref_Entity_Letters
(Ekind
(E
)) /= ' '
961 -- Both Sloc values must be set to something sensible
963 and then Sloc
(E
) > No_Location
964 and then Sloc
(N
) > No_Location
966 -- Ignore references from within an instance. The only exceptions to
967 -- this are default subprograms, for which we generate an implicit
968 -- reference and compilations in SPARK mode.
971 (Instantiation_Location
(Sloc
(N
)) = No_Location
973 or else GNATprove_Mode
)
975 -- Ignore dummy references
979 if Nkind
(N
) in N_Identifier
980 | N_Defining_Identifier
981 | N_Defining_Operator_Symbol
983 | N_Defining_Character_Literal
985 or else (Nkind
(N
) = N_Character_Literal
986 and then Sloc
(Entity
(N
)) /= Standard_Location
)
990 elsif Nkind
(N
) in N_Expanded_Name | N_Selected_Component
then
991 Nod
:= Selector_Name
(N
);
997 -- Normal case of source entity comes from source
999 if Comes_From_Source
(E
) then
1002 -- Because a declaration may be generated for a subprogram body
1003 -- without declaration in GNATprove mode, for inlining, some
1004 -- parameters may end up being marked as not coming from source
1005 -- although they are. Take these into account specially.
1007 elsif GNATprove_Mode
and then Is_Formal
(E
) then
1010 -- Entity does not come from source, but is a derived subprogram and
1011 -- the derived subprogram comes from source (after one or more
1012 -- derivations) in which case the reference is to parent subprogram.
1014 elsif Is_Overloadable
(E
)
1015 and then Present
(Alias
(E
))
1018 while not Comes_From_Source
(Ent
) loop
1019 if No
(Alias
(Ent
)) then
1026 -- The internally created defining entity for a child subprogram
1027 -- that has no previous spec has valid references.
1029 elsif Is_Overloadable
(E
)
1030 and then Is_Child_Unit
(E
)
1034 -- Ditto for the formals of such a subprogram
1036 elsif Is_Overloadable
(Scope
(E
))
1037 and then Is_Child_Unit
(Scope
(E
))
1041 -- Record components of discriminated subtypes or derived types must
1042 -- be treated as references to the original component.
1044 elsif Ekind
(E
) = E_Component
1045 and then Comes_From_Source
(Original_Record_Component
(E
))
1047 Ent
:= Original_Record_Component
(E
);
1049 -- If this is an expanded reference to a discriminant, recover the
1050 -- original discriminant, which gets the reference.
1052 elsif Ekind
(E
) = E_In_Parameter
1053 and then Present
(Discriminal_Link
(E
))
1055 Ent
:= Discriminal_Link
(E
);
1056 Set_Referenced
(Ent
);
1058 -- Ignore reference to any other entity that is not from source
1064 -- In SPARK mode, consider the underlying entity renamed instead of
1065 -- the renaming, which is needed to compute a valid set of effects
1066 -- (reads, writes) for the enclosing subprogram.
1068 if GNATprove_Mode
then
1069 Ent
:= Get_Through_Renamings
(Ent
);
1071 -- If no enclosing object, then it could be a reference to any
1072 -- location not tracked individually, like heap-allocated data.
1073 -- Conservatively approximate this possibility by generating a
1074 -- dereference, and return.
1077 if Actual_Typ
= 'w' then
1078 SPARK_Specific
.Generate_Dereference
(Nod
, 'r');
1079 SPARK_Specific
.Generate_Dereference
(Nod
, 'w');
1081 SPARK_Specific
.Generate_Dereference
(Nod
, 'r');
1088 -- Record reference to entity
1091 and then Is_Subprogram
(Nod
)
1092 and then Present
(Overridden_Operation
(Nod
))
1097 -- Comment needed here for special SPARK code ???
1099 if GNATprove_Mode
then
1101 -- Ignore references to an entity which is a Part_Of single
1102 -- concurrent object. Ideally we would prefer to add it as a
1103 -- reference to the corresponding concurrent type, but it is quite
1104 -- difficult (as such references are not currently added even for)
1105 -- reads/writes of private protected components) and not worth the
1108 if Ekind
(Ent
) in E_Abstract_State | E_Constant | E_Variable
1109 and then Present
(Encapsulating_State
(Ent
))
1110 and then Is_Single_Concurrent_Object
(Encapsulating_State
(Ent
))
1119 SPARK_Specific
.Enclosing_Subprogram_Or_Library_Package
(Nod
);
1121 SPARK_Specific
.Enclosing_Subprogram_Or_Library_Package
(Ent
);
1123 -- Since we are reaching through renamings in SPARK mode, we may
1124 -- end up with standard constants. Ignore those.
1126 if Sloc
(Ent_Scope
) <= Standard_Location
1127 or else Def
<= Standard_Location
1136 Eun
=> Get_Top_Level_Code_Unit
(Def
),
1137 Lun
=> Get_Top_Level_Code_Unit
(Ref
),
1138 Ref_Scope
=> Ref_Scope
,
1139 Ent_Scope
=> Ent_Scope
),
1140 Ent_Scope_File
=> Get_Top_Level_Code_Unit
(Ent
));
1143 Ref
:= Original_Location
(Sloc
(Nod
));
1144 Def
:= Original_Location
(Sloc
(Ent
));
1146 -- If this is an operator symbol, skip the initial quote for
1147 -- navigation purposes. This is not done for the end label,
1148 -- where we want the actual position after the closing quote.
1153 elsif Nkind
(N
) = N_Defining_Operator_Symbol
1154 or else Nkind
(Nod
) = N_Operator_Symbol
1163 Eun
=> Get_Source_Unit
(Def
),
1164 Lun
=> Get_Source_Unit
(Ref
),
1166 Ent_Scope
=> Empty
),
1167 Ent_Scope_File
=> No_Unit
);
1169 -- Generate reference to the first private entity
1172 and then Comes_From_Source
(E
)
1173 and then Nkind
(Ent
) = N_Defining_Identifier
1174 and then (Is_Package_Or_Generic_Package
(Ent
)
1175 or else Is_Concurrent_Type
(Ent
))
1176 and then Present
(First_Private_Entity
(E
))
1177 and then In_Extended_Main_Source_Unit
(N
)
1179 -- Handle case in which the full-view and partial-view of the
1180 -- first private entity are swapped.
1183 First_Private
: Entity_Id
:= First_Private_Entity
(E
);
1186 if Is_Private_Type
(First_Private
)
1187 and then Present
(Full_View
(First_Private
))
1189 First_Private
:= Full_View
(First_Private
);
1194 Loc
=> Sloc
(First_Private
),
1196 Eun
=> Get_Source_Unit
(Def
),
1197 Lun
=> Get_Source_Unit
(Ref
),
1199 Ent_Scope
=> Empty
),
1200 Ent_Scope_File
=> No_Unit
);
1205 end Generate_Reference
;
1207 -----------------------------------
1208 -- Generate_Reference_To_Formals --
1209 -----------------------------------
1211 procedure Generate_Reference_To_Formals
(E
: Entity_Id
) is
1215 if Is_Access_Subprogram_Type
(E
) then
1216 Formal
:= First_Formal
(Designated_Type
(E
));
1218 Formal
:= First_Formal
(E
);
1221 while Present
(Formal
) loop
1222 if Ekind
(Formal
) = E_In_Parameter
then
1224 if Nkind
(Parameter_Type
(Parent
(Formal
))) = N_Access_Definition
1226 Generate_Reference
(E
, Formal
, '^', False);
1228 Generate_Reference
(E
, Formal
, '>', False);
1231 elsif Ekind
(Formal
) = E_In_Out_Parameter
then
1232 Generate_Reference
(E
, Formal
, '=', False);
1235 Generate_Reference
(E
, Formal
, '<', False);
1238 Next_Formal
(Formal
);
1240 end Generate_Reference_To_Formals
;
1242 -------------------------------------------
1243 -- Generate_Reference_To_Generic_Formals --
1244 -------------------------------------------
1246 procedure Generate_Reference_To_Generic_Formals
(E
: Entity_Id
) is
1250 Formal
:= First_Entity
(E
);
1251 while Present
(Formal
) loop
1252 if Comes_From_Source
(Formal
) then
1253 Generate_Reference
(E
, Formal
, 'z', False);
1256 Next_Entity
(Formal
);
1258 end Generate_Reference_To_Generic_Formals
;
1264 function Get_Key
(E
: Xref_Entry_Number
) return Xref_Entry_Number
is
1273 function Hash
(F
: Xref_Entry_Number
) return Header_Num
is
1274 -- It is unlikely to have two references to the same entity at the same
1275 -- source location, so the hash function depends only on the Ent and Loc
1278 XE
: Xref_Entry
renames Xrefs
.Table
(F
);
1279 type M
is mod 2**32;
1281 H
: constant M
:= 3 * M
(XE
.Key
.Ent
) + 5 * M
(abs XE
.Key
.Loc
);
1282 -- It would be more natural to write:
1284 -- H : constant M := 3 * M'Mod (XE.Key.Ent) + 5 * M'Mod (XE.Key.Loc);
1286 -- But we can't use M'Mod, because it prevents bootstrapping with older
1287 -- compilers. Loc can be negative, so we do "abs" before converting.
1288 -- One day this can be cleaned up ???
1291 return Header_Num
(H
mod Num_Buckets
);
1298 procedure HT_Set_Next
(E
: Xref_Entry_Number
; Next
: Xref_Entry_Number
) is
1300 Xrefs
.Table
(E
).HTable_Next
:= Next
;
1307 function HT_Next
(E
: Xref_Entry_Number
) return Xref_Entry_Number
is
1309 return Xrefs
.Table
(E
).HTable_Next
;
1316 procedure Initialize
is
1325 function Lt
(T1
, T2
: Xref_Entry
) return Boolean is
1327 -- First test: if entity is in different unit, sort by unit
1329 if T1
.Key
.Eun
/= T2
.Key
.Eun
then
1330 return Dependency_Num
(T1
.Key
.Eun
) < Dependency_Num
(T2
.Key
.Eun
);
1332 -- Second test: within same unit, sort by entity Sloc
1334 elsif T1
.Def
/= T2
.Def
then
1335 return T1
.Def
< T2
.Def
;
1337 -- Third test: sort definitions ahead of references
1339 elsif T1
.Key
.Loc
= No_Location
then
1342 elsif T2
.Key
.Loc
= No_Location
then
1345 -- Fourth test: for same entity, sort by reference location unit
1347 elsif T1
.Key
.Lun
/= T2
.Key
.Lun
then
1348 return Dependency_Num
(T1
.Key
.Lun
) < Dependency_Num
(T2
.Key
.Lun
);
1350 -- Fifth test: order of location within referencing unit
1352 elsif T1
.Key
.Loc
/= T2
.Key
.Loc
then
1353 return T1
.Key
.Loc
< T2
.Key
.Loc
;
1355 -- Finally, for two locations at the same address, we prefer
1356 -- the one that does NOT have the type 'r' so that a modification
1357 -- or extension takes preference, when there are more than one
1358 -- reference at the same location. As a result, in the case of
1359 -- entities that are in-out actuals, the read reference follows
1360 -- the modify reference.
1363 return T2
.Key
.Typ
= 'r';
1367 -----------------------
1368 -- Output_References --
1369 -----------------------
1371 procedure Output_References
is
1373 procedure Get_Type_Reference
1375 Tref
: out Entity_Id
;
1376 Left
: out Character;
1377 Right
: out Character);
1378 -- Given an Entity_Id Ent, determines whether a type reference is
1379 -- required. If so, Tref is set to the entity for the type reference
1380 -- and Left and Right are set to the left/right brackets to be output
1381 -- for the reference. If no type reference is required, then Tref is
1382 -- set to Empty, and Left/Right are set to space.
1384 procedure Output_Import_Export_Info
(Ent
: Entity_Id
);
1385 -- Output language and external name information for an interfaced
1386 -- entity, using the format <language, external_name>.
1388 ------------------------
1389 -- Get_Type_Reference --
1390 ------------------------
1392 procedure Get_Type_Reference
1394 Tref
: out Entity_Id
;
1395 Left
: out Character;
1396 Right
: out Character)
1401 -- See if we have a type reference
1410 -- Processing for types
1412 if Is_Type
(Tref
) then
1414 -- Case of base type
1416 if Base_Type
(Tref
) = Tref
then
1418 -- If derived, then get first subtype
1420 if Tref
/= Etype
(Tref
) then
1421 Tref
:= First_Subtype
(Etype
(Tref
));
1423 -- Set brackets for derived type, but don't override
1424 -- pointer case since the fact that something is a
1425 -- pointer is more important.
1432 -- If the completion of a private type is itself a derived
1433 -- type, we need the parent of the full view.
1435 elsif Is_Private_Type
(Tref
)
1436 and then Present
(Full_View
(Tref
))
1437 and then Etype
(Full_View
(Tref
)) /= Full_View
(Tref
)
1439 Tref
:= Etype
(Full_View
(Tref
));
1446 -- If non-derived pointer, get directly designated type.
1447 -- If the type has a full view, all references are on the
1448 -- partial view that is seen first.
1450 elsif Is_Access_Type
(Tref
) then
1451 Tref
:= Directly_Designated_Type
(Tref
);
1455 elsif Is_Private_Type
(Tref
)
1456 and then Present
(Full_View
(Tref
))
1458 if Is_Access_Type
(Full_View
(Tref
)) then
1459 Tref
:= Directly_Designated_Type
(Full_View
(Tref
));
1463 -- If the full view is an array type, we also retrieve
1464 -- the corresponding component type, because the ali
1465 -- entry already indicates that this is an array.
1467 elsif Is_Array_Type
(Full_View
(Tref
)) then
1468 Tref
:= Component_Type
(Full_View
(Tref
));
1473 -- If non-derived array, get component type. Skip component
1474 -- type for case of String or Wide_String, saves worthwhile
1477 elsif Is_Array_Type
(Tref
)
1478 and then Tref
/= Standard_String
1479 and then Tref
/= Standard_Wide_String
1481 Tref
:= Component_Type
(Tref
);
1485 -- For other non-derived base types, nothing
1491 -- For a subtype, go to ancestor subtype
1494 Tref
:= Ancestor_Subtype
(Tref
);
1496 -- If no ancestor subtype, go to base type
1499 Tref
:= Base_Type
(Sav
);
1503 -- For objects, functions, enum literals, just get type from
1506 elsif Is_Object
(Tref
)
1507 or else Ekind
(Tref
) = E_Enumeration_Literal
1508 or else Ekind
(Tref
) = E_Function
1509 or else Ekind
(Tref
) = E_Operator
1511 Tref
:= Etype
(Tref
);
1513 -- Another special case: an object of a classwide type
1514 -- initialized with a tag-indeterminate call gets a subtype
1515 -- of the classwide type during expansion. See if the original
1516 -- type in the declaration is named, and return it instead
1517 -- of going to the root type. The expression may be a class-
1518 -- wide function call whose result is on the secondary stack,
1519 -- which forces the declaration to be rewritten as a renaming,
1520 -- so examine the source declaration.
1522 if Ekind
(Tref
) = E_Class_Wide_Subtype
then
1524 Decl
: constant Node_Id
:= Original_Node
(Parent
(Ent
));
1526 if Nkind
(Decl
) = N_Object_Declaration
1527 and then Is_Entity_Name
1528 (Original_Node
(Object_Definition
(Decl
)))
1531 Entity
(Original_Node
(Object_Definition
(Decl
)));
1535 -- For a function that returns a class-wide type, Tref is
1538 elsif Is_Overloadable
(Ent
)
1539 and then Is_Class_Wide_Type
(Tref
)
1544 -- For anything else, exit
1550 -- Exit if no type reference, or we are stuck in some loop trying
1551 -- to find the type reference, or if the type is standard void
1552 -- type (the latter is an implementation artifact that should not
1553 -- show up in the generated cross-references).
1557 or else Tref
= Standard_Void_Type
;
1559 -- If we have a usable type reference, return, otherwise keep
1560 -- looking for something useful (we are looking for something
1561 -- that either comes from source or standard)
1563 if Sloc
(Tref
) = Standard_Location
1564 or else Comes_From_Source
(Tref
)
1566 -- If the reference is a subtype created for a generic actual,
1567 -- go actual directly, the inner subtype is not user visible.
1569 if Nkind
(Parent
(Tref
)) = N_Subtype_Declaration
1570 and then not Comes_From_Source
(Parent
(Tref
))
1572 (Is_Wrapper_Package
(Scope
(Tref
))
1573 or else Is_Generic_Instance
(Scope
(Tref
)))
1575 Tref
:= First_Subtype
(Base_Type
(Tref
));
1582 -- If we fall through the loop, no type reference
1587 end Get_Type_Reference
;
1589 -------------------------------
1590 -- Output_Import_Export_Info --
1591 -------------------------------
1593 procedure Output_Import_Export_Info
(Ent
: Entity_Id
) is
1594 Language_Name
: Name_Id
;
1595 Conv
: constant Convention_Id
:= Convention
(Ent
);
1598 -- Generate language name from convention
1600 if Conv
= Convention_C
or else Conv
in Convention_C_Variadic
then
1601 Language_Name
:= Name_C
;
1603 elsif Conv
= Convention_CPP
then
1604 Language_Name
:= Name_CPP
;
1606 elsif Conv
= Convention_Ada
then
1607 Language_Name
:= Name_Ada
;
1610 -- For the moment we ignore all other cases ???
1615 Write_Info_Char
('<');
1616 Get_Unqualified_Name_String
(Language_Name
);
1618 for J
in 1 .. Name_Len
loop
1619 Write_Info_Char
(Name_Buffer
(J
));
1622 if Present
(Interface_Name
(Ent
)) then
1623 Write_Info_Char
(',');
1624 String_To_Name_Buffer
(Strval
(Interface_Name
(Ent
)));
1626 for J
in 1 .. Name_Len
loop
1627 Write_Info_Char
(Name_Buffer
(J
));
1631 Write_Info_Char
('>');
1632 end Output_Import_Export_Info
;
1634 -- Start of processing for Output_References
1637 -- First we add references to the primitive operations of tagged types
1638 -- declared in the main unit.
1640 Handle_Prim_Ops
: declare
1644 for J
in 1 .. Xrefs
.Last
loop
1645 Ent
:= Xrefs
.Table
(J
).Key
.Ent
;
1648 and then Is_Tagged_Type
(Ent
)
1649 and then Is_Base_Type
(Ent
)
1650 and then In_Extended_Main_Source_Unit
(Ent
)
1652 Generate_Prim_Op_References
(Ent
);
1655 end Handle_Prim_Ops
;
1657 -- Before we go ahead and output the references we have a problem
1658 -- that needs dealing with. So far we have captured things that are
1659 -- definitely referenced by the main unit, or defined in the main
1660 -- unit. That's because we don't want to clutter up the ali file
1661 -- for this unit with definition lines for entities in other units
1662 -- that are not referenced.
1664 -- But there is a glitch. We may reference an entity in another unit,
1665 -- and it may have a type reference to an entity that is not directly
1666 -- referenced in the main unit, which may mean that there is no xref
1667 -- entry for this entity yet in the list of references.
1669 -- If we don't do something about this, we will end with an orphan type
1670 -- reference, i.e. it will point to an entity that does not appear
1671 -- within the generated references in the ali file. That is not good for
1672 -- tools using the xref information.
1674 -- To fix this, we go through the references adding definition entries
1675 -- for any unreferenced entities that can be referenced in a type
1676 -- reference. There is a recursion problem here, and that is dealt with
1677 -- by making sure that this traversal also traverses any entries that
1678 -- get added by the traversal.
1680 Handle_Orphan_Type_References
: declare
1686 pragma Warnings
(Off
, L
);
1687 pragma Warnings
(Off
, R
);
1689 procedure New_Entry
(E
: Entity_Id
);
1690 -- Make an additional entry into the Xref table for a type entity
1691 -- that is related to the current entity (parent, type ancestor,
1692 -- progenitor, etc.).
1698 procedure New_Entry
(E
: Entity_Id
) is
1700 pragma Assert
(Present
(E
));
1702 if not Has_Xref_Entry
(Implementation_Base_Type
(E
))
1703 and then Sloc
(E
) > No_Location
1708 Typ
=> Character'First,
1709 Eun
=> Get_Source_Unit
(Original_Location
(Sloc
(E
))),
1712 Ent_Scope
=> Empty
),
1713 Ent_Scope_File
=> No_Unit
);
1717 -- Start of processing for Handle_Orphan_Type_References
1720 -- Note that this is not a for loop for a very good reason. The
1721 -- processing of items in the table can add new items to the table,
1722 -- and they must be processed as well.
1725 while J
<= Xrefs
.Last
loop
1726 Ent
:= Xrefs
.Table
(J
).Key
.Ent
;
1728 -- Do not generate reference information for an ignored Ghost
1729 -- entity because neither the entity nor its references will
1730 -- appear in the final tree.
1732 if Is_Ignored_Ghost_Entity
(Ent
) then
1733 goto Orphan_Continue
;
1736 Get_Type_Reference
(Ent
, Tref
, L
, R
);
1739 and then not Has_Xref_Entry
(Tref
)
1740 and then Sloc
(Tref
) > No_Location
1744 if Is_Record_Type
(Ent
)
1745 and then Present
(Interfaces
(Ent
))
1747 -- Add an entry for each one of the given interfaces
1748 -- implemented by type Ent.
1751 Elmt
: Elmt_Id
:= First_Elmt
(Interfaces
(Ent
));
1753 while Present
(Elmt
) loop
1754 New_Entry
(Node
(Elmt
));
1761 -- Collect inherited primitive operations that may be declared in
1762 -- another unit and have no visible reference in the current one.
1765 and then Is_Tagged_Type
(Ent
)
1766 and then Is_Derived_Type
(Ent
)
1767 and then Is_Base_Type
(Ent
)
1768 and then In_Extended_Main_Source_Unit
(Ent
)
1771 Op_List
: constant Elist_Id
:= Primitive_Operations
(Ent
);
1775 function Parent_Op
(E
: Entity_Id
) return Entity_Id
;
1776 -- Find original operation, which may be inherited through
1777 -- several derivations.
1779 function Parent_Op
(E
: Entity_Id
) return Entity_Id
is
1780 Orig_Op
: constant Entity_Id
:= Alias
(E
);
1783 if No
(Orig_Op
) then
1786 elsif not Comes_From_Source
(E
)
1787 and then not Has_Xref_Entry
(Orig_Op
)
1788 and then Comes_From_Source
(Orig_Op
)
1792 return Parent_Op
(Orig_Op
);
1797 Op
:= First_Elmt
(Op_List
);
1798 while Present
(Op
) loop
1799 Prim
:= Parent_Op
(Node
(Op
));
1801 if Present
(Prim
) then
1805 Typ
=> Character'First,
1806 Eun
=> Get_Source_Unit
(Sloc
(Prim
)),
1809 Ent_Scope
=> Empty
),
1810 Ent_Scope_File
=> No_Unit
);
1821 end Handle_Orphan_Type_References
;
1823 -- Now we have all the references, including those for any embedded type
1824 -- references, so we can sort them, and output them.
1826 Output_Refs
: declare
1827 Nrefs
: constant Nat
:= Xrefs
.Last
;
1828 -- Number of references in table
1830 Rnums
: array (0 .. Nrefs
) of Nat
;
1831 -- This array contains numbers of references in the Xrefs table.
1832 -- This list is sorted in output order. The extra 0'th entry is
1833 -- convenient for the call to sort. When we sort the table, we
1834 -- move the entries in Rnums around, but we do not move the
1835 -- original table entries.
1837 Curxu
: Unit_Number_Type
;
1838 -- Current xref unit
1840 Curru
: Unit_Number_Type
;
1841 -- Current reference unit for one entity
1846 Curnam
: String (1 .. Name_Buffer
'Length);
1848 -- Simple name and length of current entity
1850 Curdef
: Source_Ptr
;
1851 -- Original source location for current entity
1854 -- Current reference location
1857 -- Entity type character
1860 -- reference kind of previous reference
1866 -- Renaming reference
1868 Trunit
: Unit_Number_Type
;
1869 -- Unit number for type reference
1871 function Lt
(Op1
, Op2
: Natural) return Boolean;
1872 -- Comparison function for Sort call
1874 function Name_Change
(X
: Entity_Id
) return Boolean;
1875 -- Determines if entity X has a different simple name from Curent
1877 procedure Move
(From
: Natural; To
: Natural);
1878 -- Move procedure for Sort call
1880 package Sorting
is new GNAT
.Heap_Sort_G
(Move
, Lt
);
1886 function Lt
(Op1
, Op2
: Natural) return Boolean is
1887 T1
: Xref_Entry
renames Xrefs
.Table
(Rnums
(Nat
(Op1
)));
1888 T2
: Xref_Entry
renames Xrefs
.Table
(Rnums
(Nat
(Op2
)));
1898 procedure Move
(From
: Natural; To
: Natural) is
1900 Rnums
(Nat
(To
)) := Rnums
(Nat
(From
));
1907 -- Why a string comparison here??? Why not compare Name_Id values???
1909 function Name_Change
(X
: Entity_Id
) return Boolean is
1911 Get_Unqualified_Name_String
(Chars
(X
));
1913 if Name_Len
/= Curlen
then
1916 return Name_Buffer
(1 .. Curlen
) /= Curnam
(1 .. Curlen
);
1920 -- Start of processing for Output_Refs
1923 -- Capture the definition Sloc values. We delay doing this till now,
1924 -- since at the time the reference or definition is made, private
1925 -- types may be swapped, and the Sloc value may be incorrect. We
1926 -- also set up the pointer vector for the sort.
1928 -- For user-defined operators we need to skip the initial quote and
1929 -- point to the first character of the name, for navigation purposes.
1931 for J
in 1 .. Nrefs
loop
1933 E
: constant Entity_Id
:= Xrefs
.Table
(J
).Key
.Ent
;
1934 Loc
: constant Source_Ptr
:= Original_Location
(Sloc
(E
));
1939 if Nkind
(E
) = N_Defining_Operator_Symbol
then
1940 Xrefs
.Table
(J
).Def
:= Loc
+ 1;
1942 Xrefs
.Table
(J
).Def
:= Loc
;
1947 -- Sort the references
1949 Sorting
.Sort
(Integer (Nrefs
));
1951 -- Initialize loop through references
1955 Curdef
:= No_Location
;
1957 Crloc
:= No_Location
;
1960 -- Loop to output references
1962 for Refno
in 1 .. Nrefs
loop
1963 Output_One_Ref
: declare
1966 XE
: Xref_Entry
renames Xrefs
.Table
(Rnums
(Refno
));
1967 -- The current entry to be accessed
1971 -- Used for {} or <> or () for type reference
1973 procedure Check_Type_Reference
1975 List_Interface
: Boolean;
1976 Is_Component
: Boolean := False);
1977 -- Find whether there is a meaningful type reference for
1978 -- Ent, and display it accordingly. If List_Interface is
1979 -- true, then Ent is a progenitor interface of the current
1980 -- type entity being listed. In that case list it as is,
1981 -- without looking for a type reference for it. Flag is also
1982 -- used for index types of an array type, where the caller
1983 -- supplies the intended type reference. Is_Component serves
1984 -- the same purpose, to display the component type of a
1985 -- derived array type, for which only the parent type has
1986 -- ben displayed so far.
1988 procedure Output_Instantiation_Refs
(Loc
: Source_Ptr
);
1989 -- Recursive procedure to output instantiation references for
1990 -- the given source ptr in [file|line[...]] form. No output
1991 -- if the given location is not a generic template reference.
1993 procedure Output_Overridden_Op
(Old_E
: Entity_Id
);
1994 -- For a subprogram that is overriding, display information
1995 -- about the inherited operation that it overrides.
1997 --------------------------
1998 -- Check_Type_Reference --
1999 --------------------------
2001 procedure Check_Type_Reference
2003 List_Interface
: Boolean;
2004 Is_Component
: Boolean := False)
2007 if List_Interface
then
2009 -- This is a progenitor interface of the type for which
2010 -- xref information is being generated.
2016 -- The following is not documented in lib-xref.ads ???
2018 elsif Is_Component
then
2024 Get_Type_Reference
(Ent
, Tref
, Left
, Right
);
2027 if Present
(Tref
) then
2029 -- Case of standard entity, output name
2031 if Sloc
(Tref
) = Standard_Location
then
2032 Write_Info_Char
(Left
);
2033 Write_Info_Name
(Chars
(Tref
));
2034 Write_Info_Char
(Right
);
2036 -- Case of source entity, output location
2039 Write_Info_Char
(Left
);
2040 Trunit
:= Get_Source_Unit
(Sloc
(Tref
));
2042 if Trunit
/= Curxu
then
2043 Write_Info_Nat
(Dependency_Num
(Trunit
));
2044 Write_Info_Char
('|');
2048 (Int
(Get_Logical_Line_Number
(Sloc
(Tref
))));
2056 Ctyp
:= Xref_Entity_Letters
(Ekind
(Ent
));
2059 and then Present
(Full_View
(Ent
))
2061 Ent
:= Underlying_Type
(Ent
);
2063 if Present
(Ent
) then
2064 Ctyp
:= Xref_Entity_Letters
(Ekind
(Ent
));
2068 Write_Info_Char
(Ctyp
);
2072 (Int
(Get_Column_Number
(Sloc
(Tref
))));
2074 -- If the type comes from an instantiation, add the
2075 -- corresponding info.
2077 Output_Instantiation_Refs
(Sloc
(Tref
));
2078 Write_Info_Char
(Right
);
2081 end Check_Type_Reference
;
2083 -------------------------------
2084 -- Output_Instantiation_Refs --
2085 -------------------------------
2087 procedure Output_Instantiation_Refs
(Loc
: Source_Ptr
) is
2088 Iloc
: constant Source_Ptr
:= Instantiation_Location
(Loc
);
2089 Lun
: Unit_Number_Type
;
2090 Cu
: constant Unit_Number_Type
:= Curru
;
2093 -- Nothing to do if this is not an instantiation
2095 if Iloc
= No_Location
then
2099 -- Output instantiation reference
2101 Write_Info_Char
('[');
2102 Lun
:= Get_Source_Unit
(Iloc
);
2104 if Lun
/= Curru
then
2106 Write_Info_Nat
(Dependency_Num
(Curru
));
2107 Write_Info_Char
('|');
2110 Write_Info_Nat
(Int
(Get_Logical_Line_Number
(Iloc
)));
2112 -- Recursive call to get nested instantiations
2114 Output_Instantiation_Refs
(Iloc
);
2116 -- Output final ] after call to get proper nesting
2118 Write_Info_Char
(']');
2121 end Output_Instantiation_Refs
;
2123 --------------------------
2124 -- Output_Overridden_Op --
2125 --------------------------
2127 procedure Output_Overridden_Op
(Old_E
: Entity_Id
) is
2131 -- The overridden operation has an implicit declaration
2132 -- at the point of derivation. What we want to display
2133 -- is the original operation, which has the actual body
2134 -- (or abstract declaration) that is being overridden.
2135 -- The overridden operation is not always set, e.g. when
2136 -- it is a predefined operator.
2141 -- Follow alias chain if one is present
2143 elsif Present
(Alias
(Old_E
)) then
2145 -- The subprogram may have been implicitly inherited
2146 -- through several levels of derivation, so find the
2147 -- ultimate (source) ancestor.
2149 Op
:= Ultimate_Alias
(Old_E
);
2151 -- Normal case of no alias present. We omit generated
2152 -- primitives like tagged equality, that have no source
2160 and then Sloc
(Op
) /= Standard_Location
2161 and then Comes_From_Source
(Op
)
2164 Loc
: constant Source_Ptr
:= Sloc
(Op
);
2165 Par_Unit
: constant Unit_Number_Type
:=
2166 Get_Source_Unit
(Loc
);
2169 Write_Info_Char
('<');
2171 if Par_Unit
/= Curxu
then
2172 Write_Info_Nat
(Dependency_Num
(Par_Unit
));
2173 Write_Info_Char
('|');
2176 Write_Info_Nat
(Int
(Get_Logical_Line_Number
(Loc
)));
2177 Write_Info_Char
('p');
2178 Write_Info_Nat
(Int
(Get_Column_Number
(Loc
)));
2179 Write_Info_Char
('>');
2182 end Output_Overridden_Op
;
2184 -- Start of processing for Output_One_Ref
2189 -- Do not generate reference information for an ignored Ghost
2190 -- entity because neither the entity nor its references will
2191 -- appear in the final tree.
2193 if Is_Ignored_Ghost_Entity
(Ent
) then
2197 Ctyp
:= Xref_Entity_Letters
(Ekind
(Ent
));
2199 -- Skip reference if it is the only reference to an entity,
2200 -- and it is an END line reference, and the entity is not in
2201 -- the current extended source. This prevents junk entries
2202 -- consisting only of packages with END lines, where no
2203 -- entity from the package is actually referenced.
2206 and then Ent
/= Curent
2207 and then (Refno
= Nrefs
2209 Ent
/= Xrefs
.Table
(Rnums
(Refno
+ 1)).Key
.Ent
)
2210 and then not In_Extended_Main_Source_Unit
(Ent
)
2215 -- For private type, get full view type
2218 and then Present
(Full_View
(XE
.Key
.Ent
))
2220 Ent
:= Underlying_Type
(Ent
);
2222 if Present
(Ent
) then
2223 Ctyp
:= Xref_Entity_Letters
(Ekind
(Ent
));
2227 -- Special exception for Boolean
2229 if Ctyp
= 'E' and then Is_Boolean_Type
(Ent
) then
2233 -- For variable reference, get corresponding type
2236 Ent
:= Etype
(XE
.Key
.Ent
);
2237 Ctyp
:= Fold_Lower
(Xref_Entity_Letters
(Ekind
(Ent
)));
2239 -- If variable is private type, get full view type
2242 and then Present
(Full_View
(Etype
(XE
.Key
.Ent
)))
2244 Ent
:= Underlying_Type
(Etype
(XE
.Key
.Ent
));
2246 if Present
(Ent
) then
2247 Ctyp
:= Fold_Lower
(Xref_Entity_Letters
(Ekind
(Ent
)));
2250 elsif Is_Generic_Type
(Ent
) then
2252 -- If the type of the entity is a generic private type,
2253 -- there is no usable full view, so retain the indication
2254 -- that this is an object.
2259 -- Special handling for access parameters and objects and
2260 -- components of an anonymous access type.
2262 if Ekind
(Etype
(XE
.Key
.Ent
)) in
2263 E_Anonymous_Access_Type
2264 | E_Anonymous_Access_Subprogram_Type
2265 | E_Anonymous_Access_Protected_Subprogram_Type
2267 if Is_Formal
(XE
.Key
.Ent
)
2269 Ekind
(XE
.Key
.Ent
) in
2270 E_Variable | E_Constant | E_Component
2275 -- Special handling for Boolean
2277 elsif Ctyp
= 'e' and then Is_Boolean_Type
(Ent
) then
2282 -- Special handling for abstract types and operations
2284 if Is_Overloadable
(XE
.Key
.Ent
)
2285 and then Is_Abstract_Subprogram
(XE
.Key
.Ent
)
2288 Ctyp
:= 'x'; -- Abstract procedure
2290 elsif Ctyp
= 'V' then
2291 Ctyp
:= 'y'; -- Abstract function
2294 elsif Is_Type
(XE
.Key
.Ent
)
2295 and then Is_Abstract_Type
(XE
.Key
.Ent
)
2297 if Is_Interface
(XE
.Key
.Ent
) then
2300 elsif Ctyp
= 'R' then
2301 Ctyp
:= 'H'; -- Abstract type
2305 -- Only output reference if interesting type of entity
2309 -- Suppress references to object definitions, used for local
2312 or else XE
.Key
.Typ
= 'D'
2313 or else XE
.Key
.Typ
= 'I'
2315 -- Suppress self references, except for bodies that act as
2318 or else (XE
.Key
.Loc
= XE
.Def
2321 or else not Is_Subprogram
(XE
.Key
.Ent
)))
2323 -- Also suppress definitions of body formals (we only
2324 -- treat these as references, and the references were
2325 -- separately recorded).
2327 or else (Is_Formal
(XE
.Key
.Ent
)
2328 and then Present
(Spec_Entity
(XE
.Key
.Ent
)))
2333 -- Start new Xref section if new xref unit
2335 if XE
.Key
.Eun
/= Curxu
then
2336 if Write_Info_Col
> 1 then
2340 Curxu
:= XE
.Key
.Eun
;
2342 Write_Info_Initiate
('X');
2343 Write_Info_Char
(' ');
2344 Write_Info_Nat
(Dependency_Num
(XE
.Key
.Eun
));
2345 Write_Info_Char
(' ');
2347 (Reference_Name
(Source_Index
(XE
.Key
.Eun
)));
2350 -- Start new Entity line if new entity. Note that we
2351 -- consider two entities the same if they have the same
2352 -- name and source location. This causes entities in
2353 -- instantiations to be treated as though they referred
2358 (XE
.Key
.Ent
/= Curent
2360 (Name_Change
(XE
.Key
.Ent
) or else XE
.Def
/= Curdef
))
2362 Curent
:= XE
.Key
.Ent
;
2365 Get_Unqualified_Name_String
(Chars
(XE
.Key
.Ent
));
2367 Curnam
(1 .. Curlen
) := Name_Buffer
(1 .. Curlen
);
2369 if Write_Info_Col
> 1 then
2373 -- Write column number information
2375 Write_Info_Nat
(Int
(Get_Logical_Line_Number
(XE
.Def
)));
2376 Write_Info_Char
(Ctyp
);
2377 Write_Info_Nat
(Int
(Get_Column_Number
(XE
.Def
)));
2379 -- Write level information
2381 Write_Level_Info
: declare
2382 function Is_Visible_Generic_Entity
2383 (E
: Entity_Id
) return Boolean;
2384 -- Check whether E is declared in the visible part
2385 -- of a generic package. For source navigation
2386 -- purposes, treat this as a visible entity.
2388 function Is_Private_Record_Component
2389 (E
: Entity_Id
) return Boolean;
2390 -- Check whether E is a non-inherited component of a
2391 -- private extension. Even if the enclosing record is
2392 -- public, we want to treat the component as private
2393 -- for navigation purposes.
2395 ---------------------------------
2396 -- Is_Private_Record_Component --
2397 ---------------------------------
2399 function Is_Private_Record_Component
2400 (E
: Entity_Id
) return Boolean
2402 S
: constant Entity_Id
:= Scope
(E
);
2405 Ekind
(E
) = E_Component
2406 and then Nkind
(Declaration_Node
(S
)) =
2407 N_Private_Extension_Declaration
2408 and then Original_Record_Component
(E
) = E
;
2409 end Is_Private_Record_Component
;
2411 -------------------------------
2412 -- Is_Visible_Generic_Entity --
2413 -------------------------------
2415 function Is_Visible_Generic_Entity
2416 (E
: Entity_Id
) return Boolean
2421 -- The Present check here is an error defense
2423 if Present
(Scope
(E
))
2424 and then Ekind
(Scope
(E
)) /= E_Generic_Package
2430 while Present
(Par
) loop
2432 Nkind
(Par
) = N_Generic_Package_Declaration
2434 -- Entity is a generic formal
2439 Nkind
(Parent
(Par
)) = N_Package_Specification
2442 Is_List_Member
(Par
)
2443 and then List_Containing
(Par
) =
2444 Visible_Declarations
(Parent
(Par
));
2446 Par
:= Parent
(Par
);
2451 end Is_Visible_Generic_Entity
;
2453 -- Start of processing for Write_Level_Info
2456 if Is_Hidden
(Curent
)
2457 or else Is_Private_Record_Component
(Curent
)
2459 Write_Info_Char
(' ');
2463 or else Is_Visible_Generic_Entity
(Curent
)
2465 Write_Info_Char
('*');
2468 Write_Info_Char
(' ');
2470 end Write_Level_Info
;
2472 -- Output entity name. We use the occurrence from the
2473 -- actual source program at the definition point.
2476 Ent_Name
: constant String :=
2477 Exact_Source_Name
(Sloc
(XE
.Key
.Ent
));
2479 for C
in Ent_Name
'Range loop
2480 Write_Info_Char
(Ent_Name
(C
));
2484 -- See if we have a renaming reference
2486 if Is_Object
(XE
.Key
.Ent
)
2487 and then Present
(Renamed_Object
(XE
.Key
.Ent
))
2489 Rref
:= Renamed_Object
(XE
.Key
.Ent
);
2491 elsif Is_Overloadable
(XE
.Key
.Ent
)
2492 and then Nkind
(Parent
(Declaration_Node
(XE
.Key
.Ent
)))
2493 = N_Subprogram_Renaming_Declaration
2495 Rref
:= Name
(Parent
(Declaration_Node
(XE
.Key
.Ent
)));
2497 elsif Ekind
(XE
.Key
.Ent
) = E_Package
2498 and then Nkind
(Declaration_Node
(XE
.Key
.Ent
)) =
2499 N_Package_Renaming_Declaration
2501 Rref
:= Name
(Declaration_Node
(XE
.Key
.Ent
));
2507 if Present
(Rref
) then
2508 if Nkind
(Rref
) = N_Expanded_Name
then
2509 Rref
:= Selector_Name
(Rref
);
2512 if Nkind
(Rref
) = N_Identifier
2513 or else Nkind
(Rref
) = N_Operator_Symbol
2517 -- For renamed array components, use the array name
2518 -- for the renamed entity, which reflect the fact that
2519 -- in general the whole array is aliased.
2521 elsif Nkind
(Rref
) = N_Indexed_Component
then
2522 if Nkind
(Prefix
(Rref
)) = N_Identifier
then
2523 Rref
:= Prefix
(Rref
);
2524 elsif Nkind
(Prefix
(Rref
)) = N_Expanded_Name
then
2525 Rref
:= Selector_Name
(Prefix
(Rref
));
2535 -- Write out renaming reference if we have one
2537 if Present
(Rref
) then
2538 Write_Info_Char
('=');
2540 (Int
(Get_Logical_Line_Number
(Sloc
(Rref
))));
2541 Write_Info_Char
(':');
2543 (Int
(Get_Column_Number
(Sloc
(Rref
))));
2546 -- Indicate that the entity is in the unit of the current
2551 -- Write out information about generic parent, if entity
2554 if Is_Generic_Instance
(XE
.Key
.Ent
) then
2556 Gen_Par
: constant Entity_Id
:=
2559 (Unit_Declaration_Node
2561 Loc
: constant Source_Ptr
:= Sloc
(Gen_Par
);
2562 Gen_U
: constant Unit_Number_Type
:=
2563 Get_Source_Unit
(Loc
);
2566 Write_Info_Char
('[');
2568 if Curru
/= Gen_U
then
2569 Write_Info_Nat
(Dependency_Num
(Gen_U
));
2570 Write_Info_Char
('|');
2574 (Int
(Get_Logical_Line_Number
(Loc
)));
2575 Write_Info_Char
(']');
2579 -- See if we have a type reference and if so output
2581 Check_Type_Reference
(XE
.Key
.Ent
, False);
2583 -- Additional information for types with progenitors,
2584 -- including synchronized tagged types.
2587 Typ
: constant Entity_Id
:= XE
.Key
.Ent
;
2591 if Is_Record_Type
(Typ
)
2592 and then Present
(Interfaces
(Typ
))
2594 Elmt
:= First_Elmt
(Interfaces
(Typ
));
2596 elsif Is_Concurrent_Type
(Typ
)
2597 and then Present
(Corresponding_Record_Type
(Typ
))
2599 Interfaces
(Corresponding_Record_Type
(Typ
)))
2603 Interfaces
(Corresponding_Record_Type
(Typ
)));
2609 while Present
(Elmt
) loop
2610 Check_Type_Reference
(Node
(Elmt
), True);
2615 -- For array types, list index types as well. (This is
2616 -- not C, indexes have distinct types).
2618 if Is_Array_Type
(XE
.Key
.Ent
) then
2620 A_Typ
: constant Entity_Id
:= XE
.Key
.Ent
;
2624 -- If this is a derived array type, we have
2625 -- output the parent type, so add the component
2628 if Is_Derived_Type
(A_Typ
) then
2629 Check_Type_Reference
2630 (Component_Type
(A_Typ
), False, True);
2633 -- Add references to index types.
2635 Indx
:= First_Index
(XE
.Key
.Ent
);
2636 while Present
(Indx
) loop
2637 Check_Type_Reference
2638 (First_Subtype
(Etype
(Indx
)), True);
2644 -- If the entity is an overriding operation, write info
2645 -- on operation that was overridden.
2647 if Is_Subprogram
(XE
.Key
.Ent
)
2648 and then Present
(Overridden_Operation
(XE
.Key
.Ent
))
2650 Output_Overridden_Op
2651 (Overridden_Operation
(XE
.Key
.Ent
));
2654 -- End of processing for entity output
2656 Crloc
:= No_Location
;
2659 -- Output the reference if it is not as the same location
2660 -- as the previous one, or it is a read-reference that
2661 -- indicates that the entity is an in-out actual in a call.
2663 if XE
.Key
.Loc
/= No_Location
2665 (XE
.Key
.Loc
/= Crloc
2666 or else (Prevt
= 'm' and then XE
.Key
.Typ
= 'r'))
2668 Crloc
:= XE
.Key
.Loc
;
2669 Prevt
:= XE
.Key
.Typ
;
2671 -- Start continuation if line full, else blank
2673 if Write_Info_Col
> 72 then
2675 Write_Info_Initiate
('.');
2678 Write_Info_Char
(' ');
2680 -- Output file number if changed
2682 if XE
.Key
.Lun
/= Curru
then
2683 Curru
:= XE
.Key
.Lun
;
2684 Write_Info_Nat
(Dependency_Num
(Curru
));
2685 Write_Info_Char
('|');
2689 (Int
(Get_Logical_Line_Number
(XE
.Key
.Loc
)));
2690 Write_Info_Char
(XE
.Key
.Typ
);
2692 if Is_Overloadable
(XE
.Key
.Ent
) then
2693 if (Is_Imported
(XE
.Key
.Ent
) and then XE
.Key
.Typ
= 'b')
2695 (Is_Exported
(XE
.Key
.Ent
) and then XE
.Key
.Typ
= 'i')
2697 Output_Import_Export_Info
(XE
.Key
.Ent
);
2701 Write_Info_Nat
(Int
(Get_Column_Number
(XE
.Key
.Loc
)));
2703 Output_Instantiation_Refs
(Sloc
(XE
.Key
.Ent
));
2714 end Output_References
;
2716 -- Start of elaboration for Lib.Xref
2719 -- Reset is necessary because Elmt_Ptr does not default to Null_Ptr,
2720 -- because it's not an access type.