Fix date
[official-gcc.git] / gcc / ada / lib-writ.adb
blob8c36957228ccb5330df4d266abf0ccce26444384
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-2017, 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 Is_Predefined_Renaming => False,
91 Is_Internal_Unit => False,
92 Is_Predefined_Unit => False,
93 Filler2 => False,
94 Loading => False,
95 Main_Priority => -1,
96 Main_CPU => -1,
97 Munit_Index => 0,
98 No_Elab_Code_All => False,
99 Serial_Number => 0,
100 Version => 0,
101 Error_Location => No_Location,
102 OA_Setting => 'O');
103 end Add_Preprocessing_Dependency;
105 ------------------------------
106 -- Ensure_System_Dependency --
107 ------------------------------
109 procedure Ensure_System_Dependency is
110 System_Uname : Unit_Name_Type;
111 -- Unit name for system spec if needed for dummy entry
113 System_Fname : File_Name_Type;
114 -- File name for system spec if needed for dummy entry
116 begin
117 -- Nothing to do if we already compiled System
119 for Unum in Units.First .. Last_Unit loop
120 if Units.Table (Unum).Source_Index = System_Source_File_Index then
121 return;
122 end if;
123 end loop;
125 -- If no entry for system.ads in the units table, then add a entry
126 -- to the units table for system.ads, which will be referenced when
127 -- the ali file is generated. We need this because every unit depends
128 -- on system as a result of Targparm scanning the system.ads file to
129 -- determine the target dependent parameters for the compilation.
131 Name_Len := 6;
132 Name_Buffer (1 .. 6) := "system";
133 System_Uname := Name_To_Unit_Name (Name_Enter);
134 System_Fname := File_Name (System_Source_File_Index);
136 Units.Increment_Last;
137 Units.Table (Units.Last) :=
138 (Unit_File_Name => System_Fname,
139 Unit_Name => System_Uname,
140 Expected_Unit => System_Uname,
141 Source_Index => System_Source_File_Index,
142 Cunit => Empty,
143 Cunit_Entity => Empty,
144 Dependency_Num => 0,
145 Dynamic_Elab => False,
146 Fatal_Error => None,
147 Generate_Code => False,
148 Has_RACW => False,
149 Filler => False,
150 Ident_String => Empty,
151 Is_Predefined_Renaming => False,
152 Is_Internal_Unit => True,
153 Is_Predefined_Unit => True,
154 Filler2 => False,
155 Loading => False,
156 Main_Priority => -1,
157 Main_CPU => -1,
158 Munit_Index => 0,
159 No_Elab_Code_All => False,
160 Serial_Number => 0,
161 Version => 0,
162 Error_Location => No_Location,
163 OA_Setting => 'O');
165 -- Parse system.ads so that the checksum is set right. Style checks are
166 -- not applied. The Ekind is set to ensure that this reference is always
167 -- present in the ali file.
169 declare
170 Save_Mindex : constant Nat := Multiple_Unit_Index;
171 Save_Style : constant Boolean := Style_Check;
172 begin
173 Multiple_Unit_Index := 0;
174 Style_Check := False;
175 Initialize_Scanner (Units.Last, System_Source_File_Index);
176 Discard_List (Par (Configuration_Pragmas => False));
177 Set_Ekind (Cunit_Entity (Units.Last), E_Package);
178 Set_Scope (Cunit_Entity (Units.Last), Standard_Standard);
179 Style_Check := Save_Style;
180 Multiple_Unit_Index := Save_Mindex;
181 end;
182 end Ensure_System_Dependency;
184 ---------------
185 -- Write_ALI --
186 ---------------
188 procedure Write_ALI (Object : Boolean) is
190 ----------------
191 -- Local Data --
192 ----------------
194 Last_Unit : constant Unit_Number_Type := Units.Last;
195 -- Record unit number of last unit. We capture this in case we
196 -- have to add a dummy entry to the unit table for package System.
198 With_Flags : array (Units.First .. Last_Unit) of Boolean;
199 -- Array of flags to show which units are with'ed
201 Elab_Flags : array (Units.First .. Last_Unit) of Boolean;
202 -- Array of flags to show which units have pragma Elaborate set
204 Elab_All_Flags : array (Units.First .. Last_Unit) of Boolean;
205 -- Array of flags to show which units have pragma Elaborate All set
207 Elab_Des_Flags : array (Units.First .. Last_Unit) of Boolean;
208 -- Array of flags to show which units have Elaborate_Desirable set
210 Elab_All_Des_Flags : array (Units.First .. Last_Unit) of Boolean;
211 -- Array of flags to show which units have Elaborate_All_Desirable set
213 type Yes_No is (Unknown, Yes, No);
214 Implicit_With : array (Units.First .. Last_Unit) of Yes_No;
215 -- Indicates if an implicit with has been given for the unit. Yes if
216 -- certainly present, no if certainly absent, unkonwn if not known.
218 Sdep_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 2));
219 -- Sorted table of source dependencies. One extra entry in case we
220 -- have to add a dummy entry for System.
222 Num_Sdep : Nat := 0;
223 -- Number of active entries in Sdep_Table
225 flag_compare_debug : Int;
226 pragma Import (C, flag_compare_debug);
227 -- Import from toplev.c
229 -----------------------
230 -- Local Subprograms --
231 -----------------------
233 procedure Collect_Withs (Cunit : Node_Id);
234 -- Collect with lines for entries in the context clause of the
235 -- given compilation unit, Cunit.
237 procedure Update_Tables_From_ALI_File;
238 -- Given an up to date ALI file (see Up_To_Date_ALI_file_Exists
239 -- function), update tables from the ALI information, including
240 -- specifically the Compilation_Switches table.
242 function Up_To_Date_ALI_File_Exists return Boolean;
243 -- If there exists an ALI file that is up to date, then this function
244 -- initializes the tables in the ALI spec to contain information on
245 -- this file (using Scan_ALI) and returns True. If no file exists,
246 -- or the file is not up to date, then False is returned.
248 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type);
249 -- Write out the library information for one unit for which code is
250 -- generated (includes unit line and with lines).
252 procedure Write_With_Lines;
253 -- Write out with lines collected by calls to Collect_Withs
255 -------------------
256 -- Collect_Withs --
257 -------------------
259 procedure Collect_Withs (Cunit : Node_Id) is
260 Item : Node_Id;
261 Unum : Unit_Number_Type;
263 begin
264 Item := First (Context_Items (Cunit));
265 while Present (Item) loop
267 -- Process with clause
269 -- Ada 2005 (AI-50217): limited with_clauses do not create
270 -- dependencies, but must be recorded as components of the
271 -- partition, in case there is no regular with_clause for
272 -- the unit anywhere else.
274 if Nkind (Item) = N_With_Clause then
275 Unum := Get_Cunit_Unit_Number (Library_Unit (Item));
276 With_Flags (Unum) := True;
278 if not Limited_Present (Item) then
279 if Elaborate_Present (Item) then
280 Elab_Flags (Unum) := True;
281 end if;
283 if Elaborate_All_Present (Item) then
284 Elab_All_Flags (Unum) := True;
285 end if;
287 if Elaborate_All_Desirable (Item) then
288 Elab_All_Des_Flags (Unum) := True;
289 end if;
291 if Elaborate_Desirable (Item) then
292 Elab_Des_Flags (Unum) := True;
293 end if;
295 else
296 Set_From_Limited_With (Cunit_Entity (Unum));
297 end if;
299 if Implicit_With (Unum) /= Yes then
300 if Implicit_With_From_Instantiation (Item) then
301 Implicit_With (Unum) := Yes;
302 else
303 Implicit_With (Unum) := No;
304 end if;
305 end if;
306 end if;
308 Next (Item);
309 end loop;
310 end Collect_Withs;
312 --------------------------------
313 -- Up_To_Date_ALI_File_Exists --
314 --------------------------------
316 function Up_To_Date_ALI_File_Exists return Boolean is
317 Name : File_Name_Type;
318 Text : Text_Buffer_Ptr;
319 Id : Sdep_Id;
320 Sind : Source_File_Index;
322 begin
323 Opt.Check_Object_Consistency := True;
324 Read_Library_Info (Name, Text);
326 -- Return if we could not find an ALI file
328 if Text = null then
329 return False;
330 end if;
332 -- Return if ALI file has bad format
334 Initialize_ALI;
336 if Scan_ALI (Name, Text, False, Err => True) = No_ALI_Id then
337 return False;
338 end if;
340 -- If we have an OK ALI file, check if it is up to date
341 -- Note that we assume that the ALI read has all the entries
342 -- we have in our table, plus some additional ones (that can
343 -- come from expansion).
345 Id := First_Sdep_Entry;
346 for J in 1 .. Num_Sdep loop
347 Sind := Units.Table (Sdep_Table (J)).Source_Index;
349 while Sdep.Table (Id).Sfile /= File_Name (Sind) loop
350 if Id = Sdep.Last then
351 return False;
352 else
353 Id := Id + 1;
354 end if;
355 end loop;
357 if Sdep.Table (Id).Stamp /= Time_Stamp (Sind) then
358 return False;
359 end if;
360 end loop;
362 return True;
363 end Up_To_Date_ALI_File_Exists;
365 ---------------------------------
366 -- Update_Tables_From_ALI_File --
367 ---------------------------------
369 procedure Update_Tables_From_ALI_File is
370 begin
371 -- Build Compilation_Switches table
373 Compilation_Switches.Init;
375 for J in First_Arg_Entry .. Args.Last loop
376 Compilation_Switches.Increment_Last;
377 Compilation_Switches.Table (Compilation_Switches.Last) :=
378 Args.Table (J);
379 end loop;
380 end Update_Tables_From_ALI_File;
382 ----------------------------
383 -- Write_Unit_Information --
384 ----------------------------
386 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type) is
387 Unode : constant Node_Id := Cunit (Unit_Num);
388 Ukind : constant Node_Kind := Nkind (Unit (Unode));
389 Uent : constant Entity_Id := Cunit_Entity (Unit_Num);
390 Pnode : Node_Id;
392 begin
393 Write_Info_Initiate ('U');
394 Write_Info_Char (' ');
395 Write_Info_Name (Unit_Name (Unit_Num));
396 Write_Info_Tab (25);
397 Write_Info_Name (Unit_File_Name (Unit_Num));
399 Write_Info_Tab (49);
400 Write_Info_Str (Version_Get (Unit_Num));
402 -- Add BD parameter if Elaborate_Body pragma desirable
404 if Ekind (Uent) = E_Package
405 and then Elaborate_Body_Desirable (Uent)
406 then
407 Write_Info_Str (" BD");
408 end if;
410 -- Add BN parameter if body needed for SAL
412 if (Is_Subprogram (Uent)
413 or else Ekind (Uent) = E_Package
414 or else Is_Generic_Unit (Uent))
415 and then Body_Needed_For_SAL (Uent)
416 then
417 Write_Info_Str (" BN");
418 end if;
420 if Dynamic_Elab (Unit_Num) then
421 Write_Info_Str (" DE");
422 end if;
424 -- Set the Elaborate_Body indication if either an explicit pragma
425 -- was present, or if this is an instantiation.
427 if Has_Pragma_Elaborate_Body (Uent)
428 or else (Ukind = N_Package_Declaration
429 and then Is_Generic_Instance (Uent)
430 and then Present (Corresponding_Body (Unit (Unode))))
431 then
432 Write_Info_Str (" EB");
433 end if;
435 -- Now see if we should tell the binder that an elaboration entity
436 -- is present, which must be set to true during elaboration.
437 -- We generate the indication if the following condition is met:
439 -- If this is a spec ...
441 if (Is_Subprogram (Uent)
442 or else Ekind (Uent) = E_Package
443 or else Is_Generic_Unit (Uent))
445 -- and an elaboration entity was declared ...
447 and then Present (Elaboration_Entity (Uent))
449 -- and either the elaboration flag is required ...
451 and then (Elaboration_Entity_Required (Uent)
453 -- or this unit has elaboration code ...
455 or else not Has_No_Elaboration_Code (Unode)
457 -- or this unit has a separate body and this
458 -- body has elaboration code.
460 or else
461 (Ekind (Uent) = E_Package
462 and then Present (Body_Entity (Uent))
463 and then
464 not Has_No_Elaboration_Code
465 (Parent (Declaration_Node (Body_Entity (Uent))))))
466 then
467 Write_Info_Str (" EE");
468 end if;
470 if Has_No_Elaboration_Code (Unode) then
471 Write_Info_Str (" NE");
472 end if;
474 Write_Info_Str (" O");
475 Write_Info_Char (OA_Setting (Unit_Num));
477 if Ekind_In (Uent, E_Package, E_Package_Body)
478 and then Present (Finalizer (Uent))
479 then
480 Write_Info_Str (" PF");
481 end if;
483 if Is_Preelaborated (Uent) then
484 Write_Info_Str (" PR");
485 end if;
487 if Is_Pure (Uent) then
488 Write_Info_Str (" PU");
489 end if;
491 if Has_RACW (Unit_Num) then
492 Write_Info_Str (" RA");
493 end if;
495 if Is_Remote_Call_Interface (Uent) then
496 Write_Info_Str (" RC");
497 end if;
499 if Is_Remote_Types (Uent) then
500 Write_Info_Str (" RT");
501 end if;
503 if Serious_Errors_Detected /= 0 then
504 Write_Info_Str (" SE");
505 end if;
507 if Is_Shared_Passive (Uent) then
508 Write_Info_Str (" SP");
509 end if;
511 if Ukind = N_Subprogram_Declaration
512 or else Ukind = N_Subprogram_Body
513 then
514 Write_Info_Str (" SU");
516 elsif Ukind = N_Package_Declaration
517 or else
518 Ukind = N_Package_Body
519 then
520 -- If this is a wrapper package for a subprogram instantiation,
521 -- the user view is the subprogram. Note that in this case the
522 -- ali file contains both the spec and body of the instance.
524 if Is_Wrapper_Package (Uent) then
525 Write_Info_Str (" SU");
526 else
527 Write_Info_Str (" PK");
528 end if;
530 elsif Ukind = N_Generic_Package_Declaration then
531 Write_Info_Str (" PK");
533 end if;
535 if Ukind in N_Generic_Declaration
536 or else
537 (Present (Library_Unit (Unode))
538 and then
539 Nkind (Unit (Library_Unit (Unode))) in N_Generic_Declaration)
540 then
541 Write_Info_Str (" GE");
542 end if;
544 if not Is_Internal_Unit (Unit_Num) then
545 case Identifier_Casing (Source_Index (Unit_Num)) is
546 when All_Lower_Case => Write_Info_Str (" IL");
547 when All_Upper_Case => Write_Info_Str (" IU");
548 when others => null;
549 end case;
551 case Keyword_Casing (Source_Index (Unit_Num)) is
552 when Mixed_Case => Write_Info_Str (" KM");
553 when All_Upper_Case => Write_Info_Str (" KU");
554 when others => null;
555 end case;
556 end if;
558 if Initialize_Scalars or else Invalid_Value_Used then
559 Write_Info_Str (" IS");
560 end if;
562 Write_Info_EOL;
564 -- Generate with lines, first those that are directly with'ed
566 for J in With_Flags'Range loop
567 With_Flags (J) := False;
568 Elab_Flags (J) := False;
569 Elab_All_Flags (J) := False;
570 Elab_Des_Flags (J) := False;
571 Elab_All_Des_Flags (J) := False;
572 Implicit_With (J) := Unknown;
573 end loop;
575 Collect_Withs (Unode);
577 -- For a body, we must also check for any subunits which belong to
578 -- it and which have context clauses of their own, since these
579 -- with'ed units are part of its own elaboration dependencies.
581 if Nkind (Unit (Unode)) in N_Unit_Body then
582 for S in Units.First .. Last_Unit loop
584 -- We are only interested in subunits. For preproc. data and
585 -- def. files, Cunit is Empty, so we need to test that first.
587 if Cunit (S) /= Empty
588 and then Nkind (Unit (Cunit (S))) = N_Subunit
589 then
590 Pnode := Library_Unit (Cunit (S));
592 -- In gnatc mode, the errors in the subunits will not have
593 -- been recorded, but the analysis of the subunit may have
594 -- failed. There is no information to add to ALI file in
595 -- this case.
597 if No (Pnode) then
598 exit;
599 end if;
601 -- Find ultimate parent of the subunit
603 while Nkind (Unit (Pnode)) = N_Subunit loop
604 Pnode := Library_Unit (Pnode);
605 end loop;
607 -- See if it belongs to current unit, and if so, include
608 -- its with_clauses.
610 if Pnode = Unode then
611 Collect_Withs (Cunit (S));
612 end if;
613 end if;
614 end loop;
615 end if;
617 Write_With_Lines;
619 -- Generate the linker option lines
621 for J in 1 .. Linker_Option_Lines.Last loop
623 -- Pragma Linker_Options is not allowed in predefined generic
624 -- units. This is because they won't be read, due to the fact that
625 -- with lines for generic units lack the file name and lib name
626 -- parameters (see Lib_Writ spec for an explanation).
628 if Is_Generic_Unit (Cunit_Entity (Main_Unit))
629 and then Is_Predefined_Unit (Current_Sem_Unit)
630 and then Linker_Option_Lines.Table (J).Unit = Unit_Num
631 then
632 Set_Standard_Error;
633 Write_Line
634 ("linker options not allowed in predefined generic unit");
635 raise Unrecoverable_Error;
636 end if;
638 -- Output one linker option line
640 declare
641 S : Linker_Option_Entry renames Linker_Option_Lines.Table (J);
642 begin
643 if S.Unit = Unit_Num then
644 Write_Info_Initiate ('L');
645 Write_Info_Char (' ');
646 Write_Info_Slit (S.Option);
647 Write_Info_EOL;
648 end if;
649 end;
650 end loop;
652 -- Output notes
654 for J in 1 .. Notes.Last loop
655 declare
656 N : constant Node_Id := Notes.Table (J);
657 L : constant Source_Ptr := Sloc (N);
658 U : constant Unit_Number_Type :=
659 Unit (Get_Source_File_Index (L));
660 C : Character;
662 Note_Unit : Unit_Number_Type;
663 -- The unit in whose U section this note must be emitted:
664 -- notes for subunits are emitted along with the main unit;
665 -- all other notes are emitted as part of the enclosing
666 -- compilation unit.
668 begin
669 if U /= No_Unit and then Nkind (Unit (Cunit (U))) = N_Subunit
670 then
671 Note_Unit := Main_Unit;
672 else
673 Note_Unit := U;
674 end if;
676 if Note_Unit = Unit_Num then
677 Write_Info_Initiate ('N');
678 Write_Info_Char (' ');
680 case Pragma_Name_Unmapped (N) is
681 when Name_Annotate =>
682 C := 'A';
683 when Name_Comment =>
684 C := 'C';
685 when Name_Ident =>
686 C := 'I';
687 when Name_Title =>
688 C := 'T';
689 when Name_Subtitle =>
690 C := 'S';
691 when others =>
692 raise Program_Error;
693 end case;
695 Write_Info_Char (C);
696 Write_Info_Int (Int (Get_Logical_Line_Number (L)));
697 Write_Info_Char (':');
698 Write_Info_Int (Int (Get_Column_Number (L)));
700 -- Indicate source file of annotation if different from
701 -- compilation unit source file (case of annotation coming
702 -- from a separate).
704 if Get_Source_File_Index (L) /= Source_Index (Unit_Num) then
705 Write_Info_Char (':');
706 Write_Info_Name (File_Name (Get_Source_File_Index (L)));
707 end if;
709 declare
710 A : Node_Id;
712 begin
713 A := First (Pragma_Argument_Associations (N));
714 while Present (A) loop
715 Write_Info_Char (' ');
717 if Chars (A) /= No_Name then
718 Write_Info_Name (Chars (A));
719 Write_Info_Char (':');
720 end if;
722 declare
723 Expr : constant Node_Id := Expression (A);
725 begin
726 if Nkind (Expr) = N_Identifier then
727 Write_Info_Name (Chars (Expr));
729 elsif Nkind (Expr) = N_Integer_Literal
730 and then Is_OK_Static_Expression (Expr)
731 then
732 Write_Info_Uint (Intval (Expr));
734 elsif Nkind (Expr) = N_String_Literal
735 and then Is_OK_Static_Expression (Expr)
736 then
737 Write_Info_Slit (Strval (Expr));
739 else
740 Write_Info_Str ("<expr>");
741 end if;
742 end;
744 Next (A);
745 end loop;
746 end;
748 Write_Info_EOL;
749 end if;
750 end;
751 end loop;
752 end Write_Unit_Information;
754 ----------------------
755 -- Write_With_Lines --
756 ----------------------
758 procedure Write_With_Lines is
759 Pname : constant Unit_Name_Type :=
760 Get_Parent_Spec_Name (Unit_Name (Main_Unit));
761 Body_Fname : File_Name_Type;
762 Body_Index : Nat;
763 Cunit : Node_Id;
764 Fname : File_Name_Type;
765 Num_Withs : Int := 0;
766 Unum : Unit_Number_Type;
767 Uname : Unit_Name_Type;
768 With_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 1));
770 procedure Write_With_File_Names
771 (Nam : in out File_Name_Type;
772 Idx : Nat);
773 -- Write source file name Nam and ALI file name for unit index Idx.
774 -- Possibly change Nam to lowercase (generating a new file name).
776 --------------------------
777 -- Write_With_File_Name --
778 --------------------------
780 procedure Write_With_File_Names
781 (Nam : in out File_Name_Type;
782 Idx : Nat)
784 begin
785 if not File_Names_Case_Sensitive then
786 Get_Name_String (Nam);
787 To_Lower (Name_Buffer (1 .. Name_Len));
788 Nam := Name_Find;
789 end if;
791 Write_Info_Name (Nam);
792 Write_Info_Tab (49);
793 Write_Info_Name (Lib_File_Name (Nam, Idx));
794 end Write_With_File_Names;
796 -- Start of processing for Write_With_Lines
798 begin
799 -- Loop to build the with table. A with on the main unit itself
800 -- is ignored (AARM 10.2(14a)). Such a with-clause can occur if
801 -- the main unit is a subprogram with no spec, and a subunit of
802 -- it unnecessarily withs the parent.
804 for J in Units.First + 1 .. Last_Unit loop
806 -- Add element to with table if it is with'ed or if it is the
807 -- parent spec of the main unit (case of main unit is a child
808 -- unit). The latter with is not needed for semantic purposes,
809 -- but is required by the binder for elaboration purposes. For
810 -- preprocessing data and definition files, there is no Unit_Name,
811 -- check for that first.
813 if Unit_Name (J) /= No_Unit_Name
814 and then (With_Flags (J) or else Unit_Name (J) = Pname)
815 then
816 Num_Withs := Num_Withs + 1;
817 With_Table (Num_Withs) := J;
818 end if;
819 end loop;
821 -- Sort and output the table
823 Sort (With_Table (1 .. Num_Withs));
825 for J in 1 .. Num_Withs loop
826 Unum := With_Table (J);
828 -- Do not generate a with line for an ignored Ghost unit because
829 -- the unit does not have an ALI file.
831 if Is_Ignored_Ghost_Entity (Cunit_Entity (Unum)) then
832 goto Next_With_Line;
833 end if;
835 Cunit := Units.Table (Unum).Cunit;
836 Uname := Units.Table (Unum).Unit_Name;
837 Fname := Units.Table (Unum).Unit_File_Name;
839 if Implicit_With (Unum) = Yes then
840 Write_Info_Initiate ('Z');
842 elsif Ekind (Cunit_Entity (Unum)) = E_Package
843 and then From_Limited_With (Cunit_Entity (Unum))
844 then
845 Write_Info_Initiate ('Y');
847 else
848 Write_Info_Initiate ('W');
849 end if;
851 Write_Info_Char (' ');
852 Write_Info_Name (Uname);
854 -- Now we need to figure out the names of the files that contain
855 -- the with'ed unit. These will usually be the files for the body,
856 -- except in the case of a package that has no body. Note that we
857 -- have a specific exemption here for predefined library generics
858 -- (see comments for Generic_May_Lack_ALI). We do not generate
859 -- dependency upon the ALI file for such units. Older compilers
860 -- used to not support generating code (and ALI) for generics, and
861 -- we want to avoid having different processing (namely, different
862 -- lists of files to be compiled) for different stages of the
863 -- bootstrap.
865 if not ((Nkind (Unit (Cunit)) in N_Generic_Declaration
866 or else
867 Nkind (Unit (Cunit)) in N_Generic_Renaming_Declaration)
868 and then Generic_May_Lack_ALI (Unum))
870 -- In SPARK mode, always generate the dependencies on ALI
871 -- files, which are required to compute frame conditions
872 -- of subprograms.
874 or else GNATprove_Mode
875 then
876 Write_Info_Tab (25);
878 if Is_Spec_Name (Uname) then
879 Body_Fname :=
880 Get_File_Name
881 (Get_Body_Name (Uname),
882 Subunit => False, May_Fail => True);
884 Body_Index :=
885 Get_Unit_Index
886 (Get_Body_Name (Uname));
888 if Body_Fname = No_File then
889 Body_Fname := Get_File_Name (Uname, Subunit => False);
890 Body_Index := Get_Unit_Index (Uname);
891 end if;
893 else
894 Body_Fname := Get_File_Name (Uname, Subunit => False);
895 Body_Index := Get_Unit_Index (Uname);
896 end if;
898 -- A package is considered to have a body if it requires
899 -- a body or if a body is present in Ada 83 mode.
901 if Body_Required (Cunit)
902 or else (Ada_Version = Ada_83
903 and then Full_Source_Name (Body_Fname) /= No_File)
904 then
905 Write_With_File_Names (Body_Fname, Body_Index);
906 else
907 Write_With_File_Names (Fname, Munit_Index (Unum));
908 end if;
910 if Ekind (Cunit_Entity (Unum)) = E_Package
911 and then From_Limited_With (Cunit_Entity (Unum))
912 then
913 null;
914 else
915 if Elab_Flags (Unum) then
916 Write_Info_Str (" E");
917 end if;
919 if Elab_All_Flags (Unum) then
920 Write_Info_Str (" EA");
921 end if;
923 if Elab_Des_Flags (Unum) then
924 Write_Info_Str (" ED");
925 end if;
927 if Elab_All_Des_Flags (Unum) then
928 Write_Info_Str (" AD");
929 end if;
930 end if;
931 end if;
933 Write_Info_EOL;
935 <<Next_With_Line>>
936 null;
937 end loop;
939 -- Finally generate the special lines for cases of Restriction_Set
940 -- with No_Dependence and no restriction present.
942 declare
943 Unam : Unit_Name_Type;
945 begin
946 for J in Restriction_Set_Dependences.First ..
947 Restriction_Set_Dependences.Last
948 loop
949 Unam := Restriction_Set_Dependences.Table (J);
951 -- Don't need an entry if already in the unit table
953 for U in 0 .. Last_Unit loop
954 if Unit_Name (U) = Unam then
955 goto Next_Restriction_Set;
956 end if;
957 end loop;
959 -- Otherwise generate the entry
961 Write_Info_Initiate ('W');
962 Write_Info_Char (' ');
963 Write_Info_Name (Unam);
964 Write_Info_EOL;
966 <<Next_Restriction_Set>>
967 null;
968 end loop;
969 end;
970 end Write_With_Lines;
972 -- Start of processing for Write_ALI
974 begin
975 -- We never write an ALI file if the original operating mode was
976 -- syntax-only (-gnats switch used in compiler invocation line)
978 if Original_Operating_Mode = Check_Syntax
979 or flag_compare_debug /= 0
980 then
981 return;
982 end if;
984 -- Generation of ALI files may be disabled, e.g. for formal verification
985 -- back-end.
987 if Disable_ALI_File then
988 return;
989 end if;
991 -- Build sorted source dependency table. We do this right away, because
992 -- it is referenced by Up_To_Date_ALI_File_Exists.
994 for Unum in Units.First .. Last_Unit loop
995 if Cunit_Entity (Unum) = Empty
996 or else not From_Limited_With (Cunit_Entity (Unum))
997 then
998 -- Units that are not analyzed need not appear in the dependency
999 -- list. These units are either units appearing in limited_with
1000 -- clauses of other units, or units loaded for inlining that end
1001 -- up not inlined by a later decision of the inlining code, to
1002 -- prevent circularities. We want to exclude these files from the
1003 -- list of dependencies, so that the dependency number of other
1004 -- is correctly set, as that number is used by cross-reference
1005 -- tools to relate entity information to the unit in which they
1006 -- are declared.
1008 if Present (Cunit_Entity (Unum))
1009 and then Ekind (Cunit_Entity (Unum)) = E_Void
1010 and then Nkind (Unit (Cunit (Unum))) /= N_Subunit
1011 and then Serious_Errors_Detected = 0
1012 then
1013 null;
1015 else
1016 Num_Sdep := Num_Sdep + 1;
1017 Sdep_Table (Num_Sdep) := Unum;
1018 end if;
1019 end if;
1020 end loop;
1022 -- Sort the table so that the D lines are in order
1024 Lib.Sort (Sdep_Table (1 .. Num_Sdep));
1026 -- If we are not generating code, and there is an up to date ALI file
1027 -- file accessible, read it, and acquire the compilation arguments from
1028 -- this file. In GNATprove mode, always generate the ALI file, which
1029 -- contains a special section for formal verification.
1031 if Operating_Mode /= Generate_Code and then not GNATprove_Mode then
1032 if Up_To_Date_ALI_File_Exists then
1033 Update_Tables_From_ALI_File;
1034 return;
1035 end if;
1036 end if;
1038 -- Otherwise acquire compilation arguments and prepare to write out a
1039 -- new ali file.
1041 Create_Output_Library_Info;
1043 -- Output version line
1045 Write_Info_Initiate ('V');
1046 Write_Info_Str (" """);
1047 Write_Info_Str (Verbose_Library_Version);
1048 Write_Info_Char ('"');
1050 Write_Info_EOL;
1052 -- Output main program line if this is acceptable main program
1054 Output_Main_Program_Line : declare
1055 U : Node_Id := Unit (Units.Table (Main_Unit).Cunit);
1056 S : Node_Id;
1058 procedure M_Parameters;
1059 -- Output parameters for main program line
1061 ------------------
1062 -- M_Parameters --
1063 ------------------
1065 procedure M_Parameters is
1066 begin
1067 if Main_Priority (Main_Unit) /= Default_Main_Priority then
1068 Write_Info_Char (' ');
1069 Write_Info_Nat (Main_Priority (Main_Unit));
1070 end if;
1072 if Opt.Time_Slice_Set then
1073 Write_Info_Str (" T=");
1074 Write_Info_Nat (Opt.Time_Slice_Value);
1075 end if;
1077 if Main_CPU (Main_Unit) /= Default_Main_CPU then
1078 Write_Info_Str (" C=");
1079 Write_Info_Nat (Main_CPU (Main_Unit));
1080 end if;
1082 Write_Info_Str (" W=");
1083 Write_Info_Char
1084 (WC_Encoding_Letters (Wide_Character_Encoding_Method));
1086 Write_Info_EOL;
1087 end M_Parameters;
1089 -- Start of processing for Output_Main_Program_Line
1091 begin
1092 if Nkind (U) = N_Subprogram_Body
1093 or else
1094 (Nkind (U) = N_Package_Body
1095 and then
1096 Nkind (Original_Node (U)) in N_Subprogram_Instantiation)
1097 then
1098 -- If the unit is a subprogram instance, the entity for the
1099 -- subprogram is the alias of the visible entity, which is the
1100 -- related instance of the wrapper package. We retrieve the
1101 -- subprogram declaration of the desired entity.
1103 if Nkind (U) = N_Package_Body then
1104 U := Parent (Parent (
1105 Alias (Related_Instance (Defining_Unit_Name
1106 (Specification (Unit (Library_Unit (Parent (U)))))))));
1107 end if;
1109 S := Specification (U);
1111 -- A generic subprogram is never a main program
1113 if Nkind (U) = N_Subprogram_Body
1114 and then Present (Corresponding_Spec (U))
1115 and then
1116 Ekind_In (Corresponding_Spec (U), E_Generic_Procedure,
1117 E_Generic_Function)
1118 then
1119 null;
1121 elsif No (Parameter_Specifications (S)) then
1122 if Nkind (S) = N_Procedure_Specification then
1123 Write_Info_Initiate ('M');
1124 Write_Info_Str (" P");
1125 M_Parameters;
1127 else
1128 declare
1129 Nam : Node_Id := Defining_Unit_Name (S);
1131 begin
1132 -- If it is a child unit, get its simple name
1134 if Nkind (Nam) = N_Defining_Program_Unit_Name then
1135 Nam := Defining_Identifier (Nam);
1136 end if;
1138 if Is_Integer_Type (Etype (Nam)) then
1139 Write_Info_Initiate ('M');
1140 Write_Info_Str (" F");
1141 M_Parameters;
1142 end if;
1143 end;
1144 end if;
1145 end if;
1146 end if;
1147 end Output_Main_Program_Line;
1149 -- Write command argument ('A') lines
1151 for A in 1 .. Compilation_Switches.Last loop
1152 Write_Info_Initiate ('A');
1153 Write_Info_Char (' ');
1154 Write_Info_Str (Compilation_Switches.Table (A).all);
1155 Write_Info_Terminate;
1156 end loop;
1158 -- Output parameters ('P') line
1160 Write_Info_Initiate ('P');
1162 if Compilation_Errors then
1163 Write_Info_Str (" CE");
1164 end if;
1166 if Opt.Detect_Blocking then
1167 Write_Info_Str (" DB");
1168 end if;
1170 if Tasking_Used and then not Is_Predefined_Unit (Main_Unit) then
1171 if Locking_Policy /= ' ' then
1172 Write_Info_Str (" L");
1173 Write_Info_Char (Locking_Policy);
1174 end if;
1176 if Queuing_Policy /= ' ' then
1177 Write_Info_Str (" Q");
1178 Write_Info_Char (Queuing_Policy);
1179 end if;
1181 if Task_Dispatching_Policy /= ' ' then
1182 Write_Info_Str (" T");
1183 Write_Info_Char (Task_Dispatching_Policy);
1184 Write_Info_Char (' ');
1185 end if;
1186 end if;
1188 if GNATprove_Mode then
1189 Write_Info_Str (" GP");
1190 end if;
1192 if Partition_Elaboration_Policy /= ' ' then
1193 Write_Info_Str (" E");
1194 Write_Info_Char (Partition_Elaboration_Policy);
1195 end if;
1197 if No_Component_Reordering_Config then
1198 Write_Info_Str (" NC");
1199 end if;
1201 if not Object then
1202 Write_Info_Str (" NO");
1203 end if;
1205 if No_Run_Time_Mode then
1206 Write_Info_Str (" NR");
1207 end if;
1209 if Normalize_Scalars then
1210 Write_Info_Str (" NS");
1211 end if;
1213 if Default_SSO_Config /= ' ' then
1214 Write_Info_Str (" O");
1215 Write_Info_Char (Default_SSO_Config);
1216 end if;
1218 if Sec_Stack_Used then
1219 Write_Info_Str (" SS");
1220 end if;
1222 if Unreserve_All_Interrupts then
1223 Write_Info_Str (" UA");
1224 end if;
1226 if Front_End_Exceptions then
1227 Write_Info_Str (" FX");
1228 end if;
1230 if ZCX_Exceptions then
1231 Write_Info_Str (" ZX");
1232 end if;
1234 Write_Info_EOL;
1236 -- Before outputting the restrictions line, update the setting of
1237 -- the No_Elaboration_Code flag. Violations of this restriction
1238 -- cannot be detected until after the backend has been called since
1239 -- it is the backend that sets this flag. We have to check all units
1240 -- for which we have generated code
1242 for Unit in Units.First .. Last_Unit loop
1243 if Units.Table (Unit).Generate_Code or else Unit = Main_Unit then
1244 if not Has_No_Elaboration_Code (Cunit (Unit)) then
1245 Main_Restrictions.Violated (No_Elaboration_Code) := True;
1246 end if;
1247 end if;
1248 end loop;
1250 -- Positional case (only if debug flag -gnatd.R is set)
1252 if Debug_Flag_Dot_RR then
1254 -- Output first restrictions line
1256 Write_Info_Initiate ('R');
1257 Write_Info_Char (' ');
1259 -- First the information for the boolean restrictions
1261 for R in All_Boolean_Restrictions loop
1262 if Main_Restrictions.Set (R)
1263 and then not Restriction_Warnings (R)
1264 then
1265 Write_Info_Char ('r');
1266 elsif Main_Restrictions.Violated (R) then
1267 Write_Info_Char ('v');
1268 else
1269 Write_Info_Char ('n');
1270 end if;
1271 end loop;
1273 -- And now the information for the parameter restrictions
1275 for RP in All_Parameter_Restrictions loop
1276 if Main_Restrictions.Set (RP)
1277 and then not Restriction_Warnings (RP)
1278 then
1279 Write_Info_Char ('r');
1280 Write_Info_Nat (Nat (Main_Restrictions.Value (RP)));
1281 else
1282 Write_Info_Char ('n');
1283 end if;
1285 if not Main_Restrictions.Violated (RP)
1286 or else RP not in Checked_Parameter_Restrictions
1287 then
1288 Write_Info_Char ('n');
1289 else
1290 Write_Info_Char ('v');
1291 Write_Info_Nat (Nat (Main_Restrictions.Count (RP)));
1293 if Main_Restrictions.Unknown (RP) then
1294 Write_Info_Char ('+');
1295 end if;
1296 end if;
1297 end loop;
1299 Write_Info_EOL;
1301 -- Named case (if debug flag -gnatd.R is not set)
1303 else
1304 declare
1305 C : Character;
1307 begin
1308 -- Write RN header line with preceding blank line
1310 Write_Info_EOL;
1311 Write_Info_Initiate ('R');
1312 Write_Info_Char ('N');
1313 Write_Info_EOL;
1315 -- First the lines for the boolean restrictions
1317 for R in All_Boolean_Restrictions loop
1318 if Main_Restrictions.Set (R)
1319 and then not Restriction_Warnings (R)
1320 then
1321 C := 'R';
1322 elsif Main_Restrictions.Violated (R) then
1323 C := 'V';
1324 else
1325 goto Continue;
1326 end if;
1328 Write_Info_Initiate ('R');
1329 Write_Info_Char (C);
1330 Write_Info_Char (' ');
1331 Write_Info_Str (All_Boolean_Restrictions'Image (R));
1332 Write_Info_EOL;
1334 <<Continue>>
1335 null;
1336 end loop;
1337 end;
1339 -- And now the lines for the parameter restrictions
1341 for RP in All_Parameter_Restrictions loop
1342 if Main_Restrictions.Set (RP)
1343 and then not Restriction_Warnings (RP)
1344 then
1345 Write_Info_Initiate ('R');
1346 Write_Info_Str ("R ");
1347 Write_Info_Str (All_Parameter_Restrictions'Image (RP));
1348 Write_Info_Char ('=');
1349 Write_Info_Nat (Nat (Main_Restrictions.Value (RP)));
1350 Write_Info_EOL;
1351 end if;
1353 if not Main_Restrictions.Violated (RP)
1354 or else RP not in Checked_Parameter_Restrictions
1355 then
1356 null;
1357 else
1358 Write_Info_Initiate ('R');
1359 Write_Info_Str ("V ");
1360 Write_Info_Str (All_Parameter_Restrictions'Image (RP));
1361 Write_Info_Char ('=');
1362 Write_Info_Nat (Nat (Main_Restrictions.Count (RP)));
1364 if Main_Restrictions.Unknown (RP) then
1365 Write_Info_Char ('+');
1366 end if;
1368 Write_Info_EOL;
1369 end if;
1370 end loop;
1371 end if;
1373 -- Output R lines for No_Dependence entries
1375 for J in No_Dependences.First .. No_Dependences.Last loop
1376 if In_Extended_Main_Source_Unit (No_Dependences.Table (J).Unit)
1377 and then not No_Dependences.Table (J).Warn
1378 then
1379 Write_Info_Initiate ('R');
1380 Write_Info_Char (' ');
1381 Write_Unit_Name (No_Dependences.Table (J).Unit);
1382 Write_Info_EOL;
1383 end if;
1384 end loop;
1386 -- Output interrupt state lines
1388 for J in Interrupt_States.First .. Interrupt_States.Last loop
1389 Write_Info_Initiate ('I');
1390 Write_Info_Char (' ');
1391 Write_Info_Nat (Interrupt_States.Table (J).Interrupt_Number);
1392 Write_Info_Char (' ');
1393 Write_Info_Char (Interrupt_States.Table (J).Interrupt_State);
1394 Write_Info_Char (' ');
1395 Write_Info_Nat
1396 (Nat (Get_Logical_Line_Number
1397 (Interrupt_States.Table (J).Pragma_Loc)));
1398 Write_Info_EOL;
1399 end loop;
1401 -- Output priority specific dispatching lines
1403 for J in Specific_Dispatching.First .. Specific_Dispatching.Last loop
1404 Write_Info_Initiate ('S');
1405 Write_Info_Char (' ');
1406 Write_Info_Char (Specific_Dispatching.Table (J).Dispatching_Policy);
1407 Write_Info_Char (' ');
1408 Write_Info_Nat (Specific_Dispatching.Table (J).First_Priority);
1409 Write_Info_Char (' ');
1410 Write_Info_Nat (Specific_Dispatching.Table (J).Last_Priority);
1411 Write_Info_Char (' ');
1412 Write_Info_Nat
1413 (Nat (Get_Logical_Line_Number
1414 (Specific_Dispatching.Table (J).Pragma_Loc)));
1415 Write_Info_EOL;
1416 end loop;
1418 -- Loop through file table to output information for all units for which
1419 -- we have generated code, as marked by the Generate_Code flag.
1421 for Unit in Units.First .. Last_Unit loop
1422 if Units.Table (Unit).Generate_Code
1423 or else Unit = Main_Unit
1424 then
1425 Write_Info_EOL; -- blank line
1426 Write_Unit_Information (Unit);
1427 end if;
1428 end loop;
1430 Write_Info_EOL; -- blank line
1432 -- Output external version reference lines
1434 for J in 1 .. Version_Ref.Last loop
1435 Write_Info_Initiate ('E');
1436 Write_Info_Char (' ');
1438 for K in 1 .. String_Length (Version_Ref.Table (J)) loop
1439 Write_Info_Char_Code (Get_String_Char (Version_Ref.Table (J), K));
1440 end loop;
1442 Write_Info_EOL;
1443 end loop;
1445 -- Prepare to output the source dependency lines
1447 declare
1448 Unum : Unit_Number_Type;
1449 -- Number of unit being output
1451 Sind : Source_File_Index;
1452 -- Index of corresponding source file
1454 Fname : File_Name_Type;
1456 begin
1457 for J in 1 .. Num_Sdep loop
1458 Unum := Sdep_Table (J);
1459 Units.Table (Unum).Dependency_Num := J;
1460 Sind := Units.Table (Unum).Source_Index;
1462 Write_Info_Initiate ('D');
1463 Write_Info_Char (' ');
1465 -- Normal case of a unit entry with a source index
1467 if Sind /= No_Source_File then
1468 Fname := File_Name (Sind);
1470 -- Ensure that on platforms where the file names are not case
1471 -- sensitive, the recorded file name is in lower case.
1473 if not File_Names_Case_Sensitive then
1474 Get_Name_String (Fname);
1475 To_Lower (Name_Buffer (1 .. Name_Len));
1476 Fname := Name_Find;
1477 end if;
1479 Write_Info_Name_May_Be_Quoted (Fname);
1480 Write_Info_Tab (25);
1481 Write_Info_Str (String (Time_Stamp (Sind)));
1482 Write_Info_Char (' ');
1483 Write_Info_Str (Get_Hex_String (Source_Checksum (Sind)));
1485 -- If the dependency comes from a limited_with clause, record
1486 -- limited_checksum. This is disabled until full checksum
1487 -- changes are checked.
1489 -- if Present (Cunit_Entity (Unum))
1490 -- and then From_Limited_With (Cunit_Entity (Unum))
1491 -- then
1492 -- Write_Info_Char (' ');
1493 -- Write_Info_Char ('Y');
1494 -- Write_Info_Str (Get_Hex_String (Limited_Chk_Sum (Sind)));
1495 -- end if;
1497 -- If subunit, add unit name, omitting the %b at the end
1499 if Present (Cunit (Unum)) then
1500 Get_Decoded_Name_String (Unit_Name (Unum));
1501 Write_Info_Char (' ');
1503 if Nkind (Unit (Cunit (Unum))) = N_Subunit then
1504 Write_Info_Str (Name_Buffer (1 .. Name_Len - 2));
1505 else
1506 Write_Info_Str (Name_Buffer (1 .. Name_Len));
1507 end if;
1508 end if;
1510 -- If Source_Reference pragma used, output information
1512 if Num_SRef_Pragmas (Sind) > 0 then
1513 Write_Info_Char (' ');
1515 if Num_SRef_Pragmas (Sind) = 1 then
1516 Write_Info_Nat (Int (First_Mapped_Line (Sind)));
1517 else
1518 Write_Info_Nat (0);
1519 end if;
1521 Write_Info_Char (':');
1522 Write_Info_Name (Reference_Name (Sind));
1523 end if;
1525 -- Case where there is no source index (happens for missing
1526 -- files). In this case we write a dummy time stamp.
1528 else
1529 Write_Info_Name (Unit_File_Name (Unum));
1530 Write_Info_Tab (25);
1531 Write_Info_Str (String (Dummy_Time_Stamp));
1532 Write_Info_Char (' ');
1533 Write_Info_Str (Get_Hex_String (0));
1534 end if;
1536 Write_Info_EOL;
1537 end loop;
1538 end;
1540 -- Output cross-references
1542 if Opt.Xref_Active then
1543 Output_References;
1544 end if;
1546 -- Output SCO information if present
1548 if Generate_SCO then
1549 SCO_Record_Filtered;
1550 SCO_Output;
1551 end if;
1553 -- Output SPARK cross-reference information if needed
1555 if Opt.Xref_Active and then GNATprove_Mode then
1556 SPARK_Specific.Collect_SPARK_Xrefs (Sdep_Table => Sdep_Table,
1557 Num_Sdep => Num_Sdep);
1558 SPARK_Specific.Output_SPARK_Xrefs;
1559 end if;
1561 -- Output final blank line and we are done. This final blank line is
1562 -- probably junk, but we don't feel like making an incompatible change.
1564 Write_Info_Terminate;
1565 Close_Output_Library_Info;
1566 end Write_ALI;
1568 ---------------------
1569 -- Write_Unit_Name --
1570 ---------------------
1572 procedure Write_Unit_Name (N : Node_Id) is
1573 begin
1574 if Nkind (N) = N_Identifier then
1575 Write_Info_Name (Chars (N));
1577 else
1578 pragma Assert (Nkind (N) = N_Selected_Component);
1579 Write_Unit_Name (Prefix (N));
1580 Write_Info_Char ('.');
1581 Write_Unit_Name (Selector_Name (N));
1582 end if;
1583 end Write_Unit_Name;
1585 end Lib.Writ;