* g++.dg/template/using30.C: Move ...
[official-gcc.git] / gcc / ada / ali.adb
blob3a3431878aa03461d600b052cf221930725e3334
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- A L I --
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 ------------------------------------------------------------------------------
26 with Butil; use Butil;
27 with Debug; use Debug;
28 with Fname; use Fname;
29 with Opt; use Opt;
30 with Osint; use Osint;
31 with Output; use Output;
33 package body ALI is
35 use ASCII;
36 -- Make control characters visible
38 -- The following variable records which characters currently are
39 -- used as line type markers in the ALI file. This is used in
40 -- Scan_ALI to detect (or skip) invalid lines.
42 Known_ALI_Lines : constant array (Character range 'A' .. 'Z') of Boolean :=
43 ('V' => True, -- version
44 'M' => True, -- main program
45 'A' => True, -- argument
46 'P' => True, -- program
47 'R' => True, -- restriction
48 'I' => True, -- interrupt
49 'U' => True, -- unit
50 'W' => True, -- with
51 'L' => True, -- linker option
52 'N' => True, -- notes
53 'E' => True, -- external
54 'D' => True, -- dependency
55 'X' => True, -- xref
56 'S' => True, -- specific dispatching
57 'Y' => True, -- limited_with
58 'Z' => True, -- implicit with from instantiation
59 'C' => True, -- SCO information
60 'F' => True, -- SPARK cross-reference information
61 others => False);
63 --------------------
64 -- Initialize_ALI --
65 --------------------
67 procedure Initialize_ALI is
68 begin
69 -- When (re)initializing ALI data structures the ALI user expects to
70 -- get a fresh set of data structures. Thus we first need to erase the
71 -- marks put in the name table by the previous set of ALI routine calls.
72 -- These two loops are empty and harmless the first time in.
74 for J in ALIs.First .. ALIs.Last loop
75 Set_Name_Table_Info (ALIs.Table (J).Afile, 0);
76 end loop;
78 for J in Units.First .. Units.Last loop
79 Set_Name_Table_Info (Units.Table (J).Uname, 0);
80 end loop;
82 -- Free argument table strings
84 for J in Args.First .. Args.Last loop
85 Free (Args.Table (J));
86 end loop;
88 -- Initialize all tables
90 ALIs.Init;
91 No_Deps.Init;
92 Units.Init;
93 Withs.Init;
94 Sdep.Init;
95 Linker_Options.Init;
96 Notes.Init;
97 Xref_Section.Init;
98 Xref_Entity.Init;
99 Xref.Init;
100 Version_Ref.Reset;
102 -- Add dummy zero'th item in Linker_Options and Notes for sort calls
104 Linker_Options.Increment_Last;
105 Notes.Increment_Last;
107 -- Initialize global variables recording cumulative options in all
108 -- ALI files that are read for a given processing run in gnatbind.
110 Dynamic_Elaboration_Checks_Specified := False;
111 Locking_Policy_Specified := ' ';
112 No_Normalize_Scalars_Specified := False;
113 No_Object_Specified := False;
114 GNATprove_Mode_Specified := False;
115 Normalize_Scalars_Specified := False;
116 Partition_Elaboration_Policy_Specified := ' ';
117 Queuing_Policy_Specified := ' ';
118 SSO_Default_Specified := False;
119 Static_Elaboration_Model_Used := False;
120 Task_Dispatching_Policy_Specified := ' ';
121 Unreserve_All_Interrupts_Specified := False;
122 Zero_Cost_Exceptions_Specified := False;
123 end Initialize_ALI;
125 --------------
126 -- Scan_ALI --
127 --------------
129 function Scan_ALI
130 (F : File_Name_Type;
131 T : Text_Buffer_Ptr;
132 Ignore_ED : Boolean;
133 Err : Boolean;
134 Read_Xref : Boolean := False;
135 Read_Lines : String := "";
136 Ignore_Lines : String := "X";
137 Ignore_Errors : Boolean := False;
138 Directly_Scanned : Boolean := False) return ALI_Id
140 P : Text_Ptr := T'First;
141 Line : Logical_Line_Number := 1;
142 Id : ALI_Id;
143 C : Character;
144 NS_Found : Boolean;
145 First_Arg : Arg_Id;
147 Ignore : array (Character range 'A' .. 'Z') of Boolean;
148 -- Ignore (X) is set to True if lines starting with X are to
149 -- be ignored by Scan_ALI and skipped, and False if the lines
150 -- are to be read and processed.
152 Bad_ALI_Format : exception;
153 -- Exception raised by Fatal_Error if Err is True
155 function At_Eol return Boolean;
156 -- Test if at end of line
158 function At_End_Of_Field return Boolean;
159 -- Test if at end of line, or if at blank or horizontal tab
161 procedure Check_At_End_Of_Field;
162 -- Check if we are at end of field, fatal error if not
164 procedure Checkc (C : Character);
165 -- Check next character is C. If so bump past it, if not fatal error
167 procedure Check_Unknown_Line;
168 -- If Ignore_Errors mode, then checks C to make sure that it is not
169 -- an unknown ALI line type characters, and if so, skips lines
170 -- until the first character of the line is one of these characters,
171 -- at which point it does a Getc to put that character in C. The
172 -- call has no effect if C is already an appropriate character.
173 -- If not in Ignore_Errors mode, a fatal error is signalled if the
174 -- line is unknown. Note that if C is an EOL on entry, the line is
175 -- skipped (it is assumed that blank lines are never significant).
176 -- If C is EOF on entry, the call has no effect (it is assumed that
177 -- the caller will properly handle this case).
179 procedure Fatal_Error;
180 -- Generate fatal error message for badly formatted ALI file if
181 -- Err is false, or raise Bad_ALI_Format if Err is True.
183 procedure Fatal_Error_Ignore;
184 pragma Inline (Fatal_Error_Ignore);
185 -- In Ignore_Errors mode, has no effect, otherwise same as Fatal_Error
187 function Getc return Character;
188 -- Get next character, bumping P past the character obtained
190 function Get_File_Name
191 (Lower : Boolean := False;
192 May_Be_Quoted : Boolean := False) return File_Name_Type;
193 -- Skip blanks, then scan out a file name (name is left in Name_Buffer
194 -- with length in Name_Len, as well as returning a File_Name_Type value.
195 -- If May_Be_Quoted is True and the first non blank character is '"',
196 -- then remove starting and ending quotes and undoubled internal quotes.
197 -- If lower is false, the case is unchanged, if Lower is True then the
198 -- result is forced to all lower case for systems where file names are
199 -- not case sensitive. This ensures that gnatbind works correctly
200 -- regardless of the case of the file name on all systems. The scan
201 -- is terminated by a end of line, space or horizontal tab. Any other
202 -- special characters are included in the returned name.
204 function Get_Name
205 (Ignore_Spaces : Boolean := False;
206 Ignore_Special : Boolean := False;
207 May_Be_Quoted : Boolean := False) return Name_Id;
208 -- Skip blanks, then scan out a name (name is left in Name_Buffer with
209 -- length in Name_Len, as well as being returned in Name_Id form).
210 -- If Lower is set to True then the Name_Buffer will be converted to
211 -- all lower case, for systems where file names are not case sensitive.
212 -- This ensures that gnatbind works correctly regardless of the case
213 -- of the file name on all systems. The termination condition depends
214 -- on the settings of Ignore_Spaces and Ignore_Special:
216 -- If Ignore_Spaces is False (normal case), then scan is terminated
217 -- by the normal end of field condition (EOL, space, horizontal tab)
219 -- If Ignore_Special is False (normal case), the scan is terminated by
220 -- a typeref bracket or an equal sign except for the special case of
221 -- an operator name starting with a double quote which is terminated
222 -- by another double quote.
224 -- If May_Be_Quoted is True and the first non blank character is '"'
225 -- the name is 'unquoted'. In this case Ignore_Special is ignored and
226 -- assumed to be True.
228 -- It is an error to set both Ignore_Spaces and Ignore_Special to True.
229 -- This function handles wide characters properly.
231 function Get_Nat return Nat;
232 -- Skip blanks, then scan out an unsigned integer value in Nat range
233 -- raises ALI_Reading_Error if the encoutered type is not natural.
235 function Get_Stamp return Time_Stamp_Type;
236 -- Skip blanks, then scan out a time stamp
238 function Get_Unit_Name return Unit_Name_Type;
239 -- Skip blanks, then scan out a file name (name is left in Name_Buffer
240 -- with length in Name_Len, as well as returning a Unit_Name_Type value.
241 -- The case is unchanged and terminated by a normal end of field.
243 function Nextc return Character;
244 -- Return current character without modifying pointer P
246 procedure Get_Typeref
247 (Current_File_Num : Sdep_Id;
248 Ref : out Tref_Kind;
249 File_Num : out Sdep_Id;
250 Line : out Nat;
251 Ref_Type : out Character;
252 Col : out Nat;
253 Standard_Entity : out Name_Id);
254 -- Parse the definition of a typeref (<...>, {...} or (...))
256 procedure Skip_Eol;
257 -- Skip past spaces, then skip past end of line (fatal error if not
258 -- at end of line). Also skips past any following blank lines.
260 procedure Skip_Line;
261 -- Skip rest of current line and any following blank lines
263 procedure Skip_Space;
264 -- Skip past white space (blanks or horizontal tab)
266 procedure Skipc;
267 -- Skip past next character, does not affect value in C. This call
268 -- is like calling Getc and ignoring the returned result.
270 ---------------------
271 -- At_End_Of_Field --
272 ---------------------
274 function At_End_Of_Field return Boolean is
275 begin
276 return Nextc <= ' ';
277 end At_End_Of_Field;
279 ------------
280 -- At_Eol --
281 ------------
283 function At_Eol return Boolean is
284 begin
285 return Nextc = EOF or else Nextc = CR or else Nextc = LF;
286 end At_Eol;
288 ---------------------------
289 -- Check_At_End_Of_Field --
290 ---------------------------
292 procedure Check_At_End_Of_Field is
293 begin
294 if not At_End_Of_Field then
295 if Ignore_Errors then
296 while Nextc > ' ' loop
297 P := P + 1;
298 end loop;
299 else
300 Fatal_Error;
301 end if;
302 end if;
303 end Check_At_End_Of_Field;
305 ------------------------
306 -- Check_Unknown_Line --
307 ------------------------
309 procedure Check_Unknown_Line is
310 begin
311 while C not in 'A' .. 'Z'
312 or else not Known_ALI_Lines (C)
313 loop
314 if C = CR or else C = LF then
315 Skip_Line;
316 C := Nextc;
318 elsif C = EOF then
319 return;
321 elsif Ignore_Errors then
322 Skip_Line;
323 C := Getc;
325 else
326 Fatal_Error;
327 end if;
328 end loop;
329 end Check_Unknown_Line;
331 ------------
332 -- Checkc --
333 ------------
335 procedure Checkc (C : Character) is
336 begin
337 if Nextc = C then
338 P := P + 1;
339 elsif Ignore_Errors then
340 P := P + 1;
341 else
342 Fatal_Error;
343 end if;
344 end Checkc;
346 -----------------
347 -- Fatal_Error --
348 -----------------
350 procedure Fatal_Error is
351 Ptr1 : Text_Ptr;
352 Ptr2 : Text_Ptr;
353 Col : Int;
355 procedure Wchar (C : Character);
356 -- Write a single character, replacing horizontal tab by spaces
358 procedure Wchar (C : Character) is
359 begin
360 if C = HT then
361 loop
362 Wchar (' ');
363 exit when Col mod 8 = 0;
364 end loop;
366 else
367 Write_Char (C);
368 Col := Col + 1;
369 end if;
370 end Wchar;
372 -- Start of processing for Fatal_Error
374 begin
375 if Err then
376 raise Bad_ALI_Format;
377 end if;
379 Set_Standard_Error;
380 Write_Str ("fatal error: file ");
381 Write_Name (F);
382 Write_Str (" is incorrectly formatted");
383 Write_Eol;
385 Write_Str ("make sure you are using consistent versions " &
387 -- Split the following line so that it can easily be transformed for
388 -- e.g. JVM/.NET back-ends where the compiler has a different name.
390 "of gcc/gnatbind");
392 Write_Eol;
394 -- Find start of line
396 Ptr1 := P;
397 while Ptr1 > T'First
398 and then T (Ptr1 - 1) /= CR
399 and then T (Ptr1 - 1) /= LF
400 loop
401 Ptr1 := Ptr1 - 1;
402 end loop;
404 Write_Int (Int (Line));
405 Write_Str (". ");
407 if Line < 100 then
408 Write_Char (' ');
409 end if;
411 if Line < 10 then
412 Write_Char (' ');
413 end if;
415 Col := 0;
416 Ptr2 := Ptr1;
418 while Ptr2 < T'Last
419 and then T (Ptr2) /= CR
420 and then T (Ptr2) /= LF
421 loop
422 Wchar (T (Ptr2));
423 Ptr2 := Ptr2 + 1;
424 end loop;
426 Write_Eol;
428 Write_Str (" ");
429 Col := 0;
431 while Ptr1 < P loop
432 if T (Ptr1) = HT then
433 Wchar (HT);
434 else
435 Wchar (' ');
436 end if;
438 Ptr1 := Ptr1 + 1;
439 end loop;
441 Wchar ('|');
442 Write_Eol;
444 Exit_Program (E_Fatal);
445 end Fatal_Error;
447 ------------------------
448 -- Fatal_Error_Ignore --
449 ------------------------
451 procedure Fatal_Error_Ignore is
452 begin
453 if not Ignore_Errors then
454 Fatal_Error;
455 end if;
456 end Fatal_Error_Ignore;
458 -------------------
459 -- Get_File_Name --
460 -------------------
462 function Get_File_Name
463 (Lower : Boolean := False;
464 May_Be_Quoted : Boolean := False) return File_Name_Type
466 F : Name_Id;
468 begin
469 F := Get_Name (Ignore_Special => True,
470 May_Be_Quoted => May_Be_Quoted);
472 -- Convert file name to all lower case if file names are not case
473 -- sensitive. This ensures that we handle names in the canonical
474 -- lower case format, regardless of the actual case.
476 if Lower and not File_Names_Case_Sensitive then
477 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
478 return Name_Find;
479 else
480 return File_Name_Type (F);
481 end if;
482 end Get_File_Name;
484 --------------
485 -- Get_Name --
486 --------------
488 function Get_Name
489 (Ignore_Spaces : Boolean := False;
490 Ignore_Special : Boolean := False;
491 May_Be_Quoted : Boolean := False) return Name_Id
493 Char : Character;
495 begin
496 Name_Len := 0;
497 Skip_Space;
499 if At_Eol then
500 if Ignore_Errors then
501 return Error_Name;
502 else
503 Fatal_Error;
504 end if;
505 end if;
507 Char := Getc;
509 -- Deal with quoted characters
511 if May_Be_Quoted and then Char = '"' then
512 loop
513 if At_Eol then
514 if Ignore_Errors then
515 return Error_Name;
516 else
517 Fatal_Error;
518 end if;
519 end if;
521 Char := Getc;
523 if Char = '"' then
524 if At_Eol then
525 exit;
527 else
528 Char := Getc;
530 if Char /= '"' then
531 P := P - 1;
532 exit;
533 end if;
534 end if;
535 end if;
537 Add_Char_To_Name_Buffer (Char);
538 end loop;
540 -- Other than case of quoted character
542 else
543 P := P - 1;
544 loop
545 Add_Char_To_Name_Buffer (Getc);
547 exit when At_End_Of_Field and then not Ignore_Spaces;
549 if not Ignore_Special then
550 if Name_Buffer (1) = '"' then
551 exit when Name_Len > 1
552 and then Name_Buffer (Name_Len) = '"';
554 else
555 -- Terminate on parens or angle brackets or equal sign
557 exit when Nextc = '(' or else Nextc = ')'
558 or else Nextc = '{' or else Nextc = '}'
559 or else Nextc = '<' or else Nextc = '>'
560 or else Nextc = '=';
562 -- Terminate on comma
564 exit when Nextc = ',';
566 -- Terminate if left bracket not part of wide char
567 -- sequence Note that we only recognize brackets
568 -- notation so far ???
570 exit when Nextc = '[' and then T (P + 1) /= '"';
572 -- Terminate if right bracket not part of wide char
573 -- sequence.
575 exit when Nextc = ']' and then T (P - 1) /= '"';
576 end if;
577 end if;
578 end loop;
579 end if;
581 return Name_Find;
582 end Get_Name;
584 -------------------
585 -- Get_Unit_Name --
586 -------------------
588 function Get_Unit_Name return Unit_Name_Type is
589 begin
590 return Unit_Name_Type (Get_Name);
591 end Get_Unit_Name;
593 -------------
594 -- Get_Nat --
595 -------------
597 function Get_Nat return Nat is
598 V : Nat;
600 begin
601 Skip_Space;
603 -- Check if we are on a number. In the case of bad ALI files, this
604 -- may not be true.
606 if not (Nextc in '0' .. '9') then
607 Fatal_Error;
608 end if;
610 V := 0;
611 loop
612 V := V * 10 + (Character'Pos (Getc) - Character'Pos ('0'));
614 exit when At_End_Of_Field;
615 exit when Nextc < '0' or else Nextc > '9';
616 end loop;
618 return V;
619 end Get_Nat;
621 ---------------
622 -- Get_Stamp --
623 ---------------
625 function Get_Stamp return Time_Stamp_Type is
626 T : Time_Stamp_Type;
627 Start : Integer;
629 begin
630 Skip_Space;
632 if At_Eol then
633 if Ignore_Errors then
634 return Dummy_Time_Stamp;
635 else
636 Fatal_Error;
637 end if;
638 end if;
640 -- Following reads old style time stamp missing first two digits
642 if Nextc in '7' .. '9' then
643 T (1) := '1';
644 T (2) := '9';
645 Start := 3;
647 -- Normal case of full year in time stamp
649 else
650 Start := 1;
651 end if;
653 for J in Start .. T'Last loop
654 T (J) := Getc;
655 end loop;
657 return T;
658 end Get_Stamp;
660 -----------------
661 -- Get_Typeref --
662 -----------------
664 procedure Get_Typeref
665 (Current_File_Num : Sdep_Id;
666 Ref : out Tref_Kind;
667 File_Num : out Sdep_Id;
668 Line : out Nat;
669 Ref_Type : out Character;
670 Col : out Nat;
671 Standard_Entity : out Name_Id)
673 N : Nat;
674 begin
675 case Nextc is
676 when '<' => Ref := Tref_Derived;
677 when '(' => Ref := Tref_Access;
678 when '{' => Ref := Tref_Type;
679 when others => Ref := Tref_None;
680 end case;
682 -- Case of typeref field present
684 if Ref /= Tref_None then
685 P := P + 1; -- skip opening bracket
687 if Nextc in 'a' .. 'z' then
688 File_Num := No_Sdep_Id;
689 Line := 0;
690 Ref_Type := ' ';
691 Col := 0;
692 Standard_Entity := Get_Name (Ignore_Spaces => True);
693 else
694 N := Get_Nat;
696 if Nextc = '|' then
697 File_Num := Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
698 P := P + 1;
699 N := Get_Nat;
700 else
701 File_Num := Current_File_Num;
702 end if;
704 Line := N;
705 Ref_Type := Getc;
706 Col := Get_Nat;
707 Standard_Entity := No_Name;
708 end if;
710 -- ??? Temporary workaround for nested generics case:
711 -- 4i4 Directories{1|4I9[4|6[3|3]]}
712 -- See C918-002
714 declare
715 Nested_Brackets : Natural := 0;
717 begin
718 loop
719 case Nextc is
720 when '[' =>
721 Nested_Brackets := Nested_Brackets + 1;
722 when ']' =>
723 Nested_Brackets := Nested_Brackets - 1;
724 when others =>
725 if Nested_Brackets = 0 then
726 exit;
727 end if;
728 end case;
730 Skipc;
731 end loop;
732 end;
734 P := P + 1; -- skip closing bracket
735 Skip_Space;
737 -- No typeref entry present
739 else
740 File_Num := No_Sdep_Id;
741 Line := 0;
742 Ref_Type := ' ';
743 Col := 0;
744 Standard_Entity := No_Name;
745 end if;
746 end Get_Typeref;
748 ----------
749 -- Getc --
750 ----------
752 function Getc return Character is
753 begin
754 if P = T'Last then
755 return EOF;
756 else
757 P := P + 1;
758 return T (P - 1);
759 end if;
760 end Getc;
762 -----------
763 -- Nextc --
764 -----------
766 function Nextc return Character is
767 begin
768 return T (P);
769 end Nextc;
771 --------------
772 -- Skip_Eol --
773 --------------
775 procedure Skip_Eol is
776 begin
777 Skip_Space;
779 if not At_Eol then
780 if Ignore_Errors then
781 while not At_Eol loop
782 P := P + 1;
783 end loop;
784 else
785 Fatal_Error;
786 end if;
787 end if;
789 -- Loop to skip past blank lines (first time through skips this EOL)
791 while Nextc < ' ' and then Nextc /= EOF loop
792 if Nextc = LF then
793 Line := Line + 1;
794 end if;
796 P := P + 1;
797 end loop;
798 end Skip_Eol;
800 ---------------
801 -- Skip_Line --
802 ---------------
804 procedure Skip_Line is
805 begin
806 while not At_Eol loop
807 P := P + 1;
808 end loop;
810 Skip_Eol;
811 end Skip_Line;
813 ----------------
814 -- Skip_Space --
815 ----------------
817 procedure Skip_Space is
818 begin
819 while Nextc = ' ' or else Nextc = HT loop
820 P := P + 1;
821 end loop;
822 end Skip_Space;
824 -----------
825 -- Skipc --
826 -----------
828 procedure Skipc is
829 begin
830 if P /= T'Last then
831 P := P + 1;
832 end if;
833 end Skipc;
835 -- Start of processing for Scan_ALI
837 begin
838 First_Sdep_Entry := Sdep.Last + 1;
840 -- Acquire lines to be ignored
842 if Read_Xref then
843 Ignore :=
844 ('U' | 'W' | 'Y' | 'Z' | 'D' | 'X' => False, others => True);
846 -- Read_Lines parameter given
848 elsif Read_Lines /= "" then
849 Ignore := ('U' => False, others => True);
851 for J in Read_Lines'Range loop
852 Ignore (Read_Lines (J)) := False;
853 end loop;
855 -- Process Ignore_Lines parameter
857 else
858 Ignore := (others => False);
860 for J in Ignore_Lines'Range loop
861 pragma Assert (Ignore_Lines (J) /= 'U');
862 Ignore (Ignore_Lines (J)) := True;
863 end loop;
864 end if;
866 -- Setup ALI Table entry with appropriate defaults
868 ALIs.Increment_Last;
869 Id := ALIs.Last;
870 Set_Name_Table_Info (F, Int (Id));
872 ALIs.Table (Id) := (
873 Afile => F,
874 Compile_Errors => False,
875 First_Interrupt_State => Interrupt_States.Last + 1,
876 First_Sdep => No_Sdep_Id,
877 First_Specific_Dispatching => Specific_Dispatching.Last + 1,
878 First_Unit => No_Unit_Id,
879 GNATprove_Mode => False,
880 Last_Interrupt_State => Interrupt_States.Last,
881 Last_Sdep => No_Sdep_Id,
882 Last_Specific_Dispatching => Specific_Dispatching.Last,
883 Last_Unit => No_Unit_Id,
884 Locking_Policy => ' ',
885 Main_Priority => -1,
886 Main_CPU => -1,
887 Main_Program => None,
888 No_Object => False,
889 Normalize_Scalars => False,
890 Ofile_Full_Name => Full_Object_File_Name,
891 Partition_Elaboration_Policy => ' ',
892 Queuing_Policy => ' ',
893 Restrictions => No_Restrictions,
894 SAL_Interface => False,
895 Sfile => No_File,
896 SSO_Default => ' ',
897 Task_Dispatching_Policy => ' ',
898 Time_Slice_Value => -1,
899 WC_Encoding => 'b',
900 Unit_Exception_Table => False,
901 Ver => (others => ' '),
902 Ver_Len => 0,
903 Zero_Cost_Exceptions => False);
905 -- Now we acquire the input lines from the ALI file. Note that the
906 -- convention in the following code is that as we enter each section,
907 -- C is set to contain the first character of the following line.
909 C := Getc;
910 Check_Unknown_Line;
912 -- Acquire library version
914 if C /= 'V' then
916 -- The V line missing really indicates trouble, most likely it
917 -- means we don't have an ALI file at all, so here we give a
918 -- fatal error even if we are in Ignore_Errors mode.
920 Fatal_Error;
922 elsif Ignore ('V') then
923 Skip_Line;
925 else
926 Checkc (' ');
927 Skip_Space;
928 Checkc ('"');
930 for J in 1 .. Ver_Len_Max loop
931 C := Getc;
932 exit when C = '"';
933 ALIs.Table (Id).Ver (J) := C;
934 ALIs.Table (Id).Ver_Len := J;
935 end loop;
937 Skip_Eol;
938 end if;
940 C := Getc;
941 Check_Unknown_Line;
943 -- Acquire main program line if present
945 if C = 'M' then
946 if Ignore ('M') then
947 Skip_Line;
949 else
950 Checkc (' ');
951 Skip_Space;
953 C := Getc;
955 if C = 'F' then
956 ALIs.Table (Id).Main_Program := Func;
957 elsif C = 'P' then
958 ALIs.Table (Id).Main_Program := Proc;
959 else
960 P := P - 1;
961 Fatal_Error;
962 end if;
964 Skip_Space;
966 if not At_Eol then
967 if Nextc < 'A' then
968 ALIs.Table (Id).Main_Priority := Get_Nat;
969 end if;
971 Skip_Space;
973 if Nextc = 'T' then
974 P := P + 1;
975 Checkc ('=');
976 ALIs.Table (Id).Time_Slice_Value := Get_Nat;
977 end if;
979 Skip_Space;
981 if Nextc = 'C' then
982 P := P + 1;
983 Checkc ('=');
984 ALIs.Table (Id).Main_CPU := Get_Nat;
985 end if;
987 Skip_Space;
989 Checkc ('W');
990 Checkc ('=');
991 ALIs.Table (Id).WC_Encoding := Getc;
992 end if;
994 Skip_Eol;
995 end if;
997 C := Getc;
998 end if;
1000 -- Acquire argument lines
1002 First_Arg := Args.Last + 1;
1004 A_Loop : loop
1005 Check_Unknown_Line;
1006 exit A_Loop when C /= 'A';
1008 if Ignore ('A') then
1009 Skip_Line;
1011 else
1012 Checkc (' ');
1014 -- Scan out argument
1016 Name_Len := 0;
1017 while not At_Eol loop
1018 Add_Char_To_Name_Buffer (Getc);
1019 end loop;
1021 -- If -fstack-check, record that it occurred. Note that an
1022 -- additional string parameter can be specified, in the form of
1023 -- -fstack-check={no|generic|specific}. "no" means no checking,
1024 -- "generic" means force the use of old-style checking, and
1025 -- "specific" means use the best checking method.
1027 if Name_Len >= 13
1028 and then Name_Buffer (1 .. 13) = "-fstack-check"
1029 and then Name_Buffer (1 .. Name_Len) /= "-fstack-check=no"
1030 then
1031 Stack_Check_Switch_Set := True;
1032 end if;
1034 -- Store the argument
1036 Args.Increment_Last;
1037 Args.Table (Args.Last) := new String'(Name_Buffer (1 .. Name_Len));
1039 Skip_Eol;
1040 end if;
1042 C := Getc;
1043 end loop A_Loop;
1045 -- Acquire P line
1047 Check_Unknown_Line;
1049 while C /= 'P' loop
1050 if Ignore_Errors then
1051 if C = EOF then
1052 Fatal_Error;
1053 else
1054 Skip_Line;
1055 C := Nextc;
1056 end if;
1057 else
1058 Fatal_Error;
1059 end if;
1060 end loop;
1062 if Ignore ('P') then
1063 Skip_Line;
1065 -- Process P line
1067 else
1068 NS_Found := False;
1070 while not At_Eol loop
1071 Checkc (' ');
1072 Skip_Space;
1073 C := Getc;
1075 -- Processing for CE
1077 if C = 'C' then
1078 Checkc ('E');
1079 ALIs.Table (Id).Compile_Errors := True;
1081 -- Processing for DB
1083 elsif C = 'D' then
1084 Checkc ('B');
1085 Detect_Blocking := True;
1087 -- Processing for Ex
1089 elsif C = 'E' then
1090 Partition_Elaboration_Policy_Specified := Getc;
1091 ALIs.Table (Id).Partition_Elaboration_Policy :=
1092 Partition_Elaboration_Policy_Specified;
1094 -- Processing for GP
1096 elsif C = 'G' then
1097 Checkc ('P');
1098 GNATprove_Mode_Specified := True;
1099 ALIs.Table (Id).GNATprove_Mode := True;
1101 -- Processing for Lx
1103 elsif C = 'L' then
1104 Locking_Policy_Specified := Getc;
1105 ALIs.Table (Id).Locking_Policy := Locking_Policy_Specified;
1107 -- Processing for flags starting with N
1109 elsif C = 'N' then
1110 C := Getc;
1112 -- Processing for NO
1114 if C = 'O' then
1115 ALIs.Table (Id).No_Object := True;
1116 No_Object_Specified := True;
1118 -- Processing for NR
1120 elsif C = 'R' then
1121 No_Run_Time_Mode := True;
1122 Configurable_Run_Time_Mode := True;
1124 -- Processing for NS
1126 elsif C = 'S' then
1127 ALIs.Table (Id).Normalize_Scalars := True;
1128 Normalize_Scalars_Specified := True;
1129 NS_Found := True;
1131 -- Invalid switch starting with N
1133 else
1134 Fatal_Error_Ignore;
1135 end if;
1137 -- Processing for OH/OL
1139 elsif C = 'O' then
1140 C := Getc;
1142 if C = 'L' or else C = 'H' then
1143 ALIs.Table (Id).SSO_Default := C;
1144 SSO_Default_Specified := True;
1146 else
1147 Fatal_Error_Ignore;
1148 end if;
1150 -- Processing for Qx
1152 elsif C = 'Q' then
1153 Queuing_Policy_Specified := Getc;
1154 ALIs.Table (Id).Queuing_Policy := Queuing_Policy_Specified;
1156 -- Processing for flags starting with S
1158 elsif C = 'S' then
1159 C := Getc;
1161 -- Processing for SL
1163 if C = 'L' then
1164 ALIs.Table (Id).SAL_Interface := True;
1166 -- Processing for SS
1168 elsif C = 'S' then
1169 Opt.Sec_Stack_Used := True;
1171 -- Invalid switch starting with S
1173 else
1174 Fatal_Error_Ignore;
1175 end if;
1177 -- Processing for Tx
1179 elsif C = 'T' then
1180 Task_Dispatching_Policy_Specified := Getc;
1181 ALIs.Table (Id).Task_Dispatching_Policy :=
1182 Task_Dispatching_Policy_Specified;
1184 -- Processing for switch starting with U
1186 elsif C = 'U' then
1187 C := Getc;
1189 -- Processing for UA
1191 if C = 'A' then
1192 Unreserve_All_Interrupts_Specified := True;
1194 -- Processing for UX
1196 elsif C = 'X' then
1197 ALIs.Table (Id).Unit_Exception_Table := True;
1199 -- Invalid switches starting with U
1201 else
1202 Fatal_Error_Ignore;
1203 end if;
1205 -- Processing for ZX
1207 elsif C = 'Z' then
1208 C := Getc;
1210 if C = 'X' then
1211 ALIs.Table (Id).Zero_Cost_Exceptions := True;
1212 Zero_Cost_Exceptions_Specified := True;
1213 else
1214 Fatal_Error_Ignore;
1215 end if;
1217 -- Invalid parameter
1219 else
1220 C := Getc;
1221 Fatal_Error_Ignore;
1222 end if;
1223 end loop;
1225 if not NS_Found then
1226 No_Normalize_Scalars_Specified := True;
1227 end if;
1229 Skip_Eol;
1230 end if;
1232 C := Getc;
1233 Check_Unknown_Line;
1235 -- Loop to skip to first restrictions line
1237 while C /= 'R' loop
1238 if Ignore_Errors then
1239 if C = EOF then
1240 Fatal_Error;
1241 else
1242 Skip_Line;
1243 C := Nextc;
1244 end if;
1245 else
1246 Fatal_Error;
1247 end if;
1248 end loop;
1250 -- Ignore all 'R' lines if that is required
1252 if Ignore ('R') then
1253 while C = 'R' loop
1254 Skip_Line;
1255 C := Getc;
1256 end loop;
1258 -- Here we process the restrictions lines (other than unit name cases)
1260 else
1261 Scan_Restrictions : declare
1262 Save_R : constant Restrictions_Info := Cumulative_Restrictions;
1263 -- Save cumulative restrictions in case we have a fatal error
1265 Bad_R_Line : exception;
1266 -- Signal bad restrictions line (raised on unexpected character)
1268 Typ : Character;
1269 R : Restriction_Id;
1270 N : Natural;
1272 begin
1273 -- Named restriction case
1275 if Nextc = 'N' then
1276 Skip_Line;
1277 C := Getc;
1279 -- Loop through RR and RV lines
1281 while C = 'R' and then Nextc /= ' ' loop
1282 Typ := Getc;
1283 Checkc (' ');
1285 -- Acquire restriction name
1287 Name_Len := 0;
1288 while not At_Eol and then Nextc /= '=' loop
1289 Name_Len := Name_Len + 1;
1290 Name_Buffer (Name_Len) := Getc;
1291 end loop;
1293 -- Now search list of restrictions to find match
1295 declare
1296 RN : String renames Name_Buffer (1 .. Name_Len);
1298 begin
1299 R := Restriction_Id'First;
1300 while R /= Not_A_Restriction_Id loop
1301 if Restriction_Id'Image (R) = RN then
1302 goto R_Found;
1303 end if;
1305 R := Restriction_Id'Succ (R);
1306 end loop;
1308 -- We don't recognize the restriction. This might be
1309 -- thought of as an error, and it really is, but we
1310 -- want to allow building with inconsistent versions
1311 -- of the binder and ali files (see comments at the
1312 -- start of package System.Rident), so we just ignore
1313 -- this situation.
1315 goto Done_With_Restriction_Line;
1316 end;
1318 <<R_Found>>
1320 case R is
1322 -- Boolean restriction case
1324 when All_Boolean_Restrictions =>
1325 case Typ is
1326 when 'V' =>
1327 ALIs.Table (Id).Restrictions.Violated (R) :=
1328 True;
1329 Cumulative_Restrictions.Violated (R) := True;
1331 when 'R' =>
1332 ALIs.Table (Id).Restrictions.Set (R) := True;
1333 Cumulative_Restrictions.Set (R) := True;
1335 when others =>
1336 raise Bad_R_Line;
1337 end case;
1339 -- Parameter restriction case
1341 when All_Parameter_Restrictions =>
1342 if At_Eol or else Nextc /= '=' then
1343 raise Bad_R_Line;
1344 else
1345 Skipc;
1346 end if;
1348 N := Natural (Get_Nat);
1350 case Typ is
1352 -- Restriction set
1354 when 'R' =>
1355 ALIs.Table (Id).Restrictions.Set (R) := True;
1356 ALIs.Table (Id).Restrictions.Value (R) := N;
1358 if Cumulative_Restrictions.Set (R) then
1359 Cumulative_Restrictions.Value (R) :=
1360 Integer'Min
1361 (Cumulative_Restrictions.Value (R), N);
1362 else
1363 Cumulative_Restrictions.Set (R) := True;
1364 Cumulative_Restrictions.Value (R) := N;
1365 end if;
1367 -- Restriction violated
1369 when 'V' =>
1370 ALIs.Table (Id).Restrictions.Violated (R) :=
1371 True;
1372 Cumulative_Restrictions.Violated (R) := True;
1373 ALIs.Table (Id).Restrictions.Count (R) := N;
1375 -- Checked Max_Parameter case
1377 if R in Checked_Max_Parameter_Restrictions then
1378 Cumulative_Restrictions.Count (R) :=
1379 Integer'Max
1380 (Cumulative_Restrictions.Count (R), N);
1382 -- Other checked parameter cases
1384 else
1385 declare
1386 pragma Unsuppress (Overflow_Check);
1388 begin
1389 Cumulative_Restrictions.Count (R) :=
1390 Cumulative_Restrictions.Count (R) + N;
1392 exception
1393 when Constraint_Error =>
1395 -- A constraint error comes from the
1396 -- addition. We reset to the maximum
1397 -- and indicate that the real value
1398 -- is now unknown.
1400 Cumulative_Restrictions.Value (R) :=
1401 Integer'Last;
1402 Cumulative_Restrictions.Unknown (R) :=
1403 True;
1404 end;
1405 end if;
1407 -- Deal with + case
1409 if Nextc = '+' then
1410 Skipc;
1411 ALIs.Table (Id).Restrictions.Unknown (R) :=
1412 True;
1413 Cumulative_Restrictions.Unknown (R) := True;
1414 end if;
1416 -- Other than 'R' or 'V'
1418 when others =>
1419 raise Bad_R_Line;
1420 end case;
1422 if not At_Eol then
1423 raise Bad_R_Line;
1424 end if;
1426 -- Bizarre error case NOT_A_RESTRICTION
1428 when Not_A_Restriction_Id =>
1429 raise Bad_R_Line;
1430 end case;
1432 if not At_Eol then
1433 raise Bad_R_Line;
1434 end if;
1436 <<Done_With_Restriction_Line>>
1437 Skip_Line;
1438 C := Getc;
1439 end loop;
1441 -- Positional restriction case
1443 else
1444 Checkc (' ');
1445 Skip_Space;
1447 -- Acquire information for boolean restrictions
1449 for R in All_Boolean_Restrictions loop
1450 C := Getc;
1452 case C is
1453 when 'v' =>
1454 ALIs.Table (Id).Restrictions.Violated (R) := True;
1455 Cumulative_Restrictions.Violated (R) := True;
1457 when 'r' =>
1458 ALIs.Table (Id).Restrictions.Set (R) := True;
1459 Cumulative_Restrictions.Set (R) := True;
1461 when 'n' =>
1462 null;
1464 when others =>
1465 raise Bad_R_Line;
1466 end case;
1467 end loop;
1469 -- Acquire information for parameter restrictions
1471 for RP in All_Parameter_Restrictions loop
1472 case Getc is
1473 when 'n' =>
1474 null;
1476 when 'r' =>
1477 ALIs.Table (Id).Restrictions.Set (RP) := True;
1479 declare
1480 N : constant Integer := Integer (Get_Nat);
1481 begin
1482 ALIs.Table (Id).Restrictions.Value (RP) := N;
1484 if Cumulative_Restrictions.Set (RP) then
1485 Cumulative_Restrictions.Value (RP) :=
1486 Integer'Min
1487 (Cumulative_Restrictions.Value (RP), N);
1488 else
1489 Cumulative_Restrictions.Set (RP) := True;
1490 Cumulative_Restrictions.Value (RP) := N;
1491 end if;
1492 end;
1494 when others =>
1495 raise Bad_R_Line;
1496 end case;
1498 -- Acquire restrictions violations information
1500 case Getc is
1502 when 'n' =>
1503 null;
1505 when 'v' =>
1506 ALIs.Table (Id).Restrictions.Violated (RP) := True;
1507 Cumulative_Restrictions.Violated (RP) := True;
1509 declare
1510 N : constant Integer := Integer (Get_Nat);
1512 begin
1513 ALIs.Table (Id).Restrictions.Count (RP) := N;
1515 if RP in Checked_Max_Parameter_Restrictions then
1516 Cumulative_Restrictions.Count (RP) :=
1517 Integer'Max
1518 (Cumulative_Restrictions.Count (RP), N);
1520 else
1521 declare
1522 pragma Unsuppress (Overflow_Check);
1524 begin
1525 Cumulative_Restrictions.Count (RP) :=
1526 Cumulative_Restrictions.Count (RP) + N;
1528 exception
1529 when Constraint_Error =>
1531 -- A constraint error comes from the add. We
1532 -- reset to the maximum and indicate that the
1533 -- real value is now unknown.
1535 Cumulative_Restrictions.Value (RP) :=
1536 Integer'Last;
1537 Cumulative_Restrictions.Unknown (RP) := True;
1538 end;
1539 end if;
1541 if Nextc = '+' then
1542 Skipc;
1543 ALIs.Table (Id).Restrictions.Unknown (RP) := True;
1544 Cumulative_Restrictions.Unknown (RP) := True;
1545 end if;
1546 end;
1548 when others =>
1549 raise Bad_R_Line;
1550 end case;
1551 end loop;
1553 if not At_Eol then
1554 raise Bad_R_Line;
1555 else
1556 Skip_Line;
1557 C := Getc;
1558 end if;
1559 end if;
1561 -- Here if error during scanning of restrictions line
1563 exception
1564 when Bad_R_Line =>
1566 -- In Ignore_Errors mode, undo any changes to restrictions
1567 -- from this unit, and continue on, skipping remaining R
1568 -- lines for this unit.
1570 if Ignore_Errors then
1571 Cumulative_Restrictions := Save_R;
1572 ALIs.Table (Id).Restrictions := No_Restrictions;
1574 loop
1575 Skip_Eol;
1576 C := Getc;
1577 exit when C /= 'R';
1578 end loop;
1580 -- In normal mode, this is a fatal error
1582 else
1583 Fatal_Error;
1584 end if;
1585 end Scan_Restrictions;
1586 end if;
1588 -- Acquire additional restrictions (No_Dependence) lines if present
1590 while C = 'R' loop
1591 if Ignore ('R') then
1592 Skip_Line;
1593 else
1594 Skip_Space;
1595 No_Deps.Append ((Id, Get_Name));
1596 Skip_Eol;
1597 end if;
1599 C := Getc;
1600 end loop;
1602 -- Acquire 'I' lines if present
1604 Check_Unknown_Line;
1606 while C = 'I' loop
1607 if Ignore ('I') then
1608 Skip_Line;
1610 else
1611 declare
1612 Int_Num : Nat;
1613 I_State : Character;
1614 Line_No : Nat;
1616 begin
1617 Int_Num := Get_Nat;
1618 Skip_Space;
1619 I_State := Getc;
1620 Line_No := Get_Nat;
1622 Interrupt_States.Append (
1623 (Interrupt_Id => Int_Num,
1624 Interrupt_State => I_State,
1625 IS_Pragma_Line => Line_No));
1627 ALIs.Table (Id).Last_Interrupt_State := Interrupt_States.Last;
1628 Skip_Eol;
1629 end;
1630 end if;
1632 C := Getc;
1633 end loop;
1635 -- Acquire 'S' lines if present
1637 Check_Unknown_Line;
1639 while C = 'S' loop
1640 if Ignore ('S') then
1641 Skip_Line;
1643 else
1644 declare
1645 Policy : Character;
1646 First_Prio : Nat;
1647 Last_Prio : Nat;
1648 Line_No : Nat;
1650 begin
1651 Checkc (' ');
1652 Skip_Space;
1654 Policy := Getc;
1655 Skip_Space;
1656 First_Prio := Get_Nat;
1657 Last_Prio := Get_Nat;
1658 Line_No := Get_Nat;
1660 Specific_Dispatching.Append (
1661 (Dispatching_Policy => Policy,
1662 First_Priority => First_Prio,
1663 Last_Priority => Last_Prio,
1664 PSD_Pragma_Line => Line_No));
1666 ALIs.Table (Id).Last_Specific_Dispatching :=
1667 Specific_Dispatching.Last;
1669 Skip_Eol;
1670 end;
1671 end if;
1673 C := Getc;
1674 end loop;
1676 -- Loop to acquire unit entries
1678 U_Loop : loop
1679 Check_Unknown_Line;
1680 exit U_Loop when C /= 'U';
1682 -- Note: as per spec, we never ignore U lines
1684 Checkc (' ');
1685 Skip_Space;
1686 Units.Increment_Last;
1688 if ALIs.Table (Id).First_Unit = No_Unit_Id then
1689 ALIs.Table (Id).First_Unit := Units.Last;
1690 end if;
1692 declare
1693 UL : Unit_Record renames Units.Table (Units.Last);
1695 begin
1696 UL.Uname := Get_Unit_Name;
1697 UL.Predefined := Is_Predefined_Unit;
1698 UL.Internal := Is_Internal_Unit;
1699 UL.My_ALI := Id;
1700 UL.Sfile := Get_File_Name (Lower => True);
1701 UL.Pure := False;
1702 UL.Preelab := False;
1703 UL.No_Elab := False;
1704 UL.Shared_Passive := False;
1705 UL.RCI := False;
1706 UL.Remote_Types := False;
1707 UL.Has_RACW := False;
1708 UL.Init_Scalars := False;
1709 UL.Is_Generic := False;
1710 UL.Icasing := Mixed_Case;
1711 UL.Kcasing := All_Lower_Case;
1712 UL.Dynamic_Elab := False;
1713 UL.Elaborate_Body := False;
1714 UL.Set_Elab_Entity := False;
1715 UL.Version := "00000000";
1716 UL.First_With := Withs.Last + 1;
1717 UL.First_Arg := First_Arg;
1718 UL.Elab_Position := 0;
1719 UL.SAL_Interface := ALIs.Table (Id).SAL_Interface;
1720 UL.Directly_Scanned := Directly_Scanned;
1721 UL.Body_Needed_For_SAL := False;
1722 UL.Elaborate_Body_Desirable := False;
1723 UL.Optimize_Alignment := 'O';
1724 UL.Has_Finalizer := False;
1726 if Debug_Flag_U then
1727 Write_Str (" ----> reading unit ");
1728 Write_Int (Int (Units.Last));
1729 Write_Str (" ");
1730 Write_Unit_Name (UL.Uname);
1731 Write_Str (" from file ");
1732 Write_Name (UL.Sfile);
1733 Write_Eol;
1734 end if;
1735 end;
1737 -- Check for duplicated unit in different files
1739 declare
1740 Info : constant Int := Get_Name_Table_Info
1741 (Units.Table (Units.Last).Uname);
1742 begin
1743 if Info /= 0
1744 and then Units.Table (Units.Last).Sfile /=
1745 Units.Table (Unit_Id (Info)).Sfile
1746 then
1747 -- If Err is set then ignore duplicate unit name. This is the
1748 -- case of a call from gnatmake, where the situation can arise
1749 -- from substitution of source files. In such situations, the
1750 -- processing in gnatmake will always result in any required
1751 -- recompilations in any case, and if we consider this to be
1752 -- an error we get strange cases (for example when a generic
1753 -- instantiation is replaced by a normal package) where we
1754 -- read the old ali file, decide to recompile, and then decide
1755 -- that the old and new ali files are incompatible.
1757 if Err then
1758 null;
1760 -- If Err is not set, then this is a fatal error. This is
1761 -- the case of being called from the binder, where we must
1762 -- definitely diagnose this as an error.
1764 else
1765 Set_Standard_Error;
1766 Write_Str ("error: duplicate unit name: ");
1767 Write_Eol;
1769 Write_Str ("error: unit """);
1770 Write_Unit_Name (Units.Table (Units.Last).Uname);
1771 Write_Str (""" found in file """);
1772 Write_Name_Decoded (Units.Table (Units.Last).Sfile);
1773 Write_Char ('"');
1774 Write_Eol;
1776 Write_Str ("error: unit """);
1777 Write_Unit_Name (Units.Table (Unit_Id (Info)).Uname);
1778 Write_Str (""" found in file """);
1779 Write_Name_Decoded (Units.Table (Unit_Id (Info)).Sfile);
1780 Write_Char ('"');
1781 Write_Eol;
1783 Exit_Program (E_Fatal);
1784 end if;
1785 end if;
1786 end;
1788 Set_Name_Table_Info
1789 (Units.Table (Units.Last).Uname, Int (Units.Last));
1791 -- Scan out possible version and other parameters
1793 loop
1794 Skip_Space;
1795 exit when At_Eol;
1796 C := Getc;
1798 -- Version field
1800 if C in '0' .. '9' or else C in 'a' .. 'f' then
1801 Units.Table (Units.Last).Version (1) := C;
1803 for J in 2 .. 8 loop
1804 C := Getc;
1805 Units.Table (Units.Last).Version (J) := C;
1806 end loop;
1808 -- BD/BN parameters
1810 elsif C = 'B' then
1811 C := Getc;
1813 if C = 'D' then
1814 Check_At_End_Of_Field;
1815 Units.Table (Units.Last).Elaborate_Body_Desirable := True;
1817 elsif C = 'N' then
1818 Check_At_End_Of_Field;
1819 Units.Table (Units.Last).Body_Needed_For_SAL := True;
1821 else
1822 Fatal_Error_Ignore;
1823 end if;
1825 -- DE parameter (Dynamic elaboration checks)
1827 elsif C = 'D' then
1828 C := Getc;
1830 if C = 'E' then
1831 Check_At_End_Of_Field;
1832 Units.Table (Units.Last).Dynamic_Elab := True;
1833 Dynamic_Elaboration_Checks_Specified := True;
1834 else
1835 Fatal_Error_Ignore;
1836 end if;
1838 -- EB/EE parameters
1840 elsif C = 'E' then
1841 C := Getc;
1843 if C = 'B' then
1844 Units.Table (Units.Last).Elaborate_Body := True;
1845 elsif C = 'E' then
1846 Units.Table (Units.Last).Set_Elab_Entity := True;
1847 else
1848 Fatal_Error_Ignore;
1849 end if;
1851 Check_At_End_Of_Field;
1853 -- GE parameter (generic)
1855 elsif C = 'G' then
1856 C := Getc;
1858 if C = 'E' then
1859 Check_At_End_Of_Field;
1860 Units.Table (Units.Last).Is_Generic := True;
1861 else
1862 Fatal_Error_Ignore;
1863 end if;
1865 -- IL/IS/IU parameters
1867 elsif C = 'I' then
1868 C := Getc;
1870 if C = 'L' then
1871 Units.Table (Units.Last).Icasing := All_Lower_Case;
1872 elsif C = 'S' then
1873 Units.Table (Units.Last).Init_Scalars := True;
1874 Initialize_Scalars_Used := True;
1875 elsif C = 'U' then
1876 Units.Table (Units.Last).Icasing := All_Upper_Case;
1877 else
1878 Fatal_Error_Ignore;
1879 end if;
1881 Check_At_End_Of_Field;
1883 -- KM/KU parameters
1885 elsif C = 'K' then
1886 C := Getc;
1888 if C = 'M' then
1889 Units.Table (Units.Last).Kcasing := Mixed_Case;
1890 elsif C = 'U' then
1891 Units.Table (Units.Last).Kcasing := All_Upper_Case;
1892 else
1893 Fatal_Error_Ignore;
1894 end if;
1896 Check_At_End_Of_Field;
1898 -- NE parameter
1900 elsif C = 'N' then
1901 C := Getc;
1903 if C = 'E' then
1904 Units.Table (Units.Last).No_Elab := True;
1905 Check_At_End_Of_Field;
1906 else
1907 Fatal_Error_Ignore;
1908 end if;
1910 -- PF/PR/PU/PK parameters
1912 elsif C = 'P' then
1913 C := Getc;
1915 if C = 'F' then
1916 Units.Table (Units.Last).Has_Finalizer := True;
1917 elsif C = 'R' then
1918 Units.Table (Units.Last).Preelab := True;
1919 elsif C = 'U' then
1920 Units.Table (Units.Last).Pure := True;
1921 elsif C = 'K' then
1922 Units.Table (Units.Last).Unit_Kind := 'p';
1923 else
1924 Fatal_Error_Ignore;
1925 end if;
1927 Check_At_End_Of_Field;
1929 -- OL/OO/OS/OT parameters
1931 elsif C = 'O' then
1932 C := Getc;
1934 if C = 'L' or else C = 'O' or else C = 'S' or else C = 'T' then
1935 Units.Table (Units.Last).Optimize_Alignment := C;
1936 else
1937 Fatal_Error_Ignore;
1938 end if;
1940 Check_At_End_Of_Field;
1942 -- RC/RT parameters
1944 elsif C = 'R' then
1945 C := Getc;
1947 if C = 'C' then
1948 Units.Table (Units.Last).RCI := True;
1949 elsif C = 'T' then
1950 Units.Table (Units.Last).Remote_Types := True;
1951 elsif C = 'A' then
1952 Units.Table (Units.Last).Has_RACW := True;
1953 else
1954 Fatal_Error_Ignore;
1955 end if;
1957 Check_At_End_Of_Field;
1959 elsif C = 'S' then
1960 C := Getc;
1962 if C = 'P' then
1963 Units.Table (Units.Last).Shared_Passive := True;
1964 elsif C = 'U' then
1965 Units.Table (Units.Last).Unit_Kind := 's';
1966 else
1967 Fatal_Error_Ignore;
1968 end if;
1970 Check_At_End_Of_Field;
1972 else
1973 C := Getc;
1974 Fatal_Error_Ignore;
1975 end if;
1976 end loop;
1978 Skip_Eol;
1980 -- Check if static elaboration model used
1982 if not Units.Table (Units.Last).Dynamic_Elab
1983 and then not Units.Table (Units.Last).Internal
1984 then
1985 Static_Elaboration_Model_Used := True;
1986 end if;
1988 C := Getc;
1990 -- Scan out With lines for this unit
1992 With_Loop : loop
1993 Check_Unknown_Line;
1994 exit With_Loop when C /= 'W' and then C /= 'Y' and then C /= 'Z';
1996 if Ignore ('W') then
1997 Skip_Line;
1999 else
2000 Checkc (' ');
2001 Skip_Space;
2002 Withs.Increment_Last;
2003 Withs.Table (Withs.Last).Uname := Get_Unit_Name;
2004 Withs.Table (Withs.Last).Elaborate := False;
2005 Withs.Table (Withs.Last).Elaborate_All := False;
2006 Withs.Table (Withs.Last).Elab_Desirable := False;
2007 Withs.Table (Withs.Last).Elab_All_Desirable := False;
2008 Withs.Table (Withs.Last).SAL_Interface := False;
2009 Withs.Table (Withs.Last).Limited_With := (C = 'Y');
2010 Withs.Table (Withs.Last).Implicit_With_From_Instantiation
2011 := (C = 'Z');
2013 -- Generic case with no object file available
2015 if At_Eol then
2016 Withs.Table (Withs.Last).Sfile := No_File;
2017 Withs.Table (Withs.Last).Afile := No_File;
2019 -- Normal case
2021 else
2022 Withs.Table (Withs.Last).Sfile := Get_File_Name
2023 (Lower => True);
2024 Withs.Table (Withs.Last).Afile := Get_File_Name
2025 (Lower => True);
2027 -- Scan out possible E, EA, ED, and AD parameters
2029 while not At_Eol loop
2030 Skip_Space;
2032 if Nextc = 'A' then
2033 P := P + 1;
2034 Checkc ('D');
2035 Check_At_End_Of_Field;
2037 -- Store AD indication unless ignore required
2039 if not Ignore_ED then
2040 Withs.Table (Withs.Last).Elab_All_Desirable :=
2041 True;
2042 end if;
2044 elsif Nextc = 'E' then
2045 P := P + 1;
2047 if At_End_Of_Field then
2048 Withs.Table (Withs.Last).Elaborate := True;
2050 elsif Nextc = 'A' then
2051 P := P + 1;
2052 Check_At_End_Of_Field;
2053 Withs.Table (Withs.Last).Elaborate_All := True;
2055 else
2056 Checkc ('D');
2057 Check_At_End_Of_Field;
2059 -- Store ED indication unless ignore required
2061 if not Ignore_ED then
2062 Withs.Table (Withs.Last).Elab_Desirable :=
2063 True;
2064 end if;
2065 end if;
2067 else
2068 Fatal_Error;
2069 end if;
2070 end loop;
2071 end if;
2073 Skip_Eol;
2074 end if;
2076 C := Getc;
2077 end loop With_Loop;
2079 Units.Table (Units.Last).Last_With := Withs.Last;
2080 Units.Table (Units.Last).Last_Arg := Args.Last;
2082 -- If there are linker options lines present, scan them
2084 Name_Len := 0;
2086 Linker_Options_Loop : loop
2087 Check_Unknown_Line;
2088 exit Linker_Options_Loop when C /= 'L';
2090 if Ignore ('L') then
2091 Skip_Line;
2093 else
2094 Checkc (' ');
2095 Skip_Space;
2096 Checkc ('"');
2098 loop
2099 C := Getc;
2101 if C < Character'Val (16#20#)
2102 or else C > Character'Val (16#7E#)
2103 then
2104 Fatal_Error_Ignore;
2106 elsif C = '{' then
2107 C := Character'Val (0);
2109 declare
2110 V : Natural;
2112 begin
2113 V := 0;
2114 for J in 1 .. 2 loop
2115 C := Getc;
2117 if C in '0' .. '9' then
2118 V := V * 16 +
2119 Character'Pos (C) -
2120 Character'Pos ('0');
2122 elsif C in 'A' .. 'F' then
2123 V := V * 16 +
2124 Character'Pos (C) -
2125 Character'Pos ('A') +
2128 else
2129 Fatal_Error_Ignore;
2130 end if;
2131 end loop;
2133 Checkc ('}');
2134 Add_Char_To_Name_Buffer (Character'Val (V));
2135 end;
2137 else
2138 if C = '"' then
2139 exit when Nextc /= '"';
2140 C := Getc;
2141 end if;
2143 Add_Char_To_Name_Buffer (C);
2144 end if;
2145 end loop;
2147 Add_Char_To_Name_Buffer (NUL);
2148 Skip_Eol;
2149 end if;
2151 C := Getc;
2152 end loop Linker_Options_Loop;
2154 -- Store the linker options entry if one was found
2156 if Name_Len /= 0 then
2157 Linker_Options.Increment_Last;
2159 Linker_Options.Table (Linker_Options.Last).Name :=
2160 Name_Enter;
2162 Linker_Options.Table (Linker_Options.Last).Unit :=
2163 Units.Last;
2165 Linker_Options.Table (Linker_Options.Last).Internal_File :=
2166 Is_Internal_File_Name (F);
2168 Linker_Options.Table (Linker_Options.Last).Original_Pos :=
2169 Linker_Options.Last;
2170 end if;
2172 -- If there are notes present, scan them
2174 Notes_Loop : loop
2175 Check_Unknown_Line;
2176 exit Notes_Loop when C /= 'N';
2178 if Ignore ('N') then
2179 Skip_Line;
2181 else
2182 Checkc (' ');
2184 Notes.Increment_Last;
2185 Notes.Table (Notes.Last).Pragma_Type := Getc;
2186 Notes.Table (Notes.Last).Pragma_Line := Get_Nat;
2187 Checkc (':');
2188 Notes.Table (Notes.Last).Pragma_Col := Get_Nat;
2190 if not At_Eol and then Nextc = ':' then
2191 Checkc (':');
2192 Notes.Table (Notes.Last).Pragma_Source_File :=
2193 Get_File_Name (Lower => True);
2194 else
2195 Notes.Table (Notes.Last).Pragma_Source_File :=
2196 Units.Table (Units.Last).Sfile;
2197 end if;
2199 if At_Eol then
2200 Notes.Table (Notes.Last).Pragma_Args := No_Name;
2202 else
2203 -- Note: can't use Get_Name here as the remainder of the
2204 -- line is unstructured text whose syntax depends on the
2205 -- particular pragma used.
2207 Checkc (' ');
2209 Name_Len := 0;
2210 while not At_Eol loop
2211 Add_Char_To_Name_Buffer (Getc);
2212 end loop;
2213 end if;
2215 Skip_Eol;
2216 end if;
2218 C := Getc;
2219 end loop Notes_Loop;
2220 end loop U_Loop;
2222 -- End loop through units for one ALI file
2224 ALIs.Table (Id).Last_Unit := Units.Last;
2225 ALIs.Table (Id).Sfile := Units.Table (ALIs.Table (Id).First_Unit).Sfile;
2227 -- Set types of the units (there can be at most 2 of them)
2229 if ALIs.Table (Id).First_Unit /= ALIs.Table (Id).Last_Unit then
2230 Units.Table (ALIs.Table (Id).First_Unit).Utype := Is_Body;
2231 Units.Table (ALIs.Table (Id).Last_Unit).Utype := Is_Spec;
2233 else
2234 -- Deal with body only and spec only cases, note that the reason we
2235 -- do our own checking of the name (rather than using Is_Body_Name)
2236 -- is that Uname drags in far too much compiler junk.
2238 Get_Name_String (Units.Table (Units.Last).Uname);
2240 if Name_Buffer (Name_Len) = 'b' then
2241 Units.Table (Units.Last).Utype := Is_Body_Only;
2242 else
2243 Units.Table (Units.Last).Utype := Is_Spec_Only;
2244 end if;
2245 end if;
2247 -- Scan out external version references and put in hash table
2249 E_Loop : loop
2250 Check_Unknown_Line;
2251 exit E_Loop when C /= 'E';
2253 if Ignore ('E') then
2254 Skip_Line;
2256 else
2257 Checkc (' ');
2258 Skip_Space;
2260 Name_Len := 0;
2261 Name_Len := 0;
2262 loop
2263 C := Getc;
2265 if C < ' ' then
2266 Fatal_Error;
2267 end if;
2269 exit when At_End_Of_Field;
2270 Add_Char_To_Name_Buffer (C);
2271 end loop;
2273 Version_Ref.Set (new String'(Name_Buffer (1 .. Name_Len)), True);
2274 Skip_Eol;
2275 end if;
2277 C := Getc;
2278 end loop E_Loop;
2280 -- Scan out source dependency lines for this ALI file
2282 ALIs.Table (Id).First_Sdep := Sdep.Last + 1;
2284 D_Loop : loop
2285 Check_Unknown_Line;
2286 exit D_Loop when C /= 'D';
2288 if Ignore ('D') then
2289 Skip_Line;
2291 else
2292 Checkc (' ');
2293 Skip_Space;
2294 Sdep.Increment_Last;
2296 -- In the following call, Lower is not set to True, this is either
2297 -- a bug, or it deserves a special comment as to why this is so???
2299 -- The file/path name may be quoted
2301 Sdep.Table (Sdep.Last).Sfile :=
2302 Get_File_Name (May_Be_Quoted => True);
2304 Sdep.Table (Sdep.Last).Stamp := Get_Stamp;
2305 Sdep.Table (Sdep.Last).Dummy_Entry :=
2306 (Sdep.Table (Sdep.Last).Stamp = Dummy_Time_Stamp);
2308 -- Acquire checksum value
2310 Skip_Space;
2312 declare
2313 Ctr : Natural;
2314 Chk : Word;
2316 begin
2317 Ctr := 0;
2318 Chk := 0;
2320 loop
2321 exit when At_Eol or else Ctr = 8;
2323 if Nextc in '0' .. '9' then
2324 Chk := Chk * 16 +
2325 Character'Pos (Nextc) - Character'Pos ('0');
2327 elsif Nextc in 'a' .. 'f' then
2328 Chk := Chk * 16 +
2329 Character'Pos (Nextc) - Character'Pos ('a') + 10;
2331 else
2332 exit;
2333 end if;
2335 Ctr := Ctr + 1;
2336 P := P + 1;
2337 end loop;
2339 if Ctr = 8 and then At_End_Of_Field then
2340 Sdep.Table (Sdep.Last).Checksum := Chk;
2341 else
2342 Fatal_Error;
2343 end if;
2344 end;
2346 -- Acquire (sub)unit and reference file name entries
2348 Sdep.Table (Sdep.Last).Subunit_Name := No_Name;
2349 Sdep.Table (Sdep.Last).Unit_Name := No_Name;
2350 Sdep.Table (Sdep.Last).Rfile :=
2351 Sdep.Table (Sdep.Last).Sfile;
2352 Sdep.Table (Sdep.Last).Start_Line := 1;
2354 if not At_Eol then
2355 Skip_Space;
2357 -- Here for (sub)unit name
2359 if Nextc not in '0' .. '9' then
2360 Name_Len := 0;
2361 while not At_End_Of_Field loop
2362 Add_Char_To_Name_Buffer (Getc);
2363 end loop;
2365 -- Set the (sub)unit name. Note that we use Name_Find rather
2366 -- than Name_Enter here as the subunit name may already
2367 -- have been put in the name table by the Project Manager.
2369 if Name_Len <= 2
2370 or else Name_Buffer (Name_Len - 1) /= '%'
2371 then
2372 Sdep.Table (Sdep.Last).Subunit_Name := Name_Find;
2373 else
2374 Name_Len := Name_Len - 2;
2375 Sdep.Table (Sdep.Last).Unit_Name := Name_Find;
2376 end if;
2378 Skip_Space;
2379 end if;
2381 -- Here for reference file name entry
2383 if Nextc in '0' .. '9' then
2384 Sdep.Table (Sdep.Last).Start_Line := Get_Nat;
2385 Checkc (':');
2387 Name_Len := 0;
2389 while not At_End_Of_Field loop
2390 Add_Char_To_Name_Buffer (Getc);
2391 end loop;
2393 Sdep.Table (Sdep.Last).Rfile := Name_Enter;
2394 end if;
2395 end if;
2397 Skip_Eol;
2398 end if;
2400 C := Getc;
2401 end loop D_Loop;
2403 ALIs.Table (Id).Last_Sdep := Sdep.Last;
2405 -- We must at this stage be at an Xref line or the end of file
2407 if C = EOF then
2408 return Id;
2409 end if;
2411 Check_Unknown_Line;
2413 if C /= 'X' then
2414 Fatal_Error;
2415 end if;
2417 -- If we are ignoring Xref sections we are done (we ignore all
2418 -- remaining lines since only xref related lines follow X).
2420 if Ignore ('X') and then not Debug_Flag_X then
2421 return Id;
2422 end if;
2424 -- Loop through Xref sections
2426 X_Loop : loop
2427 Check_Unknown_Line;
2428 exit X_Loop when C /= 'X';
2430 -- Make new entry in section table
2432 Xref_Section.Increment_Last;
2434 Read_Refs_For_One_File : declare
2435 XS : Xref_Section_Record renames
2436 Xref_Section.Table (Xref_Section.Last);
2438 Current_File_Num : Sdep_Id;
2439 -- Keeps track of the current file number (changed by nn|)
2441 begin
2442 XS.File_Num := Sdep_Id (Get_Nat + Nat (First_Sdep_Entry) - 1);
2443 XS.File_Name := Get_File_Name;
2444 XS.First_Entity := Xref_Entity.Last + 1;
2446 Current_File_Num := XS.File_Num;
2448 Skip_Space;
2450 Skip_Eol;
2451 C := Nextc;
2453 -- Loop through Xref entities
2455 while C /= 'X' and then C /= EOF loop
2456 Xref_Entity.Increment_Last;
2458 Read_Refs_For_One_Entity : declare
2459 XE : Xref_Entity_Record renames
2460 Xref_Entity.Table (Xref_Entity.Last);
2461 N : Nat;
2463 procedure Read_Instantiation_Reference;
2464 -- Acquire instantiation reference. Caller has checked
2465 -- that current character is '[' and on return the cursor
2466 -- is skipped past the corresponding closing ']'.
2468 ----------------------------------
2469 -- Read_Instantiation_Reference --
2470 ----------------------------------
2472 procedure Read_Instantiation_Reference is
2473 Local_File_Num : Sdep_Id := Current_File_Num;
2475 begin
2476 Xref.Increment_Last;
2478 declare
2479 XR : Xref_Record renames Xref.Table (Xref.Last);
2481 begin
2482 P := P + 1; -- skip [
2483 N := Get_Nat;
2485 if Nextc = '|' then
2486 XR.File_Num :=
2487 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2488 Local_File_Num := XR.File_Num;
2489 P := P + 1;
2490 N := Get_Nat;
2492 else
2493 XR.File_Num := Local_File_Num;
2494 end if;
2496 XR.Line := N;
2497 XR.Rtype := ' ';
2498 XR.Col := 0;
2500 -- Recursive call for next reference
2502 if Nextc = '[' then
2503 pragma Warnings (Off); -- kill recursion warning
2504 Read_Instantiation_Reference;
2505 pragma Warnings (On);
2506 end if;
2508 -- Skip closing bracket after recursive call
2510 P := P + 1;
2511 end;
2512 end Read_Instantiation_Reference;
2514 -- Start of processing for Read_Refs_For_One_Entity
2516 begin
2517 XE.Line := Get_Nat;
2518 XE.Etype := Getc;
2519 XE.Col := Get_Nat;
2521 case Getc is
2522 when '*' =>
2523 XE.Visibility := Global;
2524 when '+' =>
2525 XE.Visibility := Static;
2526 when others =>
2527 XE.Visibility := Other;
2528 end case;
2530 XE.Entity := Get_Name;
2532 -- Handle the information about generic instantiations
2534 if Nextc = '[' then
2535 Skipc; -- Opening '['
2536 N := Get_Nat;
2538 if Nextc /= '|' then
2539 XE.Iref_File_Num := Current_File_Num;
2540 XE.Iref_Line := N;
2541 else
2542 XE.Iref_File_Num :=
2543 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2544 Skipc;
2545 XE.Iref_Line := Get_Nat;
2546 end if;
2548 if Getc /= ']' then
2549 Fatal_Error;
2550 end if;
2552 else
2553 XE.Iref_File_Num := No_Sdep_Id;
2554 XE.Iref_Line := 0;
2555 end if;
2557 Current_File_Num := XS.File_Num;
2559 -- Renaming reference is present
2561 if Nextc = '=' then
2562 P := P + 1;
2563 XE.Rref_Line := Get_Nat;
2565 if Getc /= ':' then
2566 Fatal_Error;
2567 end if;
2569 XE.Rref_Col := Get_Nat;
2571 -- No renaming reference present
2573 else
2574 XE.Rref_Line := 0;
2575 XE.Rref_Col := 0;
2576 end if;
2578 Skip_Space;
2580 XE.Oref_File_Num := No_Sdep_Id;
2581 XE.Tref_File_Num := No_Sdep_Id;
2582 XE.Tref := Tref_None;
2583 XE.First_Xref := Xref.Last + 1;
2585 -- Loop to check for additional info present
2587 loop
2588 declare
2589 Ref : Tref_Kind;
2590 File : Sdep_Id;
2591 Line : Nat;
2592 Typ : Character;
2593 Col : Nat;
2594 Std : Name_Id;
2596 begin
2597 Get_Typeref
2598 (Current_File_Num, Ref, File, Line, Typ, Col, Std);
2599 exit when Ref = Tref_None;
2601 -- Do we have an overriding procedure?
2603 if Ref = Tref_Derived and then Typ = 'p' then
2604 XE.Oref_File_Num := File;
2605 XE.Oref_Line := Line;
2606 XE.Oref_Col := Col;
2608 -- Arrays never override anything, and <> points to
2609 -- the index types instead
2611 elsif Ref = Tref_Derived and then XE.Etype = 'A' then
2613 -- Index types are stored in the list of references
2615 Xref.Increment_Last;
2617 declare
2618 XR : Xref_Record renames Xref.Table (Xref.Last);
2619 begin
2620 XR.File_Num := File;
2621 XR.Line := Line;
2622 XR.Rtype := Array_Index_Reference;
2623 XR.Col := Col;
2624 XR.Name := Std;
2625 end;
2627 -- Interfaces are stored in the list of references,
2628 -- although the parent type itself is stored in XE.
2629 -- The first interface (when there are only
2630 -- interfaces) is stored in XE.Tref*)
2632 elsif Ref = Tref_Derived
2633 and then Typ = 'R'
2634 and then XE.Tref_File_Num /= No_Sdep_Id
2635 then
2636 Xref.Increment_Last;
2638 declare
2639 XR : Xref_Record renames Xref.Table (Xref.Last);
2640 begin
2641 XR.File_Num := File;
2642 XR.Line := Line;
2643 XR.Rtype := Interface_Reference;
2644 XR.Col := Col;
2645 XR.Name := Std;
2646 end;
2648 else
2649 XE.Tref := Ref;
2650 XE.Tref_File_Num := File;
2651 XE.Tref_Line := Line;
2652 XE.Tref_Type := Typ;
2653 XE.Tref_Col := Col;
2654 XE.Tref_Standard_Entity := Std;
2655 end if;
2656 end;
2657 end loop;
2659 -- Loop through cross-references for this entity
2661 loop
2662 Skip_Space;
2664 if At_Eol then
2665 Skip_Eol;
2666 exit when Nextc /= '.';
2667 P := P + 1;
2668 end if;
2670 Xref.Increment_Last;
2672 declare
2673 XR : Xref_Record renames Xref.Table (Xref.Last);
2675 begin
2676 N := Get_Nat;
2678 if Nextc = '|' then
2679 XR.File_Num :=
2680 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2681 Current_File_Num := XR.File_Num;
2682 P := P + 1;
2683 N := Get_Nat;
2684 else
2685 XR.File_Num := Current_File_Num;
2686 end if;
2688 XR.Line := N;
2689 XR.Rtype := Getc;
2691 -- Imported entities reference as in:
2692 -- 494b<c,__gnat_copy_attribs>25
2694 if Nextc = '<' then
2695 Skipc;
2696 XR.Imported_Lang := Get_Name;
2698 pragma Assert (Nextc = ',');
2699 Skipc;
2701 XR.Imported_Name := Get_Name;
2703 pragma Assert (Nextc = '>');
2704 Skipc;
2706 else
2707 XR.Imported_Lang := No_Name;
2708 XR.Imported_Name := No_Name;
2709 end if;
2711 XR.Col := Get_Nat;
2713 if Nextc = '[' then
2714 Read_Instantiation_Reference;
2715 end if;
2716 end;
2717 end loop;
2719 -- Record last cross-reference
2721 XE.Last_Xref := Xref.Last;
2722 C := Nextc;
2724 exception
2725 when Bad_ALI_Format =>
2727 -- If ignoring errors, then we skip a line with an
2728 -- unexpected error, and try to continue subsequent
2729 -- xref lines.
2731 if Ignore_Errors then
2732 Xref_Entity.Decrement_Last;
2733 Skip_Line;
2734 C := Nextc;
2736 -- Otherwise, we reraise the fatal exception
2738 else
2739 raise;
2740 end if;
2741 end Read_Refs_For_One_Entity;
2742 end loop;
2744 -- Record last entity
2746 XS.Last_Entity := Xref_Entity.Last;
2748 end Read_Refs_For_One_File;
2750 C := Getc;
2751 end loop X_Loop;
2753 -- Here after dealing with xref sections
2755 -- Ignore remaining lines, which belong to an additional section of the
2756 -- ALI file not considered here (like SCO or SPARK information).
2758 Check_Unknown_Line;
2760 return Id;
2762 exception
2763 when Bad_ALI_Format =>
2764 return No_ALI_Id;
2765 end Scan_ALI;
2767 ---------
2768 -- SEq --
2769 ---------
2771 function SEq (F1, F2 : String_Ptr) return Boolean is
2772 begin
2773 return F1.all = F2.all;
2774 end SEq;
2776 -----------
2777 -- SHash --
2778 -----------
2780 function SHash (S : String_Ptr) return Vindex is
2781 H : Word;
2783 begin
2784 H := 0;
2785 for J in S.all'Range loop
2786 H := H * 2 + Character'Pos (S (J));
2787 end loop;
2789 return Vindex (Vindex'First + Vindex (H mod Vindex'Range_Length));
2790 end SHash;
2792 end ALI;