OSDN Git Service

* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Type>: Factor out
[pf3gnuchains/gcc-fork.git] / gcc / ada / makeutl.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                              M A K E U T L                               --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --          Copyright (C) 2004-2009, 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 Debug;
28 with Osint;    use Osint;
29 with Output;   use Output;
30 with Opt;      use Opt;
31 with Prj.Ext;
32 with Prj.Util;
33 with Snames;   use Snames;
34 with Table;
35
36 with Ada.Command_Line;  use Ada.Command_Line;
37
38 with GNAT.Directory_Operations; use GNAT.Directory_Operations;
39
40 with System.Case_Util; use System.Case_Util;
41 with System.HTable;
42
43 package body Makeutl is
44
45    type Mark_Key is record
46       File  : File_Name_Type;
47       Index : Int;
48    end record;
49    --  Identify either a mono-unit source (when Index = 0) or a specific unit
50    --  (index = 1's origin index of unit) in a multi-unit source.
51
52    --  There follow many global undocumented declarations, comments needed ???
53
54    Max_Mask_Num : constant := 2048;
55
56    subtype Mark_Num is Union_Id range 0 .. Max_Mask_Num - 1;
57
58    function Hash (Key : Mark_Key) return Mark_Num;
59
60    package Marks is new System.HTable.Simple_HTable
61      (Header_Num => Mark_Num,
62       Element    => Boolean,
63       No_Element => False,
64       Key        => Mark_Key,
65       Hash       => Hash,
66       Equal      => "=");
67    --  A hash table to keep tracks of the marked units
68
69    type Linker_Options_Data is record
70       Project : Project_Id;
71       Options : String_List_Id;
72    end record;
73
74    Linker_Option_Initial_Count : constant := 20;
75
76    Linker_Options_Buffer : String_List_Access :=
77      new String_List (1 .. Linker_Option_Initial_Count);
78
79    Last_Linker_Option : Natural := 0;
80
81    package Linker_Opts is new Table.Table (
82      Table_Component_Type => Linker_Options_Data,
83      Table_Index_Type     => Integer,
84      Table_Low_Bound      => 1,
85      Table_Initial        => 10,
86      Table_Increment      => 100,
87      Table_Name           => "Make.Linker_Opts");
88
89    procedure Add_Linker_Option (Option : String);
90
91    ---------
92    -- Add --
93    ---------
94
95    procedure Add
96      (Option : String_Access;
97       To     : in out String_List_Access;
98       Last   : in out Natural)
99    is
100    begin
101       if Last = To'Last then
102          declare
103             New_Options : constant String_List_Access :=
104                             new String_List (1 .. To'Last * 2);
105
106          begin
107             New_Options (To'Range) := To.all;
108
109             --  Set all elements of the original options to null to avoid
110             --  deallocation of copies.
111
112             To.all := (others => null);
113
114             Free (To);
115             To := New_Options;
116          end;
117       end if;
118
119       Last := Last + 1;
120       To (Last) := Option;
121    end Add;
122
123    procedure Add
124      (Option : String;
125       To     : in out String_List_Access;
126       Last   : in out Natural)
127    is
128    begin
129       Add (Option => new String'(Option), To => To, Last => Last);
130    end Add;
131
132    -----------------------
133    -- Add_Linker_Option --
134    -----------------------
135
136    procedure Add_Linker_Option (Option : String) is
137    begin
138       if Option'Length > 0 then
139          if Last_Linker_Option = Linker_Options_Buffer'Last then
140             declare
141                New_Buffer : constant String_List_Access :=
142                               new String_List
143                                 (1 .. Linker_Options_Buffer'Last +
144                                         Linker_Option_Initial_Count);
145             begin
146                New_Buffer (Linker_Options_Buffer'Range) :=
147                  Linker_Options_Buffer.all;
148                Linker_Options_Buffer.all := (others => null);
149                Free (Linker_Options_Buffer);
150                Linker_Options_Buffer := New_Buffer;
151             end;
152          end if;
153
154          Last_Linker_Option := Last_Linker_Option + 1;
155          Linker_Options_Buffer (Last_Linker_Option) := new String'(Option);
156       end if;
157    end Add_Linker_Option;
158
159    ------------------------------
160    -- Check_Source_Info_In_ALI --
161    ------------------------------
162
163    function Check_Source_Info_In_ALI (The_ALI : ALI_Id) return Boolean is
164       Unit_Name : Name_Id;
165
166    begin
167       --  Loop through units
168
169       for U in ALIs.Table (The_ALI).First_Unit ..
170                ALIs.Table (The_ALI).Last_Unit
171       loop
172          --  Check if the file name is one of the source of the unit
173
174          Get_Name_String (Units.Table (U).Uname);
175          Name_Len  := Name_Len - 2;
176          Unit_Name := Name_Find;
177
178          if File_Not_A_Source_Of (Unit_Name, Units.Table (U).Sfile) then
179             return False;
180          end if;
181
182          --  Loop to do same check for each of the withed units
183
184          for W in Units.Table (U).First_With .. Units.Table (U).Last_With loop
185             declare
186                WR : ALI.With_Record renames Withs.Table (W);
187
188             begin
189                if WR.Sfile /= No_File then
190                   Get_Name_String (WR.Uname);
191                   Name_Len  := Name_Len - 2;
192                   Unit_Name := Name_Find;
193
194                   if File_Not_A_Source_Of (Unit_Name, WR.Sfile) then
195                      return False;
196                   end if;
197                end if;
198             end;
199          end loop;
200       end loop;
201
202       --  Loop to check subunits
203
204       for D in ALIs.Table (The_ALI).First_Sdep ..
205                ALIs.Table (The_ALI).Last_Sdep
206       loop
207          declare
208             SD : Sdep_Record renames Sdep.Table (D);
209
210          begin
211             Unit_Name := SD.Subunit_Name;
212
213             if Unit_Name /= No_Name then
214
215                --  For separates, the file is no longer associated with the
216                --  unit ("proc-sep.adb" is not associated with unit "proc.sep".
217                --  So we need to check whether the source file still exists in
218                --  the source tree: it will if it matches the naming scheme
219                --  (and then will be for the same unit).
220
221                if Find_Source
222                  (In_Tree => Project_Tree,
223                   Project => No_Project,
224                   Base_Name => SD.Sfile) = No_Source
225                then
226                   --  If this is not a runtime file (when using -a) ? Otherwise
227                   --  we get complaints about a-except.adb, which uses
228                   --  separates.
229
230                   if not Check_Readonly_Files
231                     or else Find_File (SD.Sfile, Osint.Source) = No_File
232                   then
233                      if Verbose_Mode then
234                         Write_Line
235                           ("While parsing ALI file: Sdep associates "
236                            & Get_Name_String (SD.Sfile)
237                            & " with unit " & Get_Name_String (Unit_Name)
238                            & " but this does not match what was found while"
239                            & " parsing the project. Will recompile");
240                      end if;
241                      return False;
242                   end if;
243                end if;
244             end if;
245          end;
246       end loop;
247
248       return True;
249    end Check_Source_Info_In_ALI;
250
251    -----------------
252    -- Create_Name --
253    -----------------
254
255    function Create_Name (Name : String) return File_Name_Type is
256    begin
257       Name_Len := 0;
258       Add_Str_To_Name_Buffer (Name);
259       return Name_Find;
260    end Create_Name;
261
262    function Create_Name (Name : String) return Name_Id is
263    begin
264       Name_Len := 0;
265       Add_Str_To_Name_Buffer (Name);
266       return Name_Find;
267    end Create_Name;
268
269    function Create_Name (Name : String) return Path_Name_Type is
270    begin
271       Name_Len := 0;
272       Add_Str_To_Name_Buffer (Name);
273       return Name_Find;
274    end Create_Name;
275
276    ----------------------
277    -- Delete_All_Marks --
278    ----------------------
279
280    procedure Delete_All_Marks is
281    begin
282       Marks.Reset;
283    end Delete_All_Marks;
284
285    ----------------------------
286    -- Executable_Prefix_Path --
287    ----------------------------
288
289    function Executable_Prefix_Path return String is
290       Exec_Name : constant String := Command_Name;
291
292       function Get_Install_Dir (S : String) return String;
293       --  S is the executable name preceded by the absolute or relative path,
294       --  e.g. "c:\usr\bin\gcc.exe". Returns the absolute directory where "bin"
295       --  lies (in the example "C:\usr"). If the executable is not in a "bin"
296       --  directory, return "".
297
298       ---------------------
299       -- Get_Install_Dir --
300       ---------------------
301
302       function Get_Install_Dir (S : String) return String is
303          Exec      : String  := S;
304          Path_Last : Integer := 0;
305
306       begin
307          for J in reverse Exec'Range loop
308             if Exec (J) = Directory_Separator then
309                Path_Last := J - 1;
310                exit;
311             end if;
312          end loop;
313
314          if Path_Last >= Exec'First + 2 then
315             To_Lower (Exec (Path_Last - 2 .. Path_Last));
316          end if;
317
318          if Path_Last < Exec'First + 2
319            or else Exec (Path_Last - 2 .. Path_Last) /= "bin"
320            or else (Path_Last - 3 >= Exec'First
321                      and then Exec (Path_Last - 3) /= Directory_Separator)
322          then
323             return "";
324          end if;
325
326          return Normalize_Pathname (Exec (Exec'First .. Path_Last - 4))
327            & Directory_Separator;
328       end Get_Install_Dir;
329
330    --  Beginning of Executable_Prefix_Path
331
332    begin
333       --  First determine if a path prefix was placed in front of the
334       --  executable name.
335
336       for J in reverse Exec_Name'Range loop
337          if Exec_Name (J) = Directory_Separator then
338             return Get_Install_Dir (Exec_Name);
339          end if;
340       end loop;
341
342       --  If we get here, the user has typed the executable name with no
343       --  directory prefix.
344
345       declare
346          Path : String_Access := Locate_Exec_On_Path (Exec_Name);
347       begin
348          if Path = null then
349             return "";
350          else
351             declare
352                Dir : constant String := Get_Install_Dir (Path.all);
353             begin
354                Free (Path);
355                return Dir;
356             end;
357          end if;
358       end;
359    end Executable_Prefix_Path;
360
361    --------------------------
362    -- File_Not_A_Source_Of --
363    --------------------------
364
365    function File_Not_A_Source_Of
366      (Uname : Name_Id;
367       Sfile : File_Name_Type) return Boolean
368    is
369       Unit : constant Unit_Index :=
370                Units_Htable.Get (Project_Tree.Units_HT, Uname);
371
372       At_Least_One_File : Boolean := False;
373
374    begin
375       if Unit /= No_Unit_Index then
376          for F in Unit.File_Names'Range loop
377             if Unit.File_Names (F) /= null then
378                At_Least_One_File := True;
379                if Unit.File_Names (F).File = Sfile then
380                   return False;
381                end if;
382             end if;
383          end loop;
384
385          if not At_Least_One_File then
386
387             --  The unit was probably created initially for a separate unit
388             --  (which are initially created as IMPL when both suffixes are the
389             --  same). Later on, Override_Kind changed the type of the file,
390             --  and the unit is no longer valid in fact.
391
392             return False;
393          end if;
394
395          Verbose_Msg (Uname, "sources do not include ", Name_Id (Sfile));
396          return True;
397       end if;
398
399       return False;
400    end File_Not_A_Source_Of;
401
402    ----------
403    -- Hash --
404    ----------
405
406    function Hash (Key : Mark_Key) return Mark_Num is
407    begin
408       return Union_Id (Key.File) mod Max_Mask_Num;
409    end Hash;
410
411    ------------
412    -- Inform --
413    ------------
414
415    procedure Inform (N : File_Name_Type; Msg : String) is
416    begin
417       Inform (Name_Id (N), Msg);
418    end Inform;
419
420    procedure Inform (N : Name_Id := No_Name; Msg : String) is
421    begin
422       Osint.Write_Program_Name;
423
424       Write_Str (": ");
425
426       if N /= No_Name then
427          Write_Str ("""");
428
429          declare
430             Name : constant String := Get_Name_String (N);
431          begin
432             if Debug.Debug_Flag_F and then Is_Absolute_Path (Name) then
433                Write_Str (File_Name (Name));
434             else
435                Write_Str (Name);
436             end if;
437          end;
438
439          Write_Str (""" ");
440       end if;
441
442       Write_Str (Msg);
443       Write_Eol;
444    end Inform;
445
446    ----------------------------
447    -- Is_External_Assignment --
448    ----------------------------
449
450    function Is_External_Assignment
451      (Tree : Prj.Tree.Project_Node_Tree_Ref;
452       Argv : String) return Boolean
453    is
454       Start     : Positive := 3;
455       Finish    : Natural := Argv'Last;
456
457       pragma Assert (Argv'First = 1);
458       pragma Assert (Argv (1 .. 2) = "-X");
459
460    begin
461       if Argv'Last < 5 then
462          return False;
463
464       elsif Argv (3) = '"' then
465          if Argv (Argv'Last) /= '"' or else Argv'Last < 7 then
466             return False;
467          else
468             Start := 4;
469             Finish := Argv'Last - 1;
470          end if;
471       end if;
472
473       return Prj.Ext.Check
474         (Tree        => Tree,
475          Declaration => Argv (Start .. Finish));
476    end Is_External_Assignment;
477
478    ---------------
479    -- Is_Marked --
480    ---------------
481
482    function Is_Marked
483      (Source_File : File_Name_Type;
484       Index       : Int := 0) return Boolean
485    is
486    begin
487       return Marks.Get (K => (File => Source_File, Index => Index));
488    end Is_Marked;
489
490    -----------------------------
491    -- Linker_Options_Switches --
492    -----------------------------
493
494    function Linker_Options_Switches
495      (Project  : Project_Id;
496       In_Tree  : Project_Tree_Ref) return String_List
497    is
498       procedure Recursive_Add (Proj : Project_Id; Dummy : in out Boolean);
499       --  The recursive routine used to add linker options
500
501       -------------------
502       -- Recursive_Add --
503       -------------------
504
505       procedure Recursive_Add (Proj : Project_Id; Dummy : in out Boolean) is
506          pragma Unreferenced (Dummy);
507
508          Linker_Package : Package_Id;
509          Options        : Variable_Value;
510
511       begin
512          Linker_Package :=
513            Prj.Util.Value_Of
514              (Name        => Name_Linker,
515               In_Packages => Proj.Decl.Packages,
516               In_Tree     => In_Tree);
517
518          Options :=
519            Prj.Util.Value_Of
520              (Name                    => Name_Ada,
521               Index                   => 0,
522               Attribute_Or_Array_Name => Name_Linker_Options,
523               In_Package              => Linker_Package,
524               In_Tree                 => In_Tree);
525
526          --  If attribute is present, add the project with
527          --  the attribute to table Linker_Opts.
528
529          if Options /= Nil_Variable_Value then
530             Linker_Opts.Increment_Last;
531             Linker_Opts.Table (Linker_Opts.Last) :=
532               (Project => Proj, Options => Options.Values);
533          end if;
534       end Recursive_Add;
535
536       procedure For_All_Projects is
537         new For_Every_Project_Imported (Boolean, Recursive_Add);
538
539       Dummy : Boolean := False;
540
541    --  Start of processing for Linker_Options_Switches
542
543    begin
544       Linker_Opts.Init;
545
546       For_All_Projects (Project, Dummy, Imported_First => True);
547
548       Last_Linker_Option := 0;
549
550       for Index in reverse 1 .. Linker_Opts.Last loop
551          declare
552             Options : String_List_Id;
553             Proj    : constant Project_Id :=
554                         Linker_Opts.Table (Index).Project;
555             Option  : Name_Id;
556             Dir_Path : constant String :=
557                          Get_Name_String (Proj.Directory.Name);
558
559          begin
560             Options := Linker_Opts.Table (Index).Options;
561             while Options /= Nil_String loop
562                Option := In_Tree.String_Elements.Table (Options).Value;
563                Get_Name_String (Option);
564
565                --  Do not consider empty linker options
566
567                if Name_Len /= 0 then
568                   Add_Linker_Option (Name_Buffer (1 .. Name_Len));
569
570                   --  Object files and -L switches specified with relative
571                   --  paths must be converted to absolute paths.
572
573                   Test_If_Relative_Path
574                     (Switch => Linker_Options_Buffer (Last_Linker_Option),
575                      Parent => Dir_Path,
576                      Including_L_Switch => True);
577                end if;
578
579                Options := In_Tree.String_Elements.Table (Options).Next;
580             end loop;
581          end;
582       end loop;
583
584       return Linker_Options_Buffer (1 .. Last_Linker_Option);
585    end Linker_Options_Switches;
586
587    -----------
588    -- Mains --
589    -----------
590
591    package body Mains is
592
593       type File_And_Loc is record
594          File_Name : File_Name_Type;
595          Location  : Source_Ptr := No_Location;
596       end record;
597
598       package Names is new Table.Table
599         (Table_Component_Type => File_And_Loc,
600          Table_Index_Type     => Integer,
601          Table_Low_Bound      => 1,
602          Table_Initial        => 10,
603          Table_Increment      => 100,
604          Table_Name           => "Makeutl.Mains.Names");
605       --  The table that stores the mains
606
607       Current : Natural := 0;
608       --  The index of the last main retrieved from the table
609
610       --------------
611       -- Add_Main --
612       --------------
613
614       procedure Add_Main (Name : String) is
615       begin
616          Name_Len := 0;
617          Add_Str_To_Name_Buffer (Name);
618          Names.Increment_Last;
619          Names.Table (Names.Last) := (Name_Find, No_Location);
620       end Add_Main;
621
622       ------------
623       -- Delete --
624       ------------
625
626       procedure Delete is
627       begin
628          Names.Set_Last (0);
629          Mains.Reset;
630       end Delete;
631
632       ------------------
633       -- Get_Location --
634       ------------------
635
636       function Get_Location return Source_Ptr is
637       begin
638          if Current in Names.First .. Names.Last then
639             return Names.Table (Current).Location;
640          else
641             return No_Location;
642          end if;
643       end Get_Location;
644
645       ---------------
646       -- Next_Main --
647       ---------------
648
649       function Next_Main return String is
650       begin
651          if Current >= Names.Last then
652             return "";
653          else
654             Current := Current + 1;
655             return Get_Name_String (Names.Table (Current).File_Name);
656          end if;
657       end Next_Main;
658
659       ---------------------
660       -- Number_Of_Mains --
661       ---------------------
662
663       function Number_Of_Mains return Natural is
664       begin
665          return Names.Last;
666       end Number_Of_Mains;
667
668       -----------
669       -- Reset --
670       -----------
671
672       procedure Reset is
673       begin
674          Current := 0;
675       end Reset;
676
677       ------------------
678       -- Set_Location --
679       ------------------
680
681       procedure Set_Location (Location : Source_Ptr) is
682       begin
683          if Names.Last > 0 then
684             Names.Table (Names.Last).Location := Location;
685          end if;
686       end Set_Location;
687
688       -----------------
689       -- Update_Main --
690       -----------------
691
692       procedure Update_Main (Name : String) is
693       begin
694          if Current in Names.First .. Names.Last then
695             Name_Len := 0;
696             Add_Str_To_Name_Buffer (Name);
697             Names.Table (Current).File_Name := Name_Find;
698          end if;
699       end Update_Main;
700    end Mains;
701
702    ----------
703    -- Mark --
704    ----------
705
706    procedure Mark (Source_File : File_Name_Type; Index : Int := 0) is
707    begin
708       Marks.Set (K => (File => Source_File, Index => Index), E => True);
709    end Mark;
710
711    -----------------------
712    -- Path_Or_File_Name --
713    -----------------------
714
715    function Path_Or_File_Name (Path : Path_Name_Type) return String is
716       Path_Name : constant String := Get_Name_String (Path);
717    begin
718       if Debug.Debug_Flag_F then
719          return File_Name (Path_Name);
720       else
721          return Path_Name;
722       end if;
723    end Path_Or_File_Name;
724
725    ---------------------------
726    -- Test_If_Relative_Path --
727    ---------------------------
728
729    procedure Test_If_Relative_Path
730      (Switch               : in out String_Access;
731       Parent               : String;
732       Including_L_Switch   : Boolean := True;
733       Including_Non_Switch : Boolean := True;
734       Including_RTS        : Boolean := False)
735    is
736    begin
737       if Switch /= null then
738          declare
739             Sw    : String (1 .. Switch'Length);
740             Start : Positive;
741
742          begin
743             Sw := Switch.all;
744
745             if Sw (1) = '-' then
746                if Sw'Length >= 3
747                  and then (Sw (2) = 'A'
748                             or else Sw (2) = 'I'
749                             or else (Including_L_Switch and then Sw (2) = 'L'))
750                then
751                   Start := 3;
752
753                   if Sw = "-I-" then
754                      return;
755                   end if;
756
757                elsif Sw'Length >= 4
758                  and then (Sw (2 .. 3) = "aL"
759                             or else Sw (2 .. 3) = "aO"
760                             or else Sw (2 .. 3) = "aI")
761                then
762                   Start := 4;
763
764                elsif Including_RTS
765                  and then Sw'Length >= 7
766                  and then Sw (2 .. 6) = "-RTS="
767                then
768                   Start := 7;
769
770                else
771                   return;
772                end if;
773
774                --  Because relative path arguments to --RTS= may be relative
775                --  to the search directory prefix, those relative path
776                --  arguments are converted only when they include directory
777                --  information.
778
779                if not Is_Absolute_Path (Sw (Start .. Sw'Last)) then
780                   if Parent'Length = 0 then
781                      Do_Fail
782                        ("relative search path switches ("""
783                         & Sw
784                         & """) are not allowed");
785
786                   elsif Including_RTS then
787                      for J in Start .. Sw'Last loop
788                         if Sw (J) = Directory_Separator then
789                            Switch :=
790                              new String'
791                                (Sw (1 .. Start - 1) &
792                                 Parent &
793                                 Directory_Separator &
794                                 Sw (Start .. Sw'Last));
795                            return;
796                         end if;
797                      end loop;
798
799                   else
800                      Switch :=
801                        new String'
802                          (Sw (1 .. Start - 1) &
803                           Parent &
804                           Directory_Separator &
805                           Sw (Start .. Sw'Last));
806                   end if;
807                end if;
808
809             elsif Including_Non_Switch then
810                if not Is_Absolute_Path (Sw) then
811                   if Parent'Length = 0 then
812                      Do_Fail
813                        ("relative paths (""" & Sw & """) are not allowed");
814                   else
815                      Switch := new String'(Parent & Directory_Separator & Sw);
816                   end if;
817                end if;
818             end if;
819          end;
820       end if;
821    end Test_If_Relative_Path;
822
823    -------------------
824    -- Unit_Index_Of --
825    -------------------
826
827    function Unit_Index_Of (ALI_File : File_Name_Type) return Int is
828       Start  : Natural;
829       Finish : Natural;
830       Result : Int := 0;
831
832    begin
833       Get_Name_String (ALI_File);
834
835       --  First, find the last dot
836
837       Finish := Name_Len;
838
839       while Finish >= 1 and then Name_Buffer (Finish) /= '.' loop
840          Finish := Finish - 1;
841       end loop;
842
843       if Finish = 1 then
844          return 0;
845       end if;
846
847       --  Now check that the dot is preceded by digits
848
849       Start := Finish;
850       Finish := Finish - 1;
851
852       while Start >= 1 and then Name_Buffer (Start - 1) in '0' .. '9' loop
853          Start := Start - 1;
854       end loop;
855
856       --  If there are no digits, or if the digits are not preceded by the
857       --  character that precedes a unit index, this is not the ALI file of
858       --  a unit in a multi-unit source.
859
860       if Start > Finish
861         or else Start = 1
862         or else Name_Buffer (Start - 1) /= Multi_Unit_Index_Character
863       then
864          return 0;
865       end if;
866
867       --  Build the index from the digit(s)
868
869       while Start <= Finish loop
870          Result := Result * 10 +
871                      Character'Pos (Name_Buffer (Start)) - Character'Pos ('0');
872          Start := Start + 1;
873       end loop;
874
875       return Result;
876    end Unit_Index_Of;
877
878    -----------------
879    -- Verbose_Msg --
880    -----------------
881
882    procedure Verbose_Msg
883      (N1                : Name_Id;
884       S1                : String;
885       N2                : Name_Id := No_Name;
886       S2                : String  := "";
887       Prefix            : String := "  -> ";
888       Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low)
889    is
890    begin
891       if not Opt.Verbose_Mode
892         or else Minimum_Verbosity > Opt.Verbosity_Level
893       then
894          return;
895       end if;
896
897       Write_Str (Prefix);
898       Write_Str ("""");
899       Write_Name (N1);
900       Write_Str (""" ");
901       Write_Str (S1);
902
903       if N2 /= No_Name then
904          Write_Str (" """);
905          Write_Name (N2);
906          Write_Str (""" ");
907       end if;
908
909       Write_Str (S2);
910       Write_Eol;
911    end Verbose_Msg;
912
913    procedure Verbose_Msg
914      (N1                : File_Name_Type;
915       S1                : String;
916       N2                : File_Name_Type := No_File;
917       S2                : String  := "";
918       Prefix            : String := "  -> ";
919       Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low)
920    is
921    begin
922       Verbose_Msg
923         (Name_Id (N1), S1, Name_Id (N2), S2, Prefix, Minimum_Verbosity);
924    end Verbose_Msg;
925
926 end Makeutl;