2016-04-21 Ed Schonberg <schonberg@adacore.com>
[official-gcc.git] / gcc / ada / lib-writ.adb
blob34f3628388a849d1975ae0b0fa5260517394aea2
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 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;
55 with System.Case_Util; use System.Case_Util;
56 with System.WCh_Con; use System.WCh_Con;
58 package body Lib.Writ is
60 -----------------------
61 -- Local Subprograms --
62 -----------------------
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).
68 ----------------------------------
69 -- Add_Preprocessing_Dependency --
70 ----------------------------------
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 => None,
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 No_Elab_Code_All => False,
94 Serial_Number => 0,
95 Version => 0,
96 Error_Location => No_Location,
97 OA_Setting => 'O',
98 SPARK_Mode_Pragma => Empty);
99 end Add_Preprocessing_Dependency;
101 ------------------------------
102 -- Ensure_System_Dependency --
103 ------------------------------
105 procedure Ensure_System_Dependency is
106 System_Uname : Unit_Name_Type;
107 -- Unit name for system spec if needed for dummy entry
109 System_Fname : File_Name_Type;
110 -- File name for system spec if needed for dummy entry
112 begin
113 -- Nothing to do if we already compiled System
115 for Unum in Units.First .. Last_Unit loop
116 if Units.Table (Unum).Source_Index = System_Source_File_Index then
117 return;
118 end if;
119 end loop;
121 -- If no entry for system.ads in the units table, then add a entry
122 -- to the units table for system.ads, which will be referenced when
123 -- the ali file is generated. We need this because every unit depends
124 -- on system as a result of Targparm scanning the system.ads file to
125 -- determine the target dependent parameters for the compilation.
127 Name_Len := 6;
128 Name_Buffer (1 .. 6) := "system";
129 System_Uname := Name_To_Unit_Name (Name_Enter);
130 System_Fname := File_Name (System_Source_File_Index);
132 Units.Increment_Last;
133 Units.Table (Units.Last) := (
134 Unit_File_Name => System_Fname,
135 Unit_Name => System_Uname,
136 Expected_Unit => System_Uname,
137 Source_Index => System_Source_File_Index,
138 Cunit => Empty,
139 Cunit_Entity => Empty,
140 Dependency_Num => 0,
141 Dynamic_Elab => False,
142 Fatal_Error => None,
143 Generate_Code => False,
144 Has_RACW => False,
145 Filler => False,
146 Ident_String => Empty,
147 Loading => False,
148 Main_Priority => -1,
149 Main_CPU => -1,
150 Munit_Index => 0,
151 No_Elab_Code_All => False,
152 Serial_Number => 0,
153 Version => 0,
154 Error_Location => No_Location,
155 OA_Setting => 'O',
156 SPARK_Mode_Pragma => Empty);
158 -- Parse system.ads so that the checksum is set right,
159 -- Style checks are not applied. The Ekind is set to ensure
160 -- that this reference is always present in the ali file.
162 declare
163 Save_Mindex : constant Nat := Multiple_Unit_Index;
164 Save_Style : constant Boolean := Style_Check;
165 begin
166 Multiple_Unit_Index := 0;
167 Style_Check := False;
168 Initialize_Scanner (Units.Last, System_Source_File_Index);
169 Discard_List (Par (Configuration_Pragmas => False));
170 Set_Ekind (Cunit_Entity (Units.Last), E_Package);
171 Style_Check := Save_Style;
172 Multiple_Unit_Index := Save_Mindex;
173 end;
174 end Ensure_System_Dependency;
176 ---------------
177 -- Write_ALI --
178 ---------------
180 procedure Write_ALI (Object : Boolean) is
182 ----------------
183 -- Local Data --
184 ----------------
186 Last_Unit : constant Unit_Number_Type := Units.Last;
187 -- Record unit number of last unit. We capture this in case we
188 -- have to add a dummy entry to the unit table for package System.
190 With_Flags : array (Units.First .. Last_Unit) of Boolean;
191 -- Array of flags to show which units are with'ed
193 Elab_Flags : array (Units.First .. Last_Unit) of Boolean;
194 -- Array of flags to show which units have pragma Elaborate set
196 Elab_All_Flags : array (Units.First .. Last_Unit) of Boolean;
197 -- Array of flags to show which units have pragma Elaborate All set
199 Elab_Des_Flags : array (Units.First .. Last_Unit) of Boolean;
200 -- Array of flags to show which units have Elaborate_Desirable set
202 Elab_All_Des_Flags : array (Units.First .. Last_Unit) of Boolean;
203 -- Array of flags to show which units have Elaborate_All_Desirable set
205 type Yes_No is (Unknown, Yes, No);
206 Implicit_With : array (Units.First .. Last_Unit) of Yes_No;
207 -- Indicates if an implicit with has been given for the unit. Yes if
208 -- certainly present, no if certainly absent, unkonwn if not known.
210 Sdep_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 2));
211 -- Sorted table of source dependencies. One extra entry in case we
212 -- have to add a dummy entry for System.
214 Num_Sdep : Nat := 0;
215 -- Number of active entries in Sdep_Table
217 flag_compare_debug : Int;
218 pragma Import (C, flag_compare_debug);
219 -- Import from toplev.c
221 -----------------------
222 -- Local Subprograms --
223 -----------------------
225 procedure Collect_Withs (Cunit : Node_Id);
226 -- Collect with lines for entries in the context clause of the
227 -- given compilation unit, Cunit.
229 procedure Update_Tables_From_ALI_File;
230 -- Given an up to date ALI file (see Up_To_Date_ALI_file_Exists
231 -- function), update tables from the ALI information, including
232 -- specifically the Compilation_Switches table.
234 function Up_To_Date_ALI_File_Exists return Boolean;
235 -- If there exists an ALI file that is up to date, then this function
236 -- initializes the tables in the ALI spec to contain information on
237 -- this file (using Scan_ALI) and returns True. If no file exists,
238 -- or the file is not up to date, then False is returned.
240 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type);
241 -- Write out the library information for one unit for which code is
242 -- generated (includes unit line and with lines).
244 procedure Write_With_Lines;
245 -- Write out with lines collected by calls to Collect_Withs
247 -------------------
248 -- Collect_Withs --
249 -------------------
251 procedure Collect_Withs (Cunit : Node_Id) is
252 Item : Node_Id;
253 Unum : Unit_Number_Type;
255 begin
256 Item := First (Context_Items (Cunit));
257 while Present (Item) loop
259 -- Process with clause
261 -- Ada 2005 (AI-50217): limited with_clauses do not create
262 -- dependencies, but must be recorded as components of the
263 -- partition, in case there is no regular with_clause for
264 -- the unit anywhere else.
266 if Nkind (Item) = N_With_Clause then
267 Unum := Get_Cunit_Unit_Number (Library_Unit (Item));
268 With_Flags (Unum) := True;
270 if not Limited_Present (Item) then
271 if Elaborate_Present (Item) then
272 Elab_Flags (Unum) := True;
273 end if;
275 if Elaborate_All_Present (Item) then
276 Elab_All_Flags (Unum) := True;
277 end if;
279 if Elaborate_All_Desirable (Item) then
280 Elab_All_Des_Flags (Unum) := True;
281 end if;
283 if Elaborate_Desirable (Item) then
284 Elab_Des_Flags (Unum) := True;
285 end if;
287 else
288 Set_From_Limited_With (Cunit_Entity (Unum));
289 end if;
291 if Implicit_With (Unum) /= Yes then
292 if Implicit_With_From_Instantiation (Item) then
293 Implicit_With (Unum) := Yes;
294 else
295 Implicit_With (Unum) := No;
296 end if;
297 end if;
298 end if;
300 Next (Item);
301 end loop;
302 end Collect_Withs;
304 --------------------------------
305 -- Up_To_Date_ALI_File_Exists --
306 --------------------------------
308 function Up_To_Date_ALI_File_Exists return Boolean is
309 Name : File_Name_Type;
310 Text : Text_Buffer_Ptr;
311 Id : Sdep_Id;
312 Sind : Source_File_Index;
314 begin
315 Opt.Check_Object_Consistency := True;
316 Read_Library_Info (Name, Text);
318 -- Return if we could not find an ALI file
320 if Text = null then
321 return False;
322 end if;
324 -- Return if ALI file has bad format
326 Initialize_ALI;
328 if Scan_ALI (Name, Text, False, Err => True) = No_ALI_Id then
329 return False;
330 end if;
332 -- If we have an OK ALI file, check if it is up to date
333 -- Note that we assume that the ALI read has all the entries
334 -- we have in our table, plus some additional ones (that can
335 -- come from expansion).
337 Id := First_Sdep_Entry;
338 for J in 1 .. Num_Sdep loop
339 Sind := Units.Table (Sdep_Table (J)).Source_Index;
341 while Sdep.Table (Id).Sfile /= File_Name (Sind) loop
342 if Id = Sdep.Last then
343 return False;
344 else
345 Id := Id + 1;
346 end if;
347 end loop;
349 if Sdep.Table (Id).Stamp /= Time_Stamp (Sind) then
350 return False;
351 end if;
352 end loop;
354 return True;
355 end Up_To_Date_ALI_File_Exists;
357 ---------------------------------
358 -- Update_Tables_From_ALI_File --
359 ---------------------------------
361 procedure Update_Tables_From_ALI_File is
362 begin
363 -- Build Compilation_Switches table
365 Compilation_Switches.Init;
367 for J in First_Arg_Entry .. Args.Last loop
368 Compilation_Switches.Increment_Last;
369 Compilation_Switches.Table (Compilation_Switches.Last) :=
370 Args.Table (J);
371 end loop;
372 end Update_Tables_From_ALI_File;
374 ----------------------------
375 -- Write_Unit_Information --
376 ----------------------------
378 procedure Write_Unit_Information (Unit_Num : Unit_Number_Type) is
379 Unode : constant Node_Id := Cunit (Unit_Num);
380 Ukind : constant Node_Kind := Nkind (Unit (Unode));
381 Uent : constant Entity_Id := Cunit_Entity (Unit_Num);
382 Pnode : Node_Id;
384 begin
385 Write_Info_Initiate ('U');
386 Write_Info_Char (' ');
387 Write_Info_Name (Unit_Name (Unit_Num));
388 Write_Info_Tab (25);
389 Write_Info_Name (Unit_File_Name (Unit_Num));
391 Write_Info_Tab (49);
392 Write_Info_Str (Version_Get (Unit_Num));
394 -- Add BD parameter if Elaborate_Body pragma desirable
396 if Ekind (Uent) = E_Package
397 and then Elaborate_Body_Desirable (Uent)
398 then
399 Write_Info_Str (" BD");
400 end if;
402 -- Add BN parameter if body needed for SAL
404 if (Is_Subprogram (Uent)
405 or else Ekind (Uent) = E_Package
406 or else Is_Generic_Unit (Uent))
407 and then Body_Needed_For_SAL (Uent)
408 then
409 Write_Info_Str (" BN");
410 end if;
412 if Dynamic_Elab (Unit_Num) then
413 Write_Info_Str (" DE");
414 end if;
416 -- Set the Elaborate_Body indication if either an explicit pragma
417 -- was present, or if this is an instantiation.
419 if Has_Pragma_Elaborate_Body (Uent)
420 or else (Ukind = N_Package_Declaration
421 and then Is_Generic_Instance (Uent)
422 and then Present (Corresponding_Body (Unit (Unode))))
423 then
424 Write_Info_Str (" EB");
425 end if;
427 -- Now see if we should tell the binder that an elaboration entity
428 -- is present, which must be set to true during elaboration.
429 -- We generate the indication if the following condition is met:
431 -- If this is a spec ...
433 if (Is_Subprogram (Uent)
434 or else Ekind (Uent) = E_Package
435 or else Is_Generic_Unit (Uent))
437 -- and an elaboration entity was declared ...
439 and then Present (Elaboration_Entity (Uent))
441 -- and either the elaboration flag is required ...
443 and then (Elaboration_Entity_Required (Uent)
445 -- or this unit has elaboration code ...
447 or else not Has_No_Elaboration_Code (Unode)
449 -- or this unit has a separate body and this
450 -- body has elaboration code.
452 or else
453 (Ekind (Uent) = E_Package
454 and then Present (Body_Entity (Uent))
455 and then
456 not Has_No_Elaboration_Code
457 (Parent (Declaration_Node (Body_Entity (Uent))))))
458 then
459 Write_Info_Str (" EE");
460 end if;
462 if Has_No_Elaboration_Code (Unode) then
463 Write_Info_Str (" NE");
464 end if;
466 Write_Info_Str (" O");
467 Write_Info_Char (OA_Setting (Unit_Num));
469 if Ekind_In (Uent, E_Package, E_Package_Body)
470 and then Present (Finalizer (Uent))
471 then
472 Write_Info_Str (" PF");
473 end if;
475 if Is_Preelaborated (Uent) then
476 Write_Info_Str (" PR");
477 end if;
479 if Is_Pure (Uent) then
480 Write_Info_Str (" PU");
481 end if;
483 if Has_RACW (Unit_Num) then
484 Write_Info_Str (" RA");
485 end if;
487 if Is_Remote_Call_Interface (Uent) then
488 Write_Info_Str (" RC");
489 end if;
491 if Is_Remote_Types (Uent) then
492 Write_Info_Str (" RT");
493 end if;
495 if Serious_Errors_Detected /= 0 then
496 Write_Info_Str (" SE");
497 end if;
499 if Is_Shared_Passive (Uent) then
500 Write_Info_Str (" SP");
501 end if;
503 if Ukind = N_Subprogram_Declaration
504 or else Ukind = N_Subprogram_Body
505 then
506 Write_Info_Str (" SU");
508 elsif Ukind = N_Package_Declaration
509 or else
510 Ukind = N_Package_Body
511 then
512 -- If this is a wrapper package for a subprogram instantiation,
513 -- the user view is the subprogram. Note that in this case the
514 -- ali file contains both the spec and body of the instance.
516 if Is_Wrapper_Package (Uent) then
517 Write_Info_Str (" SU");
518 else
519 Write_Info_Str (" PK");
520 end if;
522 elsif Ukind = N_Generic_Package_Declaration then
523 Write_Info_Str (" PK");
525 end if;
527 if Ukind in N_Generic_Declaration
528 or else
529 (Present (Library_Unit (Unode))
530 and then
531 Nkind (Unit (Library_Unit (Unode))) in N_Generic_Declaration)
532 then
533 Write_Info_Str (" GE");
534 end if;
536 if not Is_Internal_File_Name (Unit_File_Name (Unit_Num), True) then
537 case Identifier_Casing (Source_Index (Unit_Num)) is
538 when All_Lower_Case => Write_Info_Str (" IL");
539 when All_Upper_Case => Write_Info_Str (" IU");
540 when others => null;
541 end case;
543 case Keyword_Casing (Source_Index (Unit_Num)) is
544 when Mixed_Case => Write_Info_Str (" KM");
545 when All_Upper_Case => Write_Info_Str (" KU");
546 when others => null;
547 end case;
548 end if;
550 if Initialize_Scalars or else Invalid_Value_Used then
551 Write_Info_Str (" IS");
552 end if;
554 Write_Info_EOL;
556 -- Generate with lines, first those that are directly with'ed
558 for J in With_Flags'Range loop
559 With_Flags (J) := False;
560 Elab_Flags (J) := False;
561 Elab_All_Flags (J) := False;
562 Elab_Des_Flags (J) := False;
563 Elab_All_Des_Flags (J) := False;
564 Implicit_With (J) := Unknown;
565 end loop;
567 Collect_Withs (Unode);
569 -- For a body, we must also check for any subunits which belong to
570 -- it and which have context clauses of their own, since these
571 -- with'ed units are part of its own elaboration dependencies.
573 if Nkind (Unit (Unode)) in N_Unit_Body then
574 for S in Units.First .. Last_Unit loop
576 -- We are only interested in subunits. For preproc. data and
577 -- def. files, Cunit is Empty, so we need to test that first.
579 if Cunit (S) /= Empty
580 and then Nkind (Unit (Cunit (S))) = N_Subunit
581 then
582 Pnode := Library_Unit (Cunit (S));
584 -- In gnatc mode, the errors in the subunits will not have
585 -- been recorded, but the analysis of the subunit may have
586 -- failed. There is no information to add to ALI file in
587 -- this case.
589 if No (Pnode) then
590 exit;
591 end if;
593 -- Find ultimate parent of the subunit
595 while Nkind (Unit (Pnode)) = N_Subunit loop
596 Pnode := Library_Unit (Pnode);
597 end loop;
599 -- See if it belongs to current unit, and if so, include
600 -- its with_clauses.
602 if Pnode = Unode then
603 Collect_Withs (Cunit (S));
604 end if;
605 end if;
606 end loop;
607 end if;
609 Write_With_Lines;
611 -- Generate the linker option lines
613 for J in 1 .. Linker_Option_Lines.Last loop
615 -- Pragma Linker_Options is not allowed in predefined generic
616 -- units. This is because they won't be read, due to the fact that
617 -- with lines for generic units lack the file name and lib name
618 -- parameters (see Lib_Writ spec for an explanation).
620 if Is_Generic_Unit (Cunit_Entity (Main_Unit))
621 and then
622 Is_Predefined_File_Name (Unit_File_Name (Current_Sem_Unit))
623 and then Linker_Option_Lines.Table (J).Unit = Unit_Num
624 then
625 Set_Standard_Error;
626 Write_Line
627 ("linker options not allowed in predefined generic unit");
628 raise Unrecoverable_Error;
629 end if;
631 -- Output one linker option line
633 declare
634 S : Linker_Option_Entry renames Linker_Option_Lines.Table (J);
635 begin
636 if S.Unit = Unit_Num then
637 Write_Info_Initiate ('L');
638 Write_Info_Char (' ');
639 Write_Info_Slit (S.Option);
640 Write_Info_EOL;
641 end if;
642 end;
643 end loop;
645 -- Output notes
647 for J in 1 .. Notes.Last loop
648 declare
649 N : constant Node_Id := Notes.Table (J);
650 L : constant Source_Ptr := Sloc (N);
651 U : constant Unit_Number_Type :=
652 Unit (Get_Source_File_Index (L));
653 C : Character;
655 Note_Unit : Unit_Number_Type;
656 -- The unit in whose U section this note must be emitted:
657 -- notes for subunits are emitted along with the main unit;
658 -- all other notes are emitted as part of the enclosing
659 -- compilation unit.
661 begin
662 if U /= No_Unit and then Nkind (Unit (Cunit (U))) = N_Subunit
663 then
664 Note_Unit := Main_Unit;
665 else
666 Note_Unit := U;
667 end if;
669 if Note_Unit = Unit_Num then
670 Write_Info_Initiate ('N');
671 Write_Info_Char (' ');
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;
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)));
693 -- Indicate source file of annotation if different from
694 -- compilation unit source file (case of annotation coming
695 -- from a separate).
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;
702 declare
703 A : Node_Id;
705 begin
706 A := First (Pragma_Argument_Associations (N));
707 while Present (A) loop
708 Write_Info_Char (' ');
710 if Chars (A) /= No_Name then
711 Write_Info_Name (Chars (A));
712 Write_Info_Char (':');
713 end if;
715 declare
716 Expr : constant Node_Id := Expression (A);
718 begin
719 if Nkind (Expr) = N_Identifier then
720 Write_Info_Name (Chars (Expr));
722 elsif Nkind (Expr) = N_Integer_Literal
723 and then Is_OK_Static_Expression (Expr)
724 then
725 Write_Info_Uint (Intval (Expr));
727 elsif Nkind (Expr) = N_String_Literal
728 and then Is_OK_Static_Expression (Expr)
729 then
730 Write_Info_Slit (Strval (Expr));
732 else
733 Write_Info_Str ("<expr>");
734 end if;
735 end;
737 Next (A);
738 end loop;
739 end;
741 Write_Info_EOL;
742 end if;
743 end;
744 end loop;
745 end Write_Unit_Information;
747 ----------------------
748 -- Write_With_Lines --
749 ----------------------
751 procedure Write_With_Lines is
752 Pname : constant Unit_Name_Type :=
753 Get_Parent_Spec_Name (Unit_Name (Main_Unit));
754 Body_Fname : File_Name_Type;
755 Body_Index : Nat;
756 Cunit : Node_Id;
757 Fname : File_Name_Type;
758 Num_Withs : Int := 0;
759 Unum : Unit_Number_Type;
760 Uname : Unit_Name_Type;
761 With_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 1));
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).
769 --------------------------
770 -- Write_With_File_Name --
771 --------------------------
773 procedure Write_With_File_Names
774 (Nam : in out File_Name_Type;
775 Idx : Nat)
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;
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;
789 -- Start of processing for Write_With_Lines
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.
797 for J in Units.First + 1 .. Last_Unit loop
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.
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;
814 -- Sort and output the table
816 Sort (With_Table (1 .. Num_Withs));
818 for J in 1 .. Num_Withs loop
819 Unum := With_Table (J);
821 -- Do not generate a with line for an ignored Ghost unit because
822 -- the unit does not have an ALI file.
824 if Is_Ignored_Ghost_Entity (Cunit_Entity (Unum)) then
825 goto Next_With_Line;
826 end if;
828 Cunit := Units.Table (Unum).Cunit;
829 Uname := Units.Table (Unum).Unit_Name;
830 Fname := Units.Table (Unum).Unit_File_Name;
832 if Implicit_With (Unum) = Yes then
833 Write_Info_Initiate ('Z');
835 elsif Ekind (Cunit_Entity (Unum)) = E_Package
836 and then From_Limited_With (Cunit_Entity (Unum))
837 then
838 Write_Info_Initiate ('Y');
840 else
841 Write_Info_Initiate ('W');
842 end if;
844 Write_Info_Char (' ');
845 Write_Info_Name (Uname);
847 -- Now we need to figure out the names of the files that contain
848 -- the with'ed unit. These will usually be the files for the body,
849 -- except in the case of a package that has no body. Note that we
850 -- have a specific exemption here for predefined library generics
851 -- (see comments for Generic_May_Lack_ALI). We do not generate
852 -- dependency upon the ALI file for such units. Older compilers
853 -- used to not support generating code (and ALI) for generics, and
854 -- we want to avoid having different processing (namely, different
855 -- lists of files to be compiled) for different stages of the
856 -- bootstrap.
858 if not ((Nkind (Unit (Cunit)) in N_Generic_Declaration
859 or else
860 Nkind (Unit (Cunit)) in N_Generic_Renaming_Declaration)
861 and then Generic_May_Lack_ALI (Fname))
863 -- In SPARK mode, always generate the dependencies on ALI
864 -- files, which are required to compute frame conditions
865 -- of subprograms.
867 or else GNATprove_Mode
868 then
869 Write_Info_Tab (25);
871 if Is_Spec_Name (Uname) then
872 Body_Fname :=
873 Get_File_Name
874 (Get_Body_Name (Uname),
875 Subunit => False, May_Fail => True);
877 Body_Index :=
878 Get_Unit_Index
879 (Get_Body_Name (Uname));
881 if Body_Fname = No_File then
882 Body_Fname := Get_File_Name (Uname, Subunit => False);
883 Body_Index := Get_Unit_Index (Uname);
884 end if;
886 else
887 Body_Fname := Get_File_Name (Uname, Subunit => False);
888 Body_Index := Get_Unit_Index (Uname);
889 end if;
891 -- A package is considered to have a body if it requires
892 -- a body or if a body is present in Ada 83 mode.
894 if Body_Required (Cunit)
895 or else (Ada_Version = Ada_83
896 and then Full_Source_Name (Body_Fname) /= No_File)
897 then
898 Write_With_File_Names (Body_Fname, Body_Index);
899 else
900 Write_With_File_Names (Fname, Munit_Index (Unum));
901 end if;
903 if Ekind (Cunit_Entity (Unum)) = E_Package
904 and then From_Limited_With (Cunit_Entity (Unum))
905 then
906 null;
907 else
908 if Elab_Flags (Unum) then
909 Write_Info_Str (" E");
910 end if;
912 if Elab_All_Flags (Unum) then
913 Write_Info_Str (" EA");
914 end if;
916 if Elab_Des_Flags (Unum) then
917 Write_Info_Str (" ED");
918 end if;
920 if Elab_All_Des_Flags (Unum) then
921 Write_Info_Str (" AD");
922 end if;
923 end if;
924 end if;
926 Write_Info_EOL;
928 <<Next_With_Line>>
929 null;
930 end loop;
932 -- Finally generate the special lines for cases of Restriction_Set
933 -- with No_Dependence and no restriction present.
935 declare
936 Unam : Unit_Name_Type;
938 begin
939 for J in Restriction_Set_Dependences.First ..
940 Restriction_Set_Dependences.Last
941 loop
942 Unam := Restriction_Set_Dependences.Table (J);
944 -- Don't need an entry if already in the unit table
946 for U in 0 .. Last_Unit loop
947 if Unit_Name (U) = Unam then
948 goto Next_Restriction_Set;
949 end if;
950 end loop;
952 -- Otherwise generate the entry
954 Write_Info_Initiate ('W');
955 Write_Info_Char (' ');
956 Write_Info_Name (Unam);
957 Write_Info_EOL;
959 <<Next_Restriction_Set>>
960 null;
961 end loop;
962 end;
963 end Write_With_Lines;
965 -- Start of processing for Write_ALI
967 begin
968 -- We never write an ALI file if the original operating mode was
969 -- syntax-only (-gnats switch used in compiler invocation line)
971 if Original_Operating_Mode = Check_Syntax
972 or flag_compare_debug /= 0
973 then
974 return;
975 end if;
977 -- Generation of ALI files may be disabled, e.g. for formal verification
978 -- back-end.
980 if Disable_ALI_File then
981 return;
982 end if;
984 -- Build sorted source dependency table. We do this right away, because
985 -- it is referenced by Up_To_Date_ALI_File_Exists.
987 for Unum in Units.First .. Last_Unit loop
988 if Cunit_Entity (Unum) = Empty
989 or else not From_Limited_With (Cunit_Entity (Unum))
990 then
991 Num_Sdep := Num_Sdep + 1;
992 Sdep_Table (Num_Sdep) := Unum;
993 end if;
994 end loop;
996 -- Sort the table so that the D lines are in order
998 Lib.Sort (Sdep_Table (1 .. Num_Sdep));
1000 -- If we are not generating code, and there is an up to date ALI file
1001 -- file accessible, read it, and acquire the compilation arguments from
1002 -- this file. In GNATprove mode, always generate the ALI file, which
1003 -- contains a special section for formal verification.
1005 if Operating_Mode /= Generate_Code and then not GNATprove_Mode then
1006 if Up_To_Date_ALI_File_Exists then
1007 Update_Tables_From_ALI_File;
1008 return;
1009 end if;
1010 end if;
1012 -- Otherwise acquire compilation arguments and prepare to write out a
1013 -- new ali file.
1015 Create_Output_Library_Info;
1017 -- Output version line
1019 Write_Info_Initiate ('V');
1020 Write_Info_Str (" """);
1021 Write_Info_Str (Verbose_Library_Version);
1022 Write_Info_Char ('"');
1024 Write_Info_EOL;
1026 -- Output main program line if this is acceptable main program
1028 Output_Main_Program_Line : declare
1029 U : Node_Id := Unit (Units.Table (Main_Unit).Cunit);
1030 S : Node_Id;
1032 procedure M_Parameters;
1033 -- Output parameters for main program line
1035 ------------------
1036 -- M_Parameters --
1037 ------------------
1039 procedure M_Parameters is
1040 begin
1041 if Main_Priority (Main_Unit) /= Default_Main_Priority then
1042 Write_Info_Char (' ');
1043 Write_Info_Nat (Main_Priority (Main_Unit));
1044 end if;
1046 if Opt.Time_Slice_Set then
1047 Write_Info_Str (" T=");
1048 Write_Info_Nat (Opt.Time_Slice_Value);
1049 end if;
1051 if Main_CPU (Main_Unit) /= Default_Main_CPU then
1052 Write_Info_Str (" C=");
1053 Write_Info_Nat (Main_CPU (Main_Unit));
1054 end if;
1056 Write_Info_Str (" W=");
1057 Write_Info_Char
1058 (WC_Encoding_Letters (Wide_Character_Encoding_Method));
1060 Write_Info_EOL;
1061 end M_Parameters;
1063 -- Start of processing for Output_Main_Program_Line
1065 begin
1066 if Nkind (U) = N_Subprogram_Body
1067 or else
1068 (Nkind (U) = N_Package_Body
1069 and then
1070 Nkind (Original_Node (U)) in N_Subprogram_Instantiation)
1071 then
1072 -- If the unit is a subprogram instance, the entity for the
1073 -- subprogram is the alias of the visible entity, which is the
1074 -- related instance of the wrapper package. We retrieve the
1075 -- subprogram declaration of the desired entity.
1077 if Nkind (U) = N_Package_Body then
1078 U := Parent (Parent (
1079 Alias (Related_Instance (Defining_Unit_Name
1080 (Specification (Unit (Library_Unit (Parent (U)))))))));
1081 end if;
1083 S := Specification (U);
1085 -- A generic subprogram is never a main program
1087 if Nkind (U) = N_Subprogram_Body
1088 and then Present (Corresponding_Spec (U))
1089 and then
1090 Ekind_In (Corresponding_Spec (U), E_Generic_Procedure,
1091 E_Generic_Function)
1092 then
1093 null;
1095 elsif No (Parameter_Specifications (S)) then
1096 if Nkind (S) = N_Procedure_Specification then
1097 Write_Info_Initiate ('M');
1098 Write_Info_Str (" P");
1099 M_Parameters;
1101 else
1102 declare
1103 Nam : Node_Id := Defining_Unit_Name (S);
1105 begin
1106 -- If it is a child unit, get its simple name
1108 if Nkind (Nam) = N_Defining_Program_Unit_Name then
1109 Nam := Defining_Identifier (Nam);
1110 end if;
1112 if Is_Integer_Type (Etype (Nam)) then
1113 Write_Info_Initiate ('M');
1114 Write_Info_Str (" F");
1115 M_Parameters;
1116 end if;
1117 end;
1118 end if;
1119 end if;
1120 end if;
1121 end Output_Main_Program_Line;
1123 -- Write command argument ('A') lines
1125 for A in 1 .. Compilation_Switches.Last loop
1126 Write_Info_Initiate ('A');
1127 Write_Info_Char (' ');
1128 Write_Info_Str (Compilation_Switches.Table (A).all);
1129 Write_Info_Terminate;
1130 end loop;
1132 -- Output parameters ('P') line
1134 Write_Info_Initiate ('P');
1136 if Compilation_Errors then
1137 Write_Info_Str (" CE");
1138 end if;
1140 if Opt.Detect_Blocking then
1141 Write_Info_Str (" DB");
1142 end if;
1144 if Tasking_Used
1145 and then not Is_Predefined_File_Name (Unit_File_Name (Main_Unit))
1146 then
1147 if Locking_Policy /= ' ' then
1148 Write_Info_Str (" L");
1149 Write_Info_Char (Locking_Policy);
1150 end if;
1152 if Queuing_Policy /= ' ' then
1153 Write_Info_Str (" Q");
1154 Write_Info_Char (Queuing_Policy);
1155 end if;
1157 if Task_Dispatching_Policy /= ' ' then
1158 Write_Info_Str (" T");
1159 Write_Info_Char (Task_Dispatching_Policy);
1160 Write_Info_Char (' ');
1161 end if;
1162 end if;
1164 if GNATprove_Mode then
1165 Write_Info_Str (" GP");
1166 end if;
1168 if Partition_Elaboration_Policy /= ' ' then
1169 Write_Info_Str (" E");
1170 Write_Info_Char (Partition_Elaboration_Policy);
1171 end if;
1173 if not Object then
1174 Write_Info_Str (" NO");
1175 end if;
1177 if No_Run_Time_Mode then
1178 Write_Info_Str (" NR");
1179 end if;
1181 if Normalize_Scalars then
1182 Write_Info_Str (" NS");
1183 end if;
1185 if Default_SSO_Config /= ' ' then
1186 Write_Info_Str (" O");
1187 Write_Info_Char (Default_SSO_Config);
1188 end if;
1190 if Sec_Stack_Used then
1191 Write_Info_Str (" SS");
1192 end if;
1194 if Unreserve_All_Interrupts then
1195 Write_Info_Str (" UA");
1196 end if;
1198 if Front_End_Exceptions then
1199 Write_Info_Str (" FX");
1200 end if;
1202 if ZCX_Exceptions then
1203 Write_Info_Str (" ZX");
1204 end if;
1206 Write_Info_EOL;
1208 -- Before outputting the restrictions line, update the setting of
1209 -- the No_Elaboration_Code flag. Violations of this restriction
1210 -- cannot be detected until after the backend has been called since
1211 -- it is the backend that sets this flag. We have to check all units
1212 -- for which we have generated code
1214 for Unit in Units.First .. Last_Unit loop
1215 if Units.Table (Unit).Generate_Code or else Unit = Main_Unit then
1216 if not Has_No_Elaboration_Code (Cunit (Unit)) then
1217 Main_Restrictions.Violated (No_Elaboration_Code) := True;
1218 end if;
1219 end if;
1220 end loop;
1222 -- Positional case (only if debug flag -gnatd.R is set)
1224 if Debug_Flag_Dot_RR then
1226 -- Output first restrictions line
1228 Write_Info_Initiate ('R');
1229 Write_Info_Char (' ');
1231 -- First the information for the boolean restrictions
1233 for R in All_Boolean_Restrictions loop
1234 if Main_Restrictions.Set (R)
1235 and then not Restriction_Warnings (R)
1236 then
1237 Write_Info_Char ('r');
1238 elsif Main_Restrictions.Violated (R) then
1239 Write_Info_Char ('v');
1240 else
1241 Write_Info_Char ('n');
1242 end if;
1243 end loop;
1245 -- And now the information for the parameter restrictions
1247 for RP in All_Parameter_Restrictions loop
1248 if Main_Restrictions.Set (RP)
1249 and then not Restriction_Warnings (RP)
1250 then
1251 Write_Info_Char ('r');
1252 Write_Info_Nat (Nat (Main_Restrictions.Value (RP)));
1253 else
1254 Write_Info_Char ('n');
1255 end if;
1257 if not Main_Restrictions.Violated (RP)
1258 or else RP not in Checked_Parameter_Restrictions
1259 then
1260 Write_Info_Char ('n');
1261 else
1262 Write_Info_Char ('v');
1263 Write_Info_Nat (Nat (Main_Restrictions.Count (RP)));
1265 if Main_Restrictions.Unknown (RP) then
1266 Write_Info_Char ('+');
1267 end if;
1268 end if;
1269 end loop;
1271 Write_Info_EOL;
1273 -- Named case (if debug flag -gnatd.R is not set)
1275 else
1276 declare
1277 C : Character;
1279 begin
1280 -- Write RN header line with preceding blank line
1282 Write_Info_EOL;
1283 Write_Info_Initiate ('R');
1284 Write_Info_Char ('N');
1285 Write_Info_EOL;
1287 -- First the lines for the boolean restrictions
1289 for R in All_Boolean_Restrictions loop
1290 if Main_Restrictions.Set (R)
1291 and then not Restriction_Warnings (R)
1292 then
1293 C := 'R';
1294 elsif Main_Restrictions.Violated (R) then
1295 C := 'V';
1296 else
1297 goto Continue;
1298 end if;
1300 Write_Info_Initiate ('R');
1301 Write_Info_Char (C);
1302 Write_Info_Char (' ');
1303 Write_Info_Str (All_Boolean_Restrictions'Image (R));
1304 Write_Info_EOL;
1306 <<Continue>>
1307 null;
1308 end loop;
1309 end;
1311 -- And now the lines for the parameter restrictions
1313 for RP in All_Parameter_Restrictions loop
1314 if Main_Restrictions.Set (RP)
1315 and then not Restriction_Warnings (RP)
1316 then
1317 Write_Info_Initiate ('R');
1318 Write_Info_Str ("R ");
1319 Write_Info_Str (All_Parameter_Restrictions'Image (RP));
1320 Write_Info_Char ('=');
1321 Write_Info_Nat (Nat (Main_Restrictions.Value (RP)));
1322 Write_Info_EOL;
1323 end if;
1325 if not Main_Restrictions.Violated (RP)
1326 or else RP not in Checked_Parameter_Restrictions
1327 then
1328 null;
1329 else
1330 Write_Info_Initiate ('R');
1331 Write_Info_Str ("V ");
1332 Write_Info_Str (All_Parameter_Restrictions'Image (RP));
1333 Write_Info_Char ('=');
1334 Write_Info_Nat (Nat (Main_Restrictions.Count (RP)));
1336 if Main_Restrictions.Unknown (RP) then
1337 Write_Info_Char ('+');
1338 end if;
1340 Write_Info_EOL;
1341 end if;
1342 end loop;
1343 end if;
1345 -- Output R lines for No_Dependence entries
1347 for J in No_Dependences.First .. No_Dependences.Last loop
1348 if In_Extended_Main_Source_Unit (No_Dependences.Table (J).Unit)
1349 and then not No_Dependences.Table (J).Warn
1350 then
1351 Write_Info_Initiate ('R');
1352 Write_Info_Char (' ');
1353 Write_Unit_Name (No_Dependences.Table (J).Unit);
1354 Write_Info_EOL;
1355 end if;
1356 end loop;
1358 -- Output interrupt state lines
1360 for J in Interrupt_States.First .. Interrupt_States.Last loop
1361 Write_Info_Initiate ('I');
1362 Write_Info_Char (' ');
1363 Write_Info_Nat (Interrupt_States.Table (J).Interrupt_Number);
1364 Write_Info_Char (' ');
1365 Write_Info_Char (Interrupt_States.Table (J).Interrupt_State);
1366 Write_Info_Char (' ');
1367 Write_Info_Nat
1368 (Nat (Get_Logical_Line_Number
1369 (Interrupt_States.Table (J).Pragma_Loc)));
1370 Write_Info_EOL;
1371 end loop;
1373 -- Output priority specific dispatching lines
1375 for J in Specific_Dispatching.First .. Specific_Dispatching.Last loop
1376 Write_Info_Initiate ('S');
1377 Write_Info_Char (' ');
1378 Write_Info_Char (Specific_Dispatching.Table (J).Dispatching_Policy);
1379 Write_Info_Char (' ');
1380 Write_Info_Nat (Specific_Dispatching.Table (J).First_Priority);
1381 Write_Info_Char (' ');
1382 Write_Info_Nat (Specific_Dispatching.Table (J).Last_Priority);
1383 Write_Info_Char (' ');
1384 Write_Info_Nat
1385 (Nat (Get_Logical_Line_Number
1386 (Specific_Dispatching.Table (J).Pragma_Loc)));
1387 Write_Info_EOL;
1388 end loop;
1390 -- Loop through file table to output information for all units for which
1391 -- we have generated code, as marked by the Generate_Code flag.
1393 for Unit in Units.First .. Last_Unit loop
1394 if Units.Table (Unit).Generate_Code
1395 or else Unit = Main_Unit
1396 then
1397 Write_Info_EOL; -- blank line
1398 Write_Unit_Information (Unit);
1399 end if;
1400 end loop;
1402 Write_Info_EOL; -- blank line
1404 -- Output external version reference lines
1406 for J in 1 .. Version_Ref.Last loop
1407 Write_Info_Initiate ('E');
1408 Write_Info_Char (' ');
1410 for K in 1 .. String_Length (Version_Ref.Table (J)) loop
1411 Write_Info_Char_Code (Get_String_Char (Version_Ref.Table (J), K));
1412 end loop;
1414 Write_Info_EOL;
1415 end loop;
1417 -- Prepare to output the source dependency lines
1419 declare
1420 Unum : Unit_Number_Type;
1421 -- Number of unit being output
1423 Sind : Source_File_Index;
1424 -- Index of corresponding source file
1426 Fname : File_Name_Type;
1428 begin
1429 for J in 1 .. Num_Sdep loop
1430 Unum := Sdep_Table (J);
1431 Units.Table (Unum).Dependency_Num := J;
1432 Sind := Units.Table (Unum).Source_Index;
1434 -- The dependency table also contains units that appear in the
1435 -- context of a unit loaded through a limited_with clause. These
1436 -- units are never analyzed, and thus the main unit does not
1437 -- really have a dependency on them.
1439 if Present (Cunit_Entity (Unum))
1440 and then Ekind (Cunit_Entity (Unum)) = E_Void
1441 then
1442 goto Next_Unit;
1443 end if;
1445 Write_Info_Initiate ('D');
1446 Write_Info_Char (' ');
1448 -- Normal case of a unit entry with a source index
1450 if Sind /= No_Source_File then
1451 Fname := File_Name (Sind);
1453 -- Ensure that on platforms where the file names are not case
1454 -- sensitive, the recorded file name is in lower case.
1456 if not File_Names_Case_Sensitive then
1457 Get_Name_String (Fname);
1458 To_Lower (Name_Buffer (1 .. Name_Len));
1459 Fname := Name_Find;
1460 end if;
1462 Write_Info_Name_May_Be_Quoted (Fname);
1463 Write_Info_Tab (25);
1464 Write_Info_Str (String (Time_Stamp (Sind)));
1465 Write_Info_Char (' ');
1466 Write_Info_Str (Get_Hex_String (Source_Checksum (Sind)));
1468 -- If the dependency comes from a limited_with clause,
1469 -- record limited_checksum.
1470 -- Disable for now, until full checksum changes are checked.
1472 -- if Present (Cunit_Entity (Unum))
1473 -- and then From_Limited_With (Cunit_Entity (Unum))
1474 -- then
1475 -- Write_Info_Char (' ');
1476 -- Write_Info_Char ('Y');
1477 -- Write_Info_Str (Get_Hex_String (Limited_Chk_Sum (Sind)));
1478 -- end if;
1480 -- If subunit, add unit name, omitting the %b at the end
1482 if Present (Cunit (Unum)) then
1483 Get_Decoded_Name_String (Unit_Name (Unum));
1484 Write_Info_Char (' ');
1486 if Nkind (Unit (Cunit (Unum))) = N_Subunit then
1487 Write_Info_Str (Name_Buffer (1 .. Name_Len - 2));
1488 else
1489 Write_Info_Str (Name_Buffer (1 .. Name_Len));
1490 end if;
1491 end if;
1493 -- If Source_Reference pragma used, output information
1495 if Num_SRef_Pragmas (Sind) > 0 then
1496 Write_Info_Char (' ');
1498 if Num_SRef_Pragmas (Sind) = 1 then
1499 Write_Info_Nat (Int (First_Mapped_Line (Sind)));
1500 else
1501 Write_Info_Nat (0);
1502 end if;
1504 Write_Info_Char (':');
1505 Write_Info_Name (Reference_Name (Sind));
1506 end if;
1508 -- Case where there is no source index (happens for missing
1509 -- files). In this case we write a dummy time stamp.
1511 else
1512 Write_Info_Name (Unit_File_Name (Unum));
1513 Write_Info_Tab (25);
1514 Write_Info_Str (String (Dummy_Time_Stamp));
1515 Write_Info_Char (' ');
1516 Write_Info_Str (Get_Hex_String (0));
1517 end if;
1519 Write_Info_EOL;
1521 <<Next_Unit>>
1522 null;
1523 end loop;
1524 end;
1526 -- Output cross-references
1528 if Opt.Xref_Active then
1529 Output_References;
1530 end if;
1532 -- Output SCO information if present
1534 if Generate_SCO then
1535 SCO_Record_Filtered;
1536 SCO_Output;
1537 end if;
1539 -- Output SPARK cross-reference information if needed
1541 if Opt.Xref_Active and then GNATprove_Mode then
1542 SPARK_Specific.Collect_SPARK_Xrefs (Sdep_Table => Sdep_Table,
1543 Num_Sdep => Num_Sdep);
1544 SPARK_Specific.Output_SPARK_Xrefs;
1545 end if;
1547 -- Output final blank line and we are done. This final blank line is
1548 -- probably junk, but we don't feel like making an incompatible change.
1550 Write_Info_Terminate;
1551 Close_Output_Library_Info;
1552 end Write_ALI;
1554 ---------------------
1555 -- Write_Unit_Name --
1556 ---------------------
1558 procedure Write_Unit_Name (N : Node_Id) is
1559 begin
1560 if Nkind (N) = N_Identifier then
1561 Write_Info_Name (Chars (N));
1563 else
1564 pragma Assert (Nkind (N) = N_Selected_Component);
1565 Write_Unit_Name (Prefix (N));
1566 Write_Info_Char ('.');
1567 Write_Unit_Name (Selector_Name (N));
1568 end if;
1569 end Write_Unit_Name;
1571 end Lib.Writ;