PR debug/77844
[official-gcc.git] / gcc / ada / lib-writ.adb
blob0cd615fd50458780883f0917771c313ff5c51509
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- L I B . W R I T --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2016, 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 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 with ALI; use ALI;
27 with Atree; use Atree;
28 with Casing; use Casing;
29 with Debug; use Debug;
30 with Einfo; use Einfo;
31 with Errout; use Errout;
32 with Fname; use Fname;
33 with Fname.UF; use Fname.UF;
34 with Lib.Util; use Lib.Util;
35 with Lib.Xref; use Lib.Xref;
36 with Nlists; use Nlists;
37 with Gnatvsn; use Gnatvsn;
38 with Opt; use Opt;
39 with Osint; use Osint;
40 with Osint.C; use Osint.C;
41 with Output; use Output;
42 with Par;
43 with Par_SCO; use Par_SCO;
44 with Restrict; use Restrict;
45 with Rident; use Rident;
46 with Stand; use Stand;
47 with Scn; use Scn;
48 with Sem_Eval; use Sem_Eval;
49 with Sinfo; use Sinfo;
50 with Sinput; use Sinput;
51 with Snames; use Snames;
52 with Stringt; use Stringt;
53 with Tbuild; use Tbuild;
54 with Uname; use Uname;
56 with System.Case_Util; use System.Case_Util;
57 with System.WCh_Con; use System.WCh_Con;
59 package body Lib.Writ is
61 -----------------------
62 -- Local Subprograms --
63 -----------------------
65 procedure Write_Unit_Name (N : Node_Id);
66 -- Used to write out the unit name for R (pragma Restriction) lines
67 -- for uses of Restriction (No_Dependence => unit-name).
69 ----------------------------------
70 -- Add_Preprocessing_Dependency --
71 ----------------------------------
73 procedure Add_Preprocessing_Dependency (S : Source_File_Index) is
74 begin
75 Units.Increment_Last;
76 Units.Table (Units.Last) :=
77 (Unit_File_Name => File_Name (S),
78 Unit_Name => No_Unit_Name,
79 Expected_Unit => No_Unit_Name,
80 Source_Index => S,
81 Cunit => Empty,
82 Cunit_Entity => Empty,
83 Dependency_Num => 0,
84 Dynamic_Elab => False,
85 Fatal_Error => None,
86 Generate_Code => False,
87 Has_RACW => False,
88 Filler => False,
89 Ident_String => Empty,
90 Loading => False,
91 Main_Priority => -1,
92 Main_CPU => -1,
93 Munit_Index => 0,
94 No_Elab_Code_All => False,
95 Serial_Number => 0,
96 Version => 0,
97 Error_Location => No_Location,
98 OA_Setting => 'O',
99 SPARK_Mode_Pragma => Empty);
100 end Add_Preprocessing_Dependency;
102 ------------------------------
103 -- Ensure_System_Dependency --
104 ------------------------------
106 procedure Ensure_System_Dependency is
107 System_Uname : Unit_Name_Type;
108 -- Unit name for system spec if needed for dummy entry
110 System_Fname : File_Name_Type;
111 -- File name for system spec if needed for dummy entry
113 begin
114 -- Nothing to do if we already compiled System
116 for Unum in Units.First .. Last_Unit loop
117 if Units.Table (Unum).Source_Index = System_Source_File_Index then
118 return;
119 end if;
120 end loop;
122 -- If no entry for system.ads in the units table, then add a entry
123 -- to the units table for system.ads, which will be referenced when
124 -- the ali file is generated. We need this because every unit depends
125 -- on system as a result of Targparm scanning the system.ads file to
126 -- determine the target dependent parameters for the compilation.
128 Name_Len := 6;
129 Name_Buffer (1 .. 6) := "system";
130 System_Uname := Name_To_Unit_Name (Name_Enter);
131 System_Fname := File_Name (System_Source_File_Index);
133 Units.Increment_Last;
134 Units.Table (Units.Last) := (
135 Unit_File_Name => System_Fname,
136 Unit_Name => System_Uname,
137 Expected_Unit => System_Uname,
138 Source_Index => System_Source_File_Index,
139 Cunit => Empty,
140 Cunit_Entity => Empty,
141 Dependency_Num => 0,
142 Dynamic_Elab => False,
143 Fatal_Error => None,
144 Generate_Code => False,
145 Has_RACW => False,
146 Filler => False,
147 Ident_String => Empty,
148 Loading => False,
149 Main_Priority => -1,
150 Main_CPU => -1,
151 Munit_Index => 0,
152 No_Elab_Code_All => False,
153 Serial_Number => 0,
154 Version => 0,
155 Error_Location => No_Location,
156 OA_Setting => 'O',
157 SPARK_Mode_Pragma => Empty);
159 -- Parse system.ads so that the checksum is set right. Style checks are
160 -- not applied. The Ekind is set to ensure that this reference is always
161 -- present in the ali file.
163 declare
164 Save_Mindex : constant Nat := Multiple_Unit_Index;
165 Save_Style : constant Boolean := Style_Check;
166 begin
167 Multiple_Unit_Index := 0;
168 Style_Check := False;
169 Initialize_Scanner (Units.Last, System_Source_File_Index);
170 Discard_List (Par (Configuration_Pragmas => False));
171 Set_Ekind (Cunit_Entity (Units.Last), E_Package);
172 Set_Scope (Cunit_Entity (Units.Last), Standard_Standard);
173 Style_Check := Save_Style;
174 Multiple_Unit_Index := Save_Mindex;
175 end;
176 end Ensure_System_Dependency;
178 ---------------
179 -- Write_ALI --
180 ---------------
182 procedure Write_ALI (Object : Boolean) is
184 ----------------
185 -- Local Data --
186 ----------------
188 Last_Unit : constant Unit_Number_Type := Units.Last;
189 -- Record unit number of last unit. We capture this in case we
190 -- have to add a dummy entry to the unit table for package System.
192 With_Flags : array (Units.First .. Last_Unit) of Boolean;
193 -- Array of flags to show which units are with'ed
195 Elab_Flags : array (Units.First .. Last_Unit) of Boolean;
196 -- Array of flags to show which units have pragma Elaborate set
198 Elab_All_Flags : array (Units.First .. Last_Unit) of Boolean;
199 -- Array of flags to show which units have pragma Elaborate All set
201 Elab_Des_Flags : array (Units.First .. Last_Unit) of Boolean;
202 -- Array of flags to show which units have Elaborate_Desirable set
204 Elab_All_Des_Flags : array (Units.First .. Last_Unit) of Boolean;
205 -- Array of flags to show which units have Elaborate_All_Desirable set
207 type Yes_No is (Unknown, Yes, No);
208 Implicit_With : array (Units.First .. Last_Unit) of Yes_No;
209 -- Indicates if an implicit with has been given for the unit. Yes if
210 -- certainly present, no if certainly absent, unkonwn if not known.
212 Sdep_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 2));
213 -- Sorted table of source dependencies. One extra entry in case we
214 -- have to add a dummy entry for System.
216 Num_Sdep : Nat := 0;
217 -- Number of active entries in Sdep_Table
219 flag_compare_debug : Int;
220 pragma Import (C, flag_compare_debug);
221 -- Import from toplev.c
223 -----------------------
224 -- Local Subprograms --
225 -----------------------
227 procedure Collect_Withs (Cunit : Node_Id);
228 -- Collect with lines for entries in the context clause of the
229 -- given compilation unit, Cunit.
231 procedure Update_Tables_From_ALI_File;
232 -- Given an up to date ALI file (see Up_To_Date_ALI_file_Exists
233 -- function), update tables from the ALI information, including
234 -- specifically the Compilation_Switches table.
236 function Up_To_Date_ALI_File_Exists return Boolean;
237 -- If there exists an ALI file that is up to date, then this function
238 -- initializes the tables in the ALI spec to contain information on
239 -- this file (using Scan_ALI) and returns True. If no file exists,
240 -- or the file is not up to date, then False is returned.
242 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type);
243 -- Write out the library information for one unit for which code is
244 -- generated (includes unit line and with lines).
246 procedure Write_With_Lines;
247 -- Write out with lines collected by calls to Collect_Withs
249 -------------------
250 -- Collect_Withs --
251 -------------------
253 procedure Collect_Withs (Cunit : Node_Id) is
254 Item : Node_Id;
255 Unum : Unit_Number_Type;
257 begin
258 Item := First (Context_Items (Cunit));
259 while Present (Item) loop
261 -- Process with clause
263 -- Ada 2005 (AI-50217): limited with_clauses do not create
264 -- dependencies, but must be recorded as components of the
265 -- partition, in case there is no regular with_clause for
266 -- the unit anywhere else.
268 if Nkind (Item) = N_With_Clause then
269 Unum := Get_Cunit_Unit_Number (Library_Unit (Item));
270 With_Flags (Unum) := True;
272 if not Limited_Present (Item) then
273 if Elaborate_Present (Item) then
274 Elab_Flags (Unum) := True;
275 end if;
277 if Elaborate_All_Present (Item) then
278 Elab_All_Flags (Unum) := True;
279 end if;
281 if Elaborate_All_Desirable (Item) then
282 Elab_All_Des_Flags (Unum) := True;
283 end if;
285 if Elaborate_Desirable (Item) then
286 Elab_Des_Flags (Unum) := True;
287 end if;
289 else
290 Set_From_Limited_With (Cunit_Entity (Unum));
291 end if;
293 if Implicit_With (Unum) /= Yes then
294 if Implicit_With_From_Instantiation (Item) then
295 Implicit_With (Unum) := Yes;
296 else
297 Implicit_With (Unum) := No;
298 end if;
299 end if;
300 end if;
302 Next (Item);
303 end loop;
304 end Collect_Withs;
306 --------------------------------
307 -- Up_To_Date_ALI_File_Exists --
308 --------------------------------
310 function Up_To_Date_ALI_File_Exists return Boolean is
311 Name : File_Name_Type;
312 Text : Text_Buffer_Ptr;
313 Id : Sdep_Id;
314 Sind : Source_File_Index;
316 begin
317 Opt.Check_Object_Consistency := True;
318 Read_Library_Info (Name, Text);
320 -- Return if we could not find an ALI file
322 if Text = null then
323 return False;
324 end if;
326 -- Return if ALI file has bad format
328 Initialize_ALI;
330 if Scan_ALI (Name, Text, False, Err => True) = No_ALI_Id then
331 return False;
332 end if;
334 -- If we have an OK ALI file, check if it is up to date
335 -- Note that we assume that the ALI read has all the entries
336 -- we have in our table, plus some additional ones (that can
337 -- come from expansion).
339 Id := First_Sdep_Entry;
340 for J in 1 .. Num_Sdep loop
341 Sind := Units.Table (Sdep_Table (J)).Source_Index;
343 while Sdep.Table (Id).Sfile /= File_Name (Sind) loop
344 if Id = Sdep.Last then
345 return False;
346 else
347 Id := Id + 1;
348 end if;
349 end loop;
351 if Sdep.Table (Id).Stamp /= Time_Stamp (Sind) then
352 return False;
353 end if;
354 end loop;
356 return True;
357 end Up_To_Date_ALI_File_Exists;
359 ---------------------------------
360 -- Update_Tables_From_ALI_File --
361 ---------------------------------
363 procedure Update_Tables_From_ALI_File is
364 begin
365 -- Build Compilation_Switches table
367 Compilation_Switches.Init;
369 for J in First_Arg_Entry .. Args.Last loop
370 Compilation_Switches.Increment_Last;
371 Compilation_Switches.Table (Compilation_Switches.Last) :=
372 Args.Table (J);
373 end loop;
374 end Update_Tables_From_ALI_File;
376 ----------------------------
377 -- Write_Unit_Information --
378 ----------------------------
380 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type) is
381 Unode : constant Node_Id := Cunit (Unit_Num);
382 Ukind : constant Node_Kind := Nkind (Unit (Unode));
383 Uent : constant Entity_Id := Cunit_Entity (Unit_Num);
384 Pnode : Node_Id;
386 begin
387 Write_Info_Initiate ('U');
388 Write_Info_Char (' ');
389 Write_Info_Name (Unit_Name (Unit_Num));
390 Write_Info_Tab (25);
391 Write_Info_Name (Unit_File_Name (Unit_Num));
393 Write_Info_Tab (49);
394 Write_Info_Str (Version_Get (Unit_Num));
396 -- Add BD parameter if Elaborate_Body pragma desirable
398 if Ekind (Uent) = E_Package
399 and then Elaborate_Body_Desirable (Uent)
400 then
401 Write_Info_Str (" BD");
402 end if;
404 -- Add BN parameter if body needed for SAL
406 if (Is_Subprogram (Uent)
407 or else Ekind (Uent) = E_Package
408 or else Is_Generic_Unit (Uent))
409 and then Body_Needed_For_SAL (Uent)
410 then
411 Write_Info_Str (" BN");
412 end if;
414 if Dynamic_Elab (Unit_Num) then
415 Write_Info_Str (" DE");
416 end if;
418 -- Set the Elaborate_Body indication if either an explicit pragma
419 -- was present, or if this is an instantiation.
421 if Has_Pragma_Elaborate_Body (Uent)
422 or else (Ukind = N_Package_Declaration
423 and then Is_Generic_Instance (Uent)
424 and then Present (Corresponding_Body (Unit (Unode))))
425 then
426 Write_Info_Str (" EB");
427 end if;
429 -- Now see if we should tell the binder that an elaboration entity
430 -- is present, which must be set to true during elaboration.
431 -- We generate the indication if the following condition is met:
433 -- If this is a spec ...
435 if (Is_Subprogram (Uent)
436 or else Ekind (Uent) = E_Package
437 or else Is_Generic_Unit (Uent))
439 -- and an elaboration entity was declared ...
441 and then Present (Elaboration_Entity (Uent))
443 -- and either the elaboration flag is required ...
445 and then (Elaboration_Entity_Required (Uent)
447 -- or this unit has elaboration code ...
449 or else not Has_No_Elaboration_Code (Unode)
451 -- or this unit has a separate body and this
452 -- body has elaboration code.
454 or else
455 (Ekind (Uent) = E_Package
456 and then Present (Body_Entity (Uent))
457 and then
458 not Has_No_Elaboration_Code
459 (Parent (Declaration_Node (Body_Entity (Uent))))))
460 then
461 Write_Info_Str (" EE");
462 end if;
464 if Has_No_Elaboration_Code (Unode) then
465 Write_Info_Str (" NE");
466 end if;
468 Write_Info_Str (" O");
469 Write_Info_Char (OA_Setting (Unit_Num));
471 if Ekind_In (Uent, E_Package, E_Package_Body)
472 and then Present (Finalizer (Uent))
473 then
474 Write_Info_Str (" PF");
475 end if;
477 if Is_Preelaborated (Uent) then
478 Write_Info_Str (" PR");
479 end if;
481 if Is_Pure (Uent) then
482 Write_Info_Str (" PU");
483 end if;
485 if Has_RACW (Unit_Num) then
486 Write_Info_Str (" RA");
487 end if;
489 if Is_Remote_Call_Interface (Uent) then
490 Write_Info_Str (" RC");
491 end if;
493 if Is_Remote_Types (Uent) then
494 Write_Info_Str (" RT");
495 end if;
497 if Serious_Errors_Detected /= 0 then
498 Write_Info_Str (" SE");
499 end if;
501 if Is_Shared_Passive (Uent) then
502 Write_Info_Str (" SP");
503 end if;
505 if Ukind = N_Subprogram_Declaration
506 or else Ukind = N_Subprogram_Body
507 then
508 Write_Info_Str (" SU");
510 elsif Ukind = N_Package_Declaration
511 or else
512 Ukind = N_Package_Body
513 then
514 -- If this is a wrapper package for a subprogram instantiation,
515 -- the user view is the subprogram. Note that in this case the
516 -- ali file contains both the spec and body of the instance.
518 if Is_Wrapper_Package (Uent) then
519 Write_Info_Str (" SU");
520 else
521 Write_Info_Str (" PK");
522 end if;
524 elsif Ukind = N_Generic_Package_Declaration then
525 Write_Info_Str (" PK");
527 end if;
529 if Ukind in N_Generic_Declaration
530 or else
531 (Present (Library_Unit (Unode))
532 and then
533 Nkind (Unit (Library_Unit (Unode))) in N_Generic_Declaration)
534 then
535 Write_Info_Str (" GE");
536 end if;
538 if not Is_Internal_File_Name (Unit_File_Name (Unit_Num), True) then
539 case Identifier_Casing (Source_Index (Unit_Num)) is
540 when All_Lower_Case => Write_Info_Str (" IL");
541 when All_Upper_Case => Write_Info_Str (" IU");
542 when others => null;
543 end case;
545 case Keyword_Casing (Source_Index (Unit_Num)) is
546 when Mixed_Case => Write_Info_Str (" KM");
547 when All_Upper_Case => Write_Info_Str (" KU");
548 when others => null;
549 end case;
550 end if;
552 if Initialize_Scalars or else Invalid_Value_Used then
553 Write_Info_Str (" IS");
554 end if;
556 Write_Info_EOL;
558 -- Generate with lines, first those that are directly with'ed
560 for J in With_Flags'Range loop
561 With_Flags (J) := False;
562 Elab_Flags (J) := False;
563 Elab_All_Flags (J) := False;
564 Elab_Des_Flags (J) := False;
565 Elab_All_Des_Flags (J) := False;
566 Implicit_With (J) := Unknown;
567 end loop;
569 Collect_Withs (Unode);
571 -- For a body, we must also check for any subunits which belong to
572 -- it and which have context clauses of their own, since these
573 -- with'ed units are part of its own elaboration dependencies.
575 if Nkind (Unit (Unode)) in N_Unit_Body then
576 for S in Units.First .. Last_Unit loop
578 -- We are only interested in subunits. For preproc. data and
579 -- def. files, Cunit is Empty, so we need to test that first.
581 if Cunit (S) /= Empty
582 and then Nkind (Unit (Cunit (S))) = N_Subunit
583 then
584 Pnode := Library_Unit (Cunit (S));
586 -- In gnatc mode, the errors in the subunits will not have
587 -- been recorded, but the analysis of the subunit may have
588 -- failed. There is no information to add to ALI file in
589 -- this case.
591 if No (Pnode) then
592 exit;
593 end if;
595 -- Find ultimate parent of the subunit
597 while Nkind (Unit (Pnode)) = N_Subunit loop
598 Pnode := Library_Unit (Pnode);
599 end loop;
601 -- See if it belongs to current unit, and if so, include
602 -- its with_clauses.
604 if Pnode = Unode then
605 Collect_Withs (Cunit (S));
606 end if;
607 end if;
608 end loop;
609 end if;
611 Write_With_Lines;
613 -- Generate the linker option lines
615 for J in 1 .. Linker_Option_Lines.Last loop
617 -- Pragma Linker_Options is not allowed in predefined generic
618 -- units. This is because they won't be read, due to the fact that
619 -- with lines for generic units lack the file name and lib name
620 -- parameters (see Lib_Writ spec for an explanation).
622 if Is_Generic_Unit (Cunit_Entity (Main_Unit))
623 and then
624 Is_Predefined_File_Name (Unit_File_Name (Current_Sem_Unit))
625 and then Linker_Option_Lines.Table (J).Unit = Unit_Num
626 then
627 Set_Standard_Error;
628 Write_Line
629 ("linker options not allowed in predefined generic unit");
630 raise Unrecoverable_Error;
631 end if;
633 -- Output one linker option line
635 declare
636 S : Linker_Option_Entry renames Linker_Option_Lines.Table (J);
637 begin
638 if S.Unit = Unit_Num then
639 Write_Info_Initiate ('L');
640 Write_Info_Char (' ');
641 Write_Info_Slit (S.Option);
642 Write_Info_EOL;
643 end if;
644 end;
645 end loop;
647 -- Output notes
649 for J in 1 .. Notes.Last loop
650 declare
651 N : constant Node_Id := Notes.Table (J);
652 L : constant Source_Ptr := Sloc (N);
653 U : constant Unit_Number_Type :=
654 Unit (Get_Source_File_Index (L));
655 C : Character;
657 Note_Unit : Unit_Number_Type;
658 -- The unit in whose U section this note must be emitted:
659 -- notes for subunits are emitted along with the main unit;
660 -- all other notes are emitted as part of the enclosing
661 -- compilation unit.
663 begin
664 if U /= No_Unit and then Nkind (Unit (Cunit (U))) = N_Subunit
665 then
666 Note_Unit := Main_Unit;
667 else
668 Note_Unit := U;
669 end if;
671 if Note_Unit = Unit_Num then
672 Write_Info_Initiate ('N');
673 Write_Info_Char (' ');
675 case Chars (Pragma_Identifier (N)) is
676 when Name_Annotate =>
677 C := 'A';
678 when Name_Comment =>
679 C := 'C';
680 when Name_Ident =>
681 C := 'I';
682 when Name_Title =>
683 C := 'T';
684 when Name_Subtitle =>
685 C := 'S';
686 when others =>
687 raise Program_Error;
688 end case;
690 Write_Info_Char (C);
691 Write_Info_Int (Int (Get_Logical_Line_Number (L)));
692 Write_Info_Char (':');
693 Write_Info_Int (Int (Get_Column_Number (L)));
695 -- Indicate source file of annotation if different from
696 -- compilation unit source file (case of annotation coming
697 -- from a separate).
699 if Get_Source_File_Index (L) /= Source_Index (Unit_Num) then
700 Write_Info_Char (':');
701 Write_Info_Name (File_Name (Get_Source_File_Index (L)));
702 end if;
704 declare
705 A : Node_Id;
707 begin
708 A := First (Pragma_Argument_Associations (N));
709 while Present (A) loop
710 Write_Info_Char (' ');
712 if Chars (A) /= No_Name then
713 Write_Info_Name (Chars (A));
714 Write_Info_Char (':');
715 end if;
717 declare
718 Expr : constant Node_Id := Expression (A);
720 begin
721 if Nkind (Expr) = N_Identifier then
722 Write_Info_Name (Chars (Expr));
724 elsif Nkind (Expr) = N_Integer_Literal
725 and then Is_OK_Static_Expression (Expr)
726 then
727 Write_Info_Uint (Intval (Expr));
729 elsif Nkind (Expr) = N_String_Literal
730 and then Is_OK_Static_Expression (Expr)
731 then
732 Write_Info_Slit (Strval (Expr));
734 else
735 Write_Info_Str ("<expr>");
736 end if;
737 end;
739 Next (A);
740 end loop;
741 end;
743 Write_Info_EOL;
744 end if;
745 end;
746 end loop;
747 end Write_Unit_Information;
749 ----------------------
750 -- Write_With_Lines --
751 ----------------------
753 procedure Write_With_Lines is
754 Pname : constant Unit_Name_Type :=
755 Get_Parent_Spec_Name (Unit_Name (Main_Unit));
756 Body_Fname : File_Name_Type;
757 Body_Index : Nat;
758 Cunit : Node_Id;
759 Fname : File_Name_Type;
760 Num_Withs : Int := 0;
761 Unum : Unit_Number_Type;
762 Uname : Unit_Name_Type;
763 With_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 1));
765 procedure Write_With_File_Names
766 (Nam : in out File_Name_Type;
767 Idx : Nat);
768 -- Write source file name Nam and ALI file name for unit index Idx.
769 -- Possibly change Nam to lowercase (generating a new file name).
771 --------------------------
772 -- Write_With_File_Name --
773 --------------------------
775 procedure Write_With_File_Names
776 (Nam : in out File_Name_Type;
777 Idx : Nat)
779 begin
780 if not File_Names_Case_Sensitive then
781 Get_Name_String (Nam);
782 To_Lower (Name_Buffer (1 .. Name_Len));
783 Nam := Name_Find;
784 end if;
786 Write_Info_Name (Nam);
787 Write_Info_Tab (49);
788 Write_Info_Name (Lib_File_Name (Nam, Idx));
789 end Write_With_File_Names;
791 -- Start of processing for Write_With_Lines
793 begin
794 -- Loop to build the with table. A with on the main unit itself
795 -- is ignored (AARM 10.2(14a)). Such a with-clause can occur if
796 -- the main unit is a subprogram with no spec, and a subunit of
797 -- it unnecessarily withs the parent.
799 for J in Units.First + 1 .. Last_Unit loop
801 -- Add element to with table if it is with'ed or if it is the
802 -- parent spec of the main unit (case of main unit is a child
803 -- unit). The latter with is not needed for semantic purposes,
804 -- but is required by the binder for elaboration purposes. For
805 -- preprocessing data and definition files, there is no Unit_Name,
806 -- check for that first.
808 if Unit_Name (J) /= No_Unit_Name
809 and then (With_Flags (J) or else Unit_Name (J) = Pname)
810 then
811 Num_Withs := Num_Withs + 1;
812 With_Table (Num_Withs) := J;
813 end if;
814 end loop;
816 -- Sort and output the table
818 Sort (With_Table (1 .. Num_Withs));
820 for J in 1 .. Num_Withs loop
821 Unum := With_Table (J);
823 -- Do not generate a with line for an ignored Ghost unit because
824 -- the unit does not have an ALI file.
826 if Is_Ignored_Ghost_Entity (Cunit_Entity (Unum)) then
827 goto Next_With_Line;
828 end if;
830 Cunit := Units.Table (Unum).Cunit;
831 Uname := Units.Table (Unum).Unit_Name;
832 Fname := Units.Table (Unum).Unit_File_Name;
834 if Implicit_With (Unum) = Yes then
835 Write_Info_Initiate ('Z');
837 elsif Ekind (Cunit_Entity (Unum)) = E_Package
838 and then From_Limited_With (Cunit_Entity (Unum))
839 then
840 Write_Info_Initiate ('Y');
842 else
843 Write_Info_Initiate ('W');
844 end if;
846 Write_Info_Char (' ');
847 Write_Info_Name (Uname);
849 -- Now we need to figure out the names of the files that contain
850 -- the with'ed unit. These will usually be the files for the body,
851 -- except in the case of a package that has no body. Note that we
852 -- have a specific exemption here for predefined library generics
853 -- (see comments for Generic_May_Lack_ALI). We do not generate
854 -- dependency upon the ALI file for such units. Older compilers
855 -- used to not support generating code (and ALI) for generics, and
856 -- we want to avoid having different processing (namely, different
857 -- lists of files to be compiled) for different stages of the
858 -- bootstrap.
860 if not ((Nkind (Unit (Cunit)) in N_Generic_Declaration
861 or else
862 Nkind (Unit (Cunit)) in N_Generic_Renaming_Declaration)
863 and then Generic_May_Lack_ALI (Fname))
865 -- In SPARK mode, always generate the dependencies on ALI
866 -- files, which are required to compute frame conditions
867 -- of subprograms.
869 or else GNATprove_Mode
870 then
871 Write_Info_Tab (25);
873 if Is_Spec_Name (Uname) then
874 Body_Fname :=
875 Get_File_Name
876 (Get_Body_Name (Uname),
877 Subunit => False, May_Fail => True);
879 Body_Index :=
880 Get_Unit_Index
881 (Get_Body_Name (Uname));
883 if Body_Fname = No_File then
884 Body_Fname := Get_File_Name (Uname, Subunit => False);
885 Body_Index := Get_Unit_Index (Uname);
886 end if;
888 else
889 Body_Fname := Get_File_Name (Uname, Subunit => False);
890 Body_Index := Get_Unit_Index (Uname);
891 end if;
893 -- A package is considered to have a body if it requires
894 -- a body or if a body is present in Ada 83 mode.
896 if Body_Required (Cunit)
897 or else (Ada_Version = Ada_83
898 and then Full_Source_Name (Body_Fname) /= No_File)
899 then
900 Write_With_File_Names (Body_Fname, Body_Index);
901 else
902 Write_With_File_Names (Fname, Munit_Index (Unum));
903 end if;
905 if Ekind (Cunit_Entity (Unum)) = E_Package
906 and then From_Limited_With (Cunit_Entity (Unum))
907 then
908 null;
909 else
910 if Elab_Flags (Unum) then
911 Write_Info_Str (" E");
912 end if;
914 if Elab_All_Flags (Unum) then
915 Write_Info_Str (" EA");
916 end if;
918 if Elab_Des_Flags (Unum) then
919 Write_Info_Str (" ED");
920 end if;
922 if Elab_All_Des_Flags (Unum) then
923 Write_Info_Str (" AD");
924 end if;
925 end if;
926 end if;
928 Write_Info_EOL;
930 <<Next_With_Line>>
931 null;
932 end loop;
934 -- Finally generate the special lines for cases of Restriction_Set
935 -- with No_Dependence and no restriction present.
937 declare
938 Unam : Unit_Name_Type;
940 begin
941 for J in Restriction_Set_Dependences.First ..
942 Restriction_Set_Dependences.Last
943 loop
944 Unam := Restriction_Set_Dependences.Table (J);
946 -- Don't need an entry if already in the unit table
948 for U in 0 .. Last_Unit loop
949 if Unit_Name (U) = Unam then
950 goto Next_Restriction_Set;
951 end if;
952 end loop;
954 -- Otherwise generate the entry
956 Write_Info_Initiate ('W');
957 Write_Info_Char (' ');
958 Write_Info_Name (Unam);
959 Write_Info_EOL;
961 <<Next_Restriction_Set>>
962 null;
963 end loop;
964 end;
965 end Write_With_Lines;
967 -- Start of processing for Write_ALI
969 begin
970 -- We never write an ALI file if the original operating mode was
971 -- syntax-only (-gnats switch used in compiler invocation line)
973 if Original_Operating_Mode = Check_Syntax
974 or flag_compare_debug /= 0
975 then
976 return;
977 end if;
979 -- Generation of ALI files may be disabled, e.g. for formal verification
980 -- back-end.
982 if Disable_ALI_File then
983 return;
984 end if;
986 -- Build sorted source dependency table. We do this right away, because
987 -- it is referenced by Up_To_Date_ALI_File_Exists.
989 for Unum in Units.First .. Last_Unit loop
990 if Cunit_Entity (Unum) = Empty
991 or else not From_Limited_With (Cunit_Entity (Unum))
992 then
993 -- Units that are not analyzed need not appear in the dependency
994 -- list. These units are either units appearing in limited_with
995 -- clauses of other units, or units loaded for inlining that end
996 -- up not inlined by a later decision of the inlining code, to
997 -- prevent circularities. We want to exclude these files from the
998 -- list of dependencies, so that the dependency number of other
999 -- is correctly set, as that number is used by cross-reference
1000 -- tools to relate entity information to the unit in which they
1001 -- are declared.
1003 if Present (Cunit_Entity (Unum))
1004 and then Ekind (Cunit_Entity (Unum)) = E_Void
1005 and then Nkind (Unit (Cunit (Unum))) /= N_Subunit
1006 and then Serious_Errors_Detected = 0
1007 then
1008 null;
1010 else
1011 Num_Sdep := Num_Sdep + 1;
1012 Sdep_Table (Num_Sdep) := Unum;
1013 end if;
1014 end if;
1015 end loop;
1017 -- Sort the table so that the D lines are in order
1019 Lib.Sort (Sdep_Table (1 .. Num_Sdep));
1021 -- If we are not generating code, and there is an up to date ALI file
1022 -- file accessible, read it, and acquire the compilation arguments from
1023 -- this file. In GNATprove mode, always generate the ALI file, which
1024 -- contains a special section for formal verification.
1026 if Operating_Mode /= Generate_Code and then not GNATprove_Mode then
1027 if Up_To_Date_ALI_File_Exists then
1028 Update_Tables_From_ALI_File;
1029 return;
1030 end if;
1031 end if;
1033 -- Otherwise acquire compilation arguments and prepare to write out a
1034 -- new ali file.
1036 Create_Output_Library_Info;
1038 -- Output version line
1040 Write_Info_Initiate ('V');
1041 Write_Info_Str (" """);
1042 Write_Info_Str (Verbose_Library_Version);
1043 Write_Info_Char ('"');
1045 Write_Info_EOL;
1047 -- Output main program line if this is acceptable main program
1049 Output_Main_Program_Line : declare
1050 U : Node_Id := Unit (Units.Table (Main_Unit).Cunit);
1051 S : Node_Id;
1053 procedure M_Parameters;
1054 -- Output parameters for main program line
1056 ------------------
1057 -- M_Parameters --
1058 ------------------
1060 procedure M_Parameters is
1061 begin
1062 if Main_Priority (Main_Unit) /= Default_Main_Priority then
1063 Write_Info_Char (' ');
1064 Write_Info_Nat (Main_Priority (Main_Unit));
1065 end if;
1067 if Opt.Time_Slice_Set then
1068 Write_Info_Str (" T=");
1069 Write_Info_Nat (Opt.Time_Slice_Value);
1070 end if;
1072 if Main_CPU (Main_Unit) /= Default_Main_CPU then
1073 Write_Info_Str (" C=");
1074 Write_Info_Nat (Main_CPU (Main_Unit));
1075 end if;
1077 Write_Info_Str (" W=");
1078 Write_Info_Char
1079 (WC_Encoding_Letters (Wide_Character_Encoding_Method));
1081 Write_Info_EOL;
1082 end M_Parameters;
1084 -- Start of processing for Output_Main_Program_Line
1086 begin
1087 if Nkind (U) = N_Subprogram_Body
1088 or else
1089 (Nkind (U) = N_Package_Body
1090 and then
1091 Nkind (Original_Node (U)) in N_Subprogram_Instantiation)
1092 then
1093 -- If the unit is a subprogram instance, the entity for the
1094 -- subprogram is the alias of the visible entity, which is the
1095 -- related instance of the wrapper package. We retrieve the
1096 -- subprogram declaration of the desired entity.
1098 if Nkind (U) = N_Package_Body then
1099 U := Parent (Parent (
1100 Alias (Related_Instance (Defining_Unit_Name
1101 (Specification (Unit (Library_Unit (Parent (U)))))))));
1102 end if;
1104 S := Specification (U);
1106 -- A generic subprogram is never a main program
1108 if Nkind (U) = N_Subprogram_Body
1109 and then Present (Corresponding_Spec (U))
1110 and then
1111 Ekind_In (Corresponding_Spec (U), E_Generic_Procedure,
1112 E_Generic_Function)
1113 then
1114 null;
1116 elsif No (Parameter_Specifications (S)) then
1117 if Nkind (S) = N_Procedure_Specification then
1118 Write_Info_Initiate ('M');
1119 Write_Info_Str (" P");
1120 M_Parameters;
1122 else
1123 declare
1124 Nam : Node_Id := Defining_Unit_Name (S);
1126 begin
1127 -- If it is a child unit, get its simple name
1129 if Nkind (Nam) = N_Defining_Program_Unit_Name then
1130 Nam := Defining_Identifier (Nam);
1131 end if;
1133 if Is_Integer_Type (Etype (Nam)) then
1134 Write_Info_Initiate ('M');
1135 Write_Info_Str (" F");
1136 M_Parameters;
1137 end if;
1138 end;
1139 end if;
1140 end if;
1141 end if;
1142 end Output_Main_Program_Line;
1144 -- Write command argument ('A') lines
1146 for A in 1 .. Compilation_Switches.Last loop
1147 Write_Info_Initiate ('A');
1148 Write_Info_Char (' ');
1149 Write_Info_Str (Compilation_Switches.Table (A).all);
1150 Write_Info_Terminate;
1151 end loop;
1153 -- Output parameters ('P') line
1155 Write_Info_Initiate ('P');
1157 if Compilation_Errors then
1158 Write_Info_Str (" CE");
1159 end if;
1161 if Opt.Detect_Blocking then
1162 Write_Info_Str (" DB");
1163 end if;
1165 if Tasking_Used
1166 and then not Is_Predefined_File_Name (Unit_File_Name (Main_Unit))
1167 then
1168 if Locking_Policy /= ' ' then
1169 Write_Info_Str (" L");
1170 Write_Info_Char (Locking_Policy);
1171 end if;
1173 if Queuing_Policy /= ' ' then
1174 Write_Info_Str (" Q");
1175 Write_Info_Char (Queuing_Policy);
1176 end if;
1178 if Task_Dispatching_Policy /= ' ' then
1179 Write_Info_Str (" T");
1180 Write_Info_Char (Task_Dispatching_Policy);
1181 Write_Info_Char (' ');
1182 end if;
1183 end if;
1185 if GNATprove_Mode then
1186 Write_Info_Str (" GP");
1187 end if;
1189 if Partition_Elaboration_Policy /= ' ' then
1190 Write_Info_Str (" E");
1191 Write_Info_Char (Partition_Elaboration_Policy);
1192 end if;
1194 if not Object then
1195 Write_Info_Str (" NO");
1196 end if;
1198 if No_Run_Time_Mode then
1199 Write_Info_Str (" NR");
1200 end if;
1202 if Normalize_Scalars then
1203 Write_Info_Str (" NS");
1204 end if;
1206 if Default_SSO_Config /= ' ' then
1207 Write_Info_Str (" O");
1208 Write_Info_Char (Default_SSO_Config);
1209 end if;
1211 if Sec_Stack_Used then
1212 Write_Info_Str (" SS");
1213 end if;
1215 if Unreserve_All_Interrupts then
1216 Write_Info_Str (" UA");
1217 end if;
1219 if Front_End_Exceptions then
1220 Write_Info_Str (" FX");
1221 end if;
1223 if ZCX_Exceptions then
1224 Write_Info_Str (" ZX");
1225 end if;
1227 Write_Info_EOL;
1229 -- Before outputting the restrictions line, update the setting of
1230 -- the No_Elaboration_Code flag. Violations of this restriction
1231 -- cannot be detected until after the backend has been called since
1232 -- it is the backend that sets this flag. We have to check all units
1233 -- for which we have generated code
1235 for Unit in Units.First .. Last_Unit loop
1236 if Units.Table (Unit).Generate_Code or else Unit = Main_Unit then
1237 if not Has_No_Elaboration_Code (Cunit (Unit)) then
1238 Main_Restrictions.Violated (No_Elaboration_Code) := True;
1239 end if;
1240 end if;
1241 end loop;
1243 -- Positional case (only if debug flag -gnatd.R is set)
1245 if Debug_Flag_Dot_RR then
1247 -- Output first restrictions line
1249 Write_Info_Initiate ('R');
1250 Write_Info_Char (' ');
1252 -- First the information for the boolean restrictions
1254 for R in All_Boolean_Restrictions loop
1255 if Main_Restrictions.Set (R)
1256 and then not Restriction_Warnings (R)
1257 then
1258 Write_Info_Char ('r');
1259 elsif Main_Restrictions.Violated (R) then
1260 Write_Info_Char ('v');
1261 else
1262 Write_Info_Char ('n');
1263 end if;
1264 end loop;
1266 -- And now the information for the parameter restrictions
1268 for RP in All_Parameter_Restrictions loop
1269 if Main_Restrictions.Set (RP)
1270 and then not Restriction_Warnings (RP)
1271 then
1272 Write_Info_Char ('r');
1273 Write_Info_Nat (Nat (Main_Restrictions.Value (RP)));
1274 else
1275 Write_Info_Char ('n');
1276 end if;
1278 if not Main_Restrictions.Violated (RP)
1279 or else RP not in Checked_Parameter_Restrictions
1280 then
1281 Write_Info_Char ('n');
1282 else
1283 Write_Info_Char ('v');
1284 Write_Info_Nat (Nat (Main_Restrictions.Count (RP)));
1286 if Main_Restrictions.Unknown (RP) then
1287 Write_Info_Char ('+');
1288 end if;
1289 end if;
1290 end loop;
1292 Write_Info_EOL;
1294 -- Named case (if debug flag -gnatd.R is not set)
1296 else
1297 declare
1298 C : Character;
1300 begin
1301 -- Write RN header line with preceding blank line
1303 Write_Info_EOL;
1304 Write_Info_Initiate ('R');
1305 Write_Info_Char ('N');
1306 Write_Info_EOL;
1308 -- First the lines for the boolean restrictions
1310 for R in All_Boolean_Restrictions loop
1311 if Main_Restrictions.Set (R)
1312 and then not Restriction_Warnings (R)
1313 then
1314 C := 'R';
1315 elsif Main_Restrictions.Violated (R) then
1316 C := 'V';
1317 else
1318 goto Continue;
1319 end if;
1321 Write_Info_Initiate ('R');
1322 Write_Info_Char (C);
1323 Write_Info_Char (' ');
1324 Write_Info_Str (All_Boolean_Restrictions'Image (R));
1325 Write_Info_EOL;
1327 <<Continue>>
1328 null;
1329 end loop;
1330 end;
1332 -- And now the lines for the parameter restrictions
1334 for RP in All_Parameter_Restrictions loop
1335 if Main_Restrictions.Set (RP)
1336 and then not Restriction_Warnings (RP)
1337 then
1338 Write_Info_Initiate ('R');
1339 Write_Info_Str ("R ");
1340 Write_Info_Str (All_Parameter_Restrictions'Image (RP));
1341 Write_Info_Char ('=');
1342 Write_Info_Nat (Nat (Main_Restrictions.Value (RP)));
1343 Write_Info_EOL;
1344 end if;
1346 if not Main_Restrictions.Violated (RP)
1347 or else RP not in Checked_Parameter_Restrictions
1348 then
1349 null;
1350 else
1351 Write_Info_Initiate ('R');
1352 Write_Info_Str ("V ");
1353 Write_Info_Str (All_Parameter_Restrictions'Image (RP));
1354 Write_Info_Char ('=');
1355 Write_Info_Nat (Nat (Main_Restrictions.Count (RP)));
1357 if Main_Restrictions.Unknown (RP) then
1358 Write_Info_Char ('+');
1359 end if;
1361 Write_Info_EOL;
1362 end if;
1363 end loop;
1364 end if;
1366 -- Output R lines for No_Dependence entries
1368 for J in No_Dependences.First .. No_Dependences.Last loop
1369 if In_Extended_Main_Source_Unit (No_Dependences.Table (J).Unit)
1370 and then not No_Dependences.Table (J).Warn
1371 then
1372 Write_Info_Initiate ('R');
1373 Write_Info_Char (' ');
1374 Write_Unit_Name (No_Dependences.Table (J).Unit);
1375 Write_Info_EOL;
1376 end if;
1377 end loop;
1379 -- Output interrupt state lines
1381 for J in Interrupt_States.First .. Interrupt_States.Last loop
1382 Write_Info_Initiate ('I');
1383 Write_Info_Char (' ');
1384 Write_Info_Nat (Interrupt_States.Table (J).Interrupt_Number);
1385 Write_Info_Char (' ');
1386 Write_Info_Char (Interrupt_States.Table (J).Interrupt_State);
1387 Write_Info_Char (' ');
1388 Write_Info_Nat
1389 (Nat (Get_Logical_Line_Number
1390 (Interrupt_States.Table (J).Pragma_Loc)));
1391 Write_Info_EOL;
1392 end loop;
1394 -- Output priority specific dispatching lines
1396 for J in Specific_Dispatching.First .. Specific_Dispatching.Last loop
1397 Write_Info_Initiate ('S');
1398 Write_Info_Char (' ');
1399 Write_Info_Char (Specific_Dispatching.Table (J).Dispatching_Policy);
1400 Write_Info_Char (' ');
1401 Write_Info_Nat (Specific_Dispatching.Table (J).First_Priority);
1402 Write_Info_Char (' ');
1403 Write_Info_Nat (Specific_Dispatching.Table (J).Last_Priority);
1404 Write_Info_Char (' ');
1405 Write_Info_Nat
1406 (Nat (Get_Logical_Line_Number
1407 (Specific_Dispatching.Table (J).Pragma_Loc)));
1408 Write_Info_EOL;
1409 end loop;
1411 -- Loop through file table to output information for all units for which
1412 -- we have generated code, as marked by the Generate_Code flag.
1414 for Unit in Units.First .. Last_Unit loop
1415 if Units.Table (Unit).Generate_Code
1416 or else Unit = Main_Unit
1417 then
1418 Write_Info_EOL; -- blank line
1419 Write_Unit_Information (Unit);
1420 end if;
1421 end loop;
1423 Write_Info_EOL; -- blank line
1425 -- Output external version reference lines
1427 for J in 1 .. Version_Ref.Last loop
1428 Write_Info_Initiate ('E');
1429 Write_Info_Char (' ');
1431 for K in 1 .. String_Length (Version_Ref.Table (J)) loop
1432 Write_Info_Char_Code (Get_String_Char (Version_Ref.Table (J), K));
1433 end loop;
1435 Write_Info_EOL;
1436 end loop;
1438 -- Prepare to output the source dependency lines
1440 declare
1441 Unum : Unit_Number_Type;
1442 -- Number of unit being output
1444 Sind : Source_File_Index;
1445 -- Index of corresponding source file
1447 Fname : File_Name_Type;
1449 begin
1450 for J in 1 .. Num_Sdep loop
1451 Unum := Sdep_Table (J);
1452 Units.Table (Unum).Dependency_Num := J;
1453 Sind := Units.Table (Unum).Source_Index;
1455 Write_Info_Initiate ('D');
1456 Write_Info_Char (' ');
1458 -- Normal case of a unit entry with a source index
1460 if Sind /= No_Source_File then
1461 Fname := File_Name (Sind);
1463 -- Ensure that on platforms where the file names are not case
1464 -- sensitive, the recorded file name is in lower case.
1466 if not File_Names_Case_Sensitive then
1467 Get_Name_String (Fname);
1468 To_Lower (Name_Buffer (1 .. Name_Len));
1469 Fname := Name_Find;
1470 end if;
1472 Write_Info_Name_May_Be_Quoted (Fname);
1473 Write_Info_Tab (25);
1474 Write_Info_Str (String (Time_Stamp (Sind)));
1475 Write_Info_Char (' ');
1476 Write_Info_Str (Get_Hex_String (Source_Checksum (Sind)));
1478 -- If the dependency comes from a limited_with clause, record
1479 -- limited_checksum. This is disabled until full checksum
1480 -- changes are checked.
1482 -- if Present (Cunit_Entity (Unum))
1483 -- and then From_Limited_With (Cunit_Entity (Unum))
1484 -- then
1485 -- Write_Info_Char (' ');
1486 -- Write_Info_Char ('Y');
1487 -- Write_Info_Str (Get_Hex_String (Limited_Chk_Sum (Sind)));
1488 -- end if;
1490 -- If subunit, add unit name, omitting the %b at the end
1492 if Present (Cunit (Unum)) then
1493 Get_Decoded_Name_String (Unit_Name (Unum));
1494 Write_Info_Char (' ');
1496 if Nkind (Unit (Cunit (Unum))) = N_Subunit then
1497 Write_Info_Str (Name_Buffer (1 .. Name_Len - 2));
1498 else
1499 Write_Info_Str (Name_Buffer (1 .. Name_Len));
1500 end if;
1501 end if;
1503 -- If Source_Reference pragma used, output information
1505 if Num_SRef_Pragmas (Sind) > 0 then
1506 Write_Info_Char (' ');
1508 if Num_SRef_Pragmas (Sind) = 1 then
1509 Write_Info_Nat (Int (First_Mapped_Line (Sind)));
1510 else
1511 Write_Info_Nat (0);
1512 end if;
1514 Write_Info_Char (':');
1515 Write_Info_Name (Reference_Name (Sind));
1516 end if;
1518 -- Case where there is no source index (happens for missing
1519 -- files). In this case we write a dummy time stamp.
1521 else
1522 Write_Info_Name (Unit_File_Name (Unum));
1523 Write_Info_Tab (25);
1524 Write_Info_Str (String (Dummy_Time_Stamp));
1525 Write_Info_Char (' ');
1526 Write_Info_Str (Get_Hex_String (0));
1527 end if;
1529 Write_Info_EOL;
1530 end loop;
1531 end;
1533 -- Output cross-references
1535 if Opt.Xref_Active then
1536 Output_References;
1537 end if;
1539 -- Output SCO information if present
1541 if Generate_SCO then
1542 SCO_Record_Filtered;
1543 SCO_Output;
1544 end if;
1546 -- Output SPARK cross-reference information if needed
1548 if Opt.Xref_Active and then GNATprove_Mode then
1549 SPARK_Specific.Collect_SPARK_Xrefs (Sdep_Table => Sdep_Table,
1550 Num_Sdep => Num_Sdep);
1551 SPARK_Specific.Output_SPARK_Xrefs;
1552 end if;
1554 -- Output final blank line and we are done. This final blank line is
1555 -- probably junk, but we don't feel like making an incompatible change.
1557 Write_Info_Terminate;
1558 Close_Output_Library_Info;
1559 end Write_ALI;
1561 ---------------------
1562 -- Write_Unit_Name --
1563 ---------------------
1565 procedure Write_Unit_Name (N : Node_Id) is
1566 begin
1567 if Nkind (N) = N_Identifier then
1568 Write_Info_Name (Chars (N));
1570 else
1571 pragma Assert (Nkind (N) = N_Selected_Component);
1572 Write_Unit_Name (Prefix (N));
1573 Write_Info_Char ('.');
1574 Write_Unit_Name (Selector_Name (N));
1575 end if;
1576 end Write_Unit_Name;
1578 end Lib.Writ;