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