PR middle-end/61455
[official-gcc.git] / gcc / ada / ali.adb
blob2fe955259268ab04c6d42ecf1ae7791c1132a535
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 Normalize_Scalars_Specified := False;
115 Partition_Elaboration_Policy_Specified := ' ';
116 Queuing_Policy_Specified := ' ';
117 SSO_Default_Specified := False;
118 Static_Elaboration_Model_Used := False;
119 Task_Dispatching_Policy_Specified := ' ';
120 Unreserve_All_Interrupts_Specified := False;
121 Zero_Cost_Exceptions_Specified := False;
122 end Initialize_ALI;
124 --------------
125 -- Scan_ALI --
126 --------------
128 function Scan_ALI
129 (F : File_Name_Type;
130 T : Text_Buffer_Ptr;
131 Ignore_ED : Boolean;
132 Err : Boolean;
133 Read_Xref : Boolean := False;
134 Read_Lines : String := "";
135 Ignore_Lines : String := "X";
136 Ignore_Errors : Boolean := False;
137 Directly_Scanned : Boolean := False) return ALI_Id
139 P : Text_Ptr := T'First;
140 Line : Logical_Line_Number := 1;
141 Id : ALI_Id;
142 C : Character;
143 NS_Found : Boolean;
144 First_Arg : Arg_Id;
146 Ignore : array (Character range 'A' .. 'Z') of Boolean;
147 -- Ignore (X) is set to True if lines starting with X are to
148 -- be ignored by Scan_ALI and skipped, and False if the lines
149 -- are to be read and processed.
151 Bad_ALI_Format : exception;
152 -- Exception raised by Fatal_Error if Err is True
154 function At_Eol return Boolean;
155 -- Test if at end of line
157 function At_End_Of_Field return Boolean;
158 -- Test if at end of line, or if at blank or horizontal tab
160 procedure Check_At_End_Of_Field;
161 -- Check if we are at end of field, fatal error if not
163 procedure Checkc (C : Character);
164 -- Check next character is C. If so bump past it, if not fatal error
166 procedure Check_Unknown_Line;
167 -- If Ignore_Errors mode, then checks C to make sure that it is not
168 -- an unknown ALI line type characters, and if so, skips lines
169 -- until the first character of the line is one of these characters,
170 -- at which point it does a Getc to put that character in C. The
171 -- call has no effect if C is already an appropriate character.
172 -- If not in Ignore_Errors mode, a fatal error is signalled if the
173 -- line is unknown. Note that if C is an EOL on entry, the line is
174 -- skipped (it is assumed that blank lines are never significant).
175 -- If C is EOF on entry, the call has no effect (it is assumed that
176 -- the caller will properly handle this case).
178 procedure Fatal_Error;
179 -- Generate fatal error message for badly formatted ALI file if
180 -- Err is false, or raise Bad_ALI_Format if Err is True.
182 procedure Fatal_Error_Ignore;
183 pragma Inline (Fatal_Error_Ignore);
184 -- In Ignore_Errors mode, has no effect, otherwise same as Fatal_Error
186 function Getc return Character;
187 -- Get next character, bumping P past the character obtained
189 function Get_File_Name
190 (Lower : Boolean := False;
191 May_Be_Quoted : Boolean := False) return File_Name_Type;
192 -- Skip blanks, then scan out a file name (name is left in Name_Buffer
193 -- with length in Name_Len, as well as returning a File_Name_Type value.
194 -- If May_Be_Quoted is True and the first non blank character is '"',
195 -- then remove starting and ending quotes and undoubled internal quotes.
196 -- If lower is false, the case is unchanged, if Lower is True then the
197 -- result is forced to all lower case for systems where file names are
198 -- not case sensitive. This ensures that gnatbind works correctly
199 -- regardless of the case of the file name on all systems. The scan
200 -- is terminated by a end of line, space or horizontal tab. Any other
201 -- special characters are included in the returned name.
203 function Get_Name
204 (Ignore_Spaces : Boolean := False;
205 Ignore_Special : Boolean := False;
206 May_Be_Quoted : Boolean := False) return Name_Id;
207 -- Skip blanks, then scan out a name (name is left in Name_Buffer with
208 -- length in Name_Len, as well as being returned in Name_Id form).
209 -- If Lower is set to True then the Name_Buffer will be converted to
210 -- all lower case, for systems where file names are not case sensitive.
211 -- This ensures that gnatbind works correctly regardless of the case
212 -- of the file name on all systems. The termination condition depends
213 -- on the settings of Ignore_Spaces and Ignore_Special:
215 -- If Ignore_Spaces is False (normal case), then scan is terminated
216 -- by the normal end of field condition (EOL, space, horizontal tab)
218 -- If Ignore_Special is False (normal case), the scan is terminated by
219 -- a typeref bracket or an equal sign except for the special case of
220 -- an operator name starting with a double quote which is terminated
221 -- by another double quote.
223 -- If May_Be_Quoted is True and the first non blank character is '"'
224 -- the name is 'unquoted'. In this case Ignore_Special is ignored and
225 -- assumed to be True.
227 -- It is an error to set both Ignore_Spaces and Ignore_Special to True.
228 -- This function handles wide characters properly.
230 function Get_Nat return Nat;
231 -- Skip blanks, then scan out an unsigned integer value in Nat range
232 -- raises ALI_Reading_Error if the encoutered type is not natural.
234 function Get_Stamp return Time_Stamp_Type;
235 -- Skip blanks, then scan out a time stamp
237 function Get_Unit_Name return Unit_Name_Type;
238 -- Skip blanks, then scan out a file name (name is left in Name_Buffer
239 -- with length in Name_Len, as well as returning a Unit_Name_Type value.
240 -- The case is unchanged and terminated by a normal end of field.
242 function Nextc return Character;
243 -- Return current character without modifying pointer P
245 procedure Get_Typeref
246 (Current_File_Num : Sdep_Id;
247 Ref : out Tref_Kind;
248 File_Num : out Sdep_Id;
249 Line : out Nat;
250 Ref_Type : out Character;
251 Col : out Nat;
252 Standard_Entity : out Name_Id);
253 -- Parse the definition of a typeref (<...>, {...} or (...))
255 procedure Skip_Eol;
256 -- Skip past spaces, then skip past end of line (fatal error if not
257 -- at end of line). Also skips past any following blank lines.
259 procedure Skip_Line;
260 -- Skip rest of current line and any following blank lines
262 procedure Skip_Space;
263 -- Skip past white space (blanks or horizontal tab)
265 procedure Skipc;
266 -- Skip past next character, does not affect value in C. This call
267 -- is like calling Getc and ignoring the returned result.
269 ---------------------
270 -- At_End_Of_Field --
271 ---------------------
273 function At_End_Of_Field return Boolean is
274 begin
275 return Nextc <= ' ';
276 end At_End_Of_Field;
278 ------------
279 -- At_Eol --
280 ------------
282 function At_Eol return Boolean is
283 begin
284 return Nextc = EOF or else Nextc = CR or else Nextc = LF;
285 end At_Eol;
287 ---------------------------
288 -- Check_At_End_Of_Field --
289 ---------------------------
291 procedure Check_At_End_Of_Field is
292 begin
293 if not At_End_Of_Field then
294 if Ignore_Errors then
295 while Nextc > ' ' loop
296 P := P + 1;
297 end loop;
298 else
299 Fatal_Error;
300 end if;
301 end if;
302 end Check_At_End_Of_Field;
304 ------------------------
305 -- Check_Unknown_Line --
306 ------------------------
308 procedure Check_Unknown_Line is
309 begin
310 while C not in 'A' .. 'Z'
311 or else not Known_ALI_Lines (C)
312 loop
313 if C = CR or else C = LF then
314 Skip_Line;
315 C := Nextc;
317 elsif C = EOF then
318 return;
320 elsif Ignore_Errors then
321 Skip_Line;
322 C := Getc;
324 else
325 Fatal_Error;
326 end if;
327 end loop;
328 end Check_Unknown_Line;
330 ------------
331 -- Checkc --
332 ------------
334 procedure Checkc (C : Character) is
335 begin
336 if Nextc = C then
337 P := P + 1;
338 elsif Ignore_Errors then
339 P := P + 1;
340 else
341 Fatal_Error;
342 end if;
343 end Checkc;
345 -----------------
346 -- Fatal_Error --
347 -----------------
349 procedure Fatal_Error is
350 Ptr1 : Text_Ptr;
351 Ptr2 : Text_Ptr;
352 Col : Int;
354 procedure Wchar (C : Character);
355 -- Write a single character, replacing horizontal tab by spaces
357 procedure Wchar (C : Character) is
358 begin
359 if C = HT then
360 loop
361 Wchar (' ');
362 exit when Col mod 8 = 0;
363 end loop;
365 else
366 Write_Char (C);
367 Col := Col + 1;
368 end if;
369 end Wchar;
371 -- Start of processing for Fatal_Error
373 begin
374 if Err then
375 raise Bad_ALI_Format;
376 end if;
378 Set_Standard_Error;
379 Write_Str ("fatal error: file ");
380 Write_Name (F);
381 Write_Str (" is incorrectly formatted");
382 Write_Eol;
384 Write_Str ("make sure you are using consistent versions " &
386 -- Split the following line so that it can easily be transformed for
387 -- e.g. JVM/.NET back-ends where the compiler has a different name.
389 "of gcc/gnatbind");
391 Write_Eol;
393 -- Find start of line
395 Ptr1 := P;
396 while Ptr1 > T'First
397 and then T (Ptr1 - 1) /= CR
398 and then T (Ptr1 - 1) /= LF
399 loop
400 Ptr1 := Ptr1 - 1;
401 end loop;
403 Write_Int (Int (Line));
404 Write_Str (". ");
406 if Line < 100 then
407 Write_Char (' ');
408 end if;
410 if Line < 10 then
411 Write_Char (' ');
412 end if;
414 Col := 0;
415 Ptr2 := Ptr1;
417 while Ptr2 < T'Last
418 and then T (Ptr2) /= CR
419 and then T (Ptr2) /= LF
420 loop
421 Wchar (T (Ptr2));
422 Ptr2 := Ptr2 + 1;
423 end loop;
425 Write_Eol;
427 Write_Str (" ");
428 Col := 0;
430 while Ptr1 < P loop
431 if T (Ptr1) = HT then
432 Wchar (HT);
433 else
434 Wchar (' ');
435 end if;
437 Ptr1 := Ptr1 + 1;
438 end loop;
440 Wchar ('|');
441 Write_Eol;
443 Exit_Program (E_Fatal);
444 end Fatal_Error;
446 ------------------------
447 -- Fatal_Error_Ignore --
448 ------------------------
450 procedure Fatal_Error_Ignore is
451 begin
452 if not Ignore_Errors then
453 Fatal_Error;
454 end if;
455 end Fatal_Error_Ignore;
457 -------------------
458 -- Get_File_Name --
459 -------------------
461 function Get_File_Name
462 (Lower : Boolean := False;
463 May_Be_Quoted : Boolean := False) return File_Name_Type
465 F : Name_Id;
467 begin
468 F := Get_Name (Ignore_Special => True,
469 May_Be_Quoted => May_Be_Quoted);
471 -- Convert file name to all lower case if file names are not case
472 -- sensitive. This ensures that we handle names in the canonical
473 -- lower case format, regardless of the actual case.
475 if Lower and not File_Names_Case_Sensitive then
476 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
477 return Name_Find;
478 else
479 return File_Name_Type (F);
480 end if;
481 end Get_File_Name;
483 --------------
484 -- Get_Name --
485 --------------
487 function Get_Name
488 (Ignore_Spaces : Boolean := False;
489 Ignore_Special : Boolean := False;
490 May_Be_Quoted : Boolean := False) return Name_Id
492 Char : Character;
494 begin
495 Name_Len := 0;
496 Skip_Space;
498 if At_Eol then
499 if Ignore_Errors then
500 return Error_Name;
501 else
502 Fatal_Error;
503 end if;
504 end if;
506 Char := Getc;
508 -- Deal with quoted characters
510 if May_Be_Quoted and then Char = '"' then
511 loop
512 if At_Eol then
513 if Ignore_Errors then
514 return Error_Name;
515 else
516 Fatal_Error;
517 end if;
518 end if;
520 Char := Getc;
522 if Char = '"' then
523 if At_Eol then
524 exit;
526 else
527 Char := Getc;
529 if Char /= '"' then
530 P := P - 1;
531 exit;
532 end if;
533 end if;
534 end if;
536 Add_Char_To_Name_Buffer (Char);
537 end loop;
539 -- Other than case of quoted character
541 else
542 P := P - 1;
543 loop
544 Add_Char_To_Name_Buffer (Getc);
546 exit when At_End_Of_Field and then not Ignore_Spaces;
548 if not Ignore_Special then
549 if Name_Buffer (1) = '"' then
550 exit when Name_Len > 1
551 and then Name_Buffer (Name_Len) = '"';
553 else
554 -- Terminate on parens or angle brackets or equal sign
556 exit when Nextc = '(' or else Nextc = ')'
557 or else Nextc = '{' or else Nextc = '}'
558 or else Nextc = '<' or else Nextc = '>'
559 or else Nextc = '=';
561 -- Terminate on comma
563 exit when Nextc = ',';
565 -- Terminate if left bracket not part of wide char
566 -- sequence Note that we only recognize brackets
567 -- notation so far ???
569 exit when Nextc = '[' and then T (P + 1) /= '"';
571 -- Terminate if right bracket not part of wide char
572 -- sequence.
574 exit when Nextc = ']' and then T (P - 1) /= '"';
575 end if;
576 end if;
577 end loop;
578 end if;
580 return Name_Find;
581 end Get_Name;
583 -------------------
584 -- Get_Unit_Name --
585 -------------------
587 function Get_Unit_Name return Unit_Name_Type is
588 begin
589 return Unit_Name_Type (Get_Name);
590 end Get_Unit_Name;
592 -------------
593 -- Get_Nat --
594 -------------
596 function Get_Nat return Nat is
597 V : Nat;
599 begin
600 Skip_Space;
602 -- Check if we are on a number. In the case of bad ALI files, this
603 -- may not be true.
605 if not (Nextc in '0' .. '9') then
606 Fatal_Error;
607 end if;
609 V := 0;
610 loop
611 V := V * 10 + (Character'Pos (Getc) - Character'Pos ('0'));
613 exit when At_End_Of_Field;
614 exit when Nextc < '0' or else Nextc > '9';
615 end loop;
617 return V;
618 end Get_Nat;
620 ---------------
621 -- Get_Stamp --
622 ---------------
624 function Get_Stamp return Time_Stamp_Type is
625 T : Time_Stamp_Type;
626 Start : Integer;
628 begin
629 Skip_Space;
631 if At_Eol then
632 if Ignore_Errors then
633 return Dummy_Time_Stamp;
634 else
635 Fatal_Error;
636 end if;
637 end if;
639 -- Following reads old style time stamp missing first two digits
641 if Nextc in '7' .. '9' then
642 T (1) := '1';
643 T (2) := '9';
644 Start := 3;
646 -- Normal case of full year in time stamp
648 else
649 Start := 1;
650 end if;
652 for J in Start .. T'Last loop
653 T (J) := Getc;
654 end loop;
656 return T;
657 end Get_Stamp;
659 -----------------
660 -- Get_Typeref --
661 -----------------
663 procedure Get_Typeref
664 (Current_File_Num : Sdep_Id;
665 Ref : out Tref_Kind;
666 File_Num : out Sdep_Id;
667 Line : out Nat;
668 Ref_Type : out Character;
669 Col : out Nat;
670 Standard_Entity : out Name_Id)
672 N : Nat;
673 begin
674 case Nextc is
675 when '<' => Ref := Tref_Derived;
676 when '(' => Ref := Tref_Access;
677 when '{' => Ref := Tref_Type;
678 when others => Ref := Tref_None;
679 end case;
681 -- Case of typeref field present
683 if Ref /= Tref_None then
684 P := P + 1; -- skip opening bracket
686 if Nextc in 'a' .. 'z' then
687 File_Num := No_Sdep_Id;
688 Line := 0;
689 Ref_Type := ' ';
690 Col := 0;
691 Standard_Entity := Get_Name (Ignore_Spaces => True);
692 else
693 N := Get_Nat;
695 if Nextc = '|' then
696 File_Num := Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
697 P := P + 1;
698 N := Get_Nat;
699 else
700 File_Num := Current_File_Num;
701 end if;
703 Line := N;
704 Ref_Type := Getc;
705 Col := Get_Nat;
706 Standard_Entity := No_Name;
707 end if;
709 -- ??? Temporary workaround for nested generics case:
710 -- 4i4 Directories{1|4I9[4|6[3|3]]}
711 -- See C918-002
713 declare
714 Nested_Brackets : Natural := 0;
716 begin
717 loop
718 case Nextc is
719 when '[' =>
720 Nested_Brackets := Nested_Brackets + 1;
721 when ']' =>
722 Nested_Brackets := Nested_Brackets - 1;
723 when others =>
724 if Nested_Brackets = 0 then
725 exit;
726 end if;
727 end case;
729 Skipc;
730 end loop;
731 end;
733 P := P + 1; -- skip closing bracket
734 Skip_Space;
736 -- No typeref entry present
738 else
739 File_Num := No_Sdep_Id;
740 Line := 0;
741 Ref_Type := ' ';
742 Col := 0;
743 Standard_Entity := No_Name;
744 end if;
745 end Get_Typeref;
747 ----------
748 -- Getc --
749 ----------
751 function Getc return Character is
752 begin
753 if P = T'Last then
754 return EOF;
755 else
756 P := P + 1;
757 return T (P - 1);
758 end if;
759 end Getc;
761 -----------
762 -- Nextc --
763 -----------
765 function Nextc return Character is
766 begin
767 return T (P);
768 end Nextc;
770 --------------
771 -- Skip_Eol --
772 --------------
774 procedure Skip_Eol is
775 begin
776 Skip_Space;
778 if not At_Eol then
779 if Ignore_Errors then
780 while not At_Eol loop
781 P := P + 1;
782 end loop;
783 else
784 Fatal_Error;
785 end if;
786 end if;
788 -- Loop to skip past blank lines (first time through skips this EOL)
790 while Nextc < ' ' and then Nextc /= EOF loop
791 if Nextc = LF then
792 Line := Line + 1;
793 end if;
795 P := P + 1;
796 end loop;
797 end Skip_Eol;
799 ---------------
800 -- Skip_Line --
801 ---------------
803 procedure Skip_Line is
804 begin
805 while not At_Eol loop
806 P := P + 1;
807 end loop;
809 Skip_Eol;
810 end Skip_Line;
812 ----------------
813 -- Skip_Space --
814 ----------------
816 procedure Skip_Space is
817 begin
818 while Nextc = ' ' or else Nextc = HT loop
819 P := P + 1;
820 end loop;
821 end Skip_Space;
823 -----------
824 -- Skipc --
825 -----------
827 procedure Skipc is
828 begin
829 if P /= T'Last then
830 P := P + 1;
831 end if;
832 end Skipc;
834 -- Start of processing for Scan_ALI
836 begin
837 First_Sdep_Entry := Sdep.Last + 1;
839 -- Acquire lines to be ignored
841 if Read_Xref then
842 Ignore :=
843 ('U' | 'W' | 'Y' | 'Z' | 'D' | 'X' => False, others => True);
845 -- Read_Lines parameter given
847 elsif Read_Lines /= "" then
848 Ignore := ('U' => False, others => True);
850 for J in Read_Lines'Range loop
851 Ignore (Read_Lines (J)) := False;
852 end loop;
854 -- Process Ignore_Lines parameter
856 else
857 Ignore := (others => False);
859 for J in Ignore_Lines'Range loop
860 pragma Assert (Ignore_Lines (J) /= 'U');
861 Ignore (Ignore_Lines (J)) := True;
862 end loop;
863 end if;
865 -- Setup ALI Table entry with appropriate defaults
867 ALIs.Increment_Last;
868 Id := ALIs.Last;
869 Set_Name_Table_Info (F, Int (Id));
871 ALIs.Table (Id) := (
872 Afile => F,
873 Compile_Errors => False,
874 First_Interrupt_State => Interrupt_States.Last + 1,
875 First_Sdep => No_Sdep_Id,
876 First_Specific_Dispatching => Specific_Dispatching.Last + 1,
877 First_Unit => No_Unit_Id,
878 Last_Interrupt_State => Interrupt_States.Last,
879 Last_Sdep => No_Sdep_Id,
880 Last_Specific_Dispatching => Specific_Dispatching.Last,
881 Last_Unit => No_Unit_Id,
882 Locking_Policy => ' ',
883 Main_Priority => -1,
884 Main_CPU => -1,
885 Main_Program => None,
886 No_Object => False,
887 Normalize_Scalars => False,
888 Ofile_Full_Name => Full_Object_File_Name,
889 Partition_Elaboration_Policy => ' ',
890 Queuing_Policy => ' ',
891 Restrictions => No_Restrictions,
892 SAL_Interface => False,
893 Sfile => No_File,
894 SSO_Default => ' ',
895 Task_Dispatching_Policy => ' ',
896 Time_Slice_Value => -1,
897 WC_Encoding => 'b',
898 Unit_Exception_Table => False,
899 Ver => (others => ' '),
900 Ver_Len => 0,
901 Zero_Cost_Exceptions => False);
903 -- Now we acquire the input lines from the ALI file. Note that the
904 -- convention in the following code is that as we enter each section,
905 -- C is set to contain the first character of the following line.
907 C := Getc;
908 Check_Unknown_Line;
910 -- Acquire library version
912 if C /= 'V' then
914 -- The V line missing really indicates trouble, most likely it
915 -- means we don't have an ALI file at all, so here we give a
916 -- fatal error even if we are in Ignore_Errors mode.
918 Fatal_Error;
920 elsif Ignore ('V') then
921 Skip_Line;
923 else
924 Checkc (' ');
925 Skip_Space;
926 Checkc ('"');
928 for J in 1 .. Ver_Len_Max loop
929 C := Getc;
930 exit when C = '"';
931 ALIs.Table (Id).Ver (J) := C;
932 ALIs.Table (Id).Ver_Len := J;
933 end loop;
935 Skip_Eol;
936 end if;
938 C := Getc;
939 Check_Unknown_Line;
941 -- Acquire main program line if present
943 if C = 'M' then
944 if Ignore ('M') then
945 Skip_Line;
947 else
948 Checkc (' ');
949 Skip_Space;
951 C := Getc;
953 if C = 'F' then
954 ALIs.Table (Id).Main_Program := Func;
955 elsif C = 'P' then
956 ALIs.Table (Id).Main_Program := Proc;
957 else
958 P := P - 1;
959 Fatal_Error;
960 end if;
962 Skip_Space;
964 if not At_Eol then
965 if Nextc < 'A' then
966 ALIs.Table (Id).Main_Priority := Get_Nat;
967 end if;
969 Skip_Space;
971 if Nextc = 'T' then
972 P := P + 1;
973 Checkc ('=');
974 ALIs.Table (Id).Time_Slice_Value := Get_Nat;
975 end if;
977 Skip_Space;
979 if Nextc = 'C' then
980 P := P + 1;
981 Checkc ('=');
982 ALIs.Table (Id).Main_CPU := Get_Nat;
983 end if;
985 Skip_Space;
987 Checkc ('W');
988 Checkc ('=');
989 ALIs.Table (Id).WC_Encoding := Getc;
990 end if;
992 Skip_Eol;
993 end if;
995 C := Getc;
996 end if;
998 -- Acquire argument lines
1000 First_Arg := Args.Last + 1;
1002 A_Loop : loop
1003 Check_Unknown_Line;
1004 exit A_Loop when C /= 'A';
1006 if Ignore ('A') then
1007 Skip_Line;
1009 else
1010 Checkc (' ');
1012 -- Scan out argument
1014 Name_Len := 0;
1015 while not At_Eol loop
1016 Add_Char_To_Name_Buffer (Getc);
1017 end loop;
1019 -- If -fstack-check, record that it occurred. Note that an
1020 -- additional string parameter can be specified, in the form of
1021 -- -fstack-check={no|generic|specific}. "no" means no checking,
1022 -- "generic" means force the use of old-style checking, and
1023 -- "specific" means use the best checking method.
1025 if Name_Len >= 13
1026 and then Name_Buffer (1 .. 13) = "-fstack-check"
1027 and then Name_Buffer (1 .. Name_Len) /= "-fstack-check=no"
1028 then
1029 Stack_Check_Switch_Set := True;
1030 end if;
1032 -- Store the argument
1034 Args.Increment_Last;
1035 Args.Table (Args.Last) := new String'(Name_Buffer (1 .. Name_Len));
1037 Skip_Eol;
1038 end if;
1040 C := Getc;
1041 end loop A_Loop;
1043 -- Acquire P line
1045 Check_Unknown_Line;
1047 while C /= 'P' loop
1048 if Ignore_Errors then
1049 if C = EOF then
1050 Fatal_Error;
1051 else
1052 Skip_Line;
1053 C := Nextc;
1054 end if;
1055 else
1056 Fatal_Error;
1057 end if;
1058 end loop;
1060 if Ignore ('P') then
1061 Skip_Line;
1063 -- Process P line
1065 else
1066 NS_Found := False;
1068 while not At_Eol loop
1069 Checkc (' ');
1070 Skip_Space;
1071 C := Getc;
1073 -- Processing for CE
1075 if C = 'C' then
1076 Checkc ('E');
1077 ALIs.Table (Id).Compile_Errors := True;
1079 -- Processing for DB
1081 elsif C = 'D' then
1082 Checkc ('B');
1083 Detect_Blocking := True;
1085 -- Processing for Ex
1087 elsif C = 'E' then
1088 Partition_Elaboration_Policy_Specified := Getc;
1089 ALIs.Table (Id).Partition_Elaboration_Policy :=
1090 Partition_Elaboration_Policy_Specified;
1092 -- Processing for Lx
1094 elsif C = 'L' then
1095 Locking_Policy_Specified := Getc;
1096 ALIs.Table (Id).Locking_Policy := Locking_Policy_Specified;
1098 -- Processing for flags starting with N
1100 elsif C = 'N' then
1101 C := Getc;
1103 -- Processing for NO
1105 if C = 'O' then
1106 ALIs.Table (Id).No_Object := True;
1107 No_Object_Specified := True;
1109 -- Processing for NR
1111 elsif C = 'R' then
1112 No_Run_Time_Mode := True;
1113 Configurable_Run_Time_Mode := True;
1115 -- Processing for NS
1117 elsif C = 'S' then
1118 ALIs.Table (Id).Normalize_Scalars := True;
1119 Normalize_Scalars_Specified := True;
1120 NS_Found := True;
1122 -- Invalid switch starting with N
1124 else
1125 Fatal_Error_Ignore;
1126 end if;
1128 -- Processing for OH/OL
1130 elsif C = 'O' then
1131 C := Getc;
1133 if C = 'L' or else C = 'H' then
1134 ALIs.Table (Id).SSO_Default := C;
1135 SSO_Default_Specified := True;
1137 else
1138 Fatal_Error_Ignore;
1139 end if;
1141 -- Processing for Qx
1143 elsif C = 'Q' then
1144 Queuing_Policy_Specified := Getc;
1145 ALIs.Table (Id).Queuing_Policy := Queuing_Policy_Specified;
1147 -- Processing for flags starting with S
1149 elsif C = 'S' then
1150 C := Getc;
1152 -- Processing for SL
1154 if C = 'L' then
1155 ALIs.Table (Id).SAL_Interface := True;
1157 -- Processing for SS
1159 elsif C = 'S' then
1160 Opt.Sec_Stack_Used := True;
1162 -- Invalid switch starting with S
1164 else
1165 Fatal_Error_Ignore;
1166 end if;
1168 -- Processing for Tx
1170 elsif C = 'T' then
1171 Task_Dispatching_Policy_Specified := Getc;
1172 ALIs.Table (Id).Task_Dispatching_Policy :=
1173 Task_Dispatching_Policy_Specified;
1175 -- Processing for switch starting with U
1177 elsif C = 'U' then
1178 C := Getc;
1180 -- Processing for UA
1182 if C = 'A' then
1183 Unreserve_All_Interrupts_Specified := True;
1185 -- Processing for UX
1187 elsif C = 'X' then
1188 ALIs.Table (Id).Unit_Exception_Table := True;
1190 -- Invalid switches starting with U
1192 else
1193 Fatal_Error_Ignore;
1194 end if;
1196 -- Processing for ZX
1198 elsif C = 'Z' then
1199 C := Getc;
1201 if C = 'X' then
1202 ALIs.Table (Id).Zero_Cost_Exceptions := True;
1203 Zero_Cost_Exceptions_Specified := True;
1204 else
1205 Fatal_Error_Ignore;
1206 end if;
1208 -- Invalid parameter
1210 else
1211 C := Getc;
1212 Fatal_Error_Ignore;
1213 end if;
1214 end loop;
1216 if not NS_Found then
1217 No_Normalize_Scalars_Specified := True;
1218 end if;
1220 Skip_Eol;
1221 end if;
1223 C := Getc;
1224 Check_Unknown_Line;
1226 -- Loop to skip to first restrictions line
1228 while C /= 'R' loop
1229 if Ignore_Errors then
1230 if C = EOF then
1231 Fatal_Error;
1232 else
1233 Skip_Line;
1234 C := Nextc;
1235 end if;
1236 else
1237 Fatal_Error;
1238 end if;
1239 end loop;
1241 -- Ignore all 'R' lines if that is required
1243 if Ignore ('R') then
1244 while C = 'R' loop
1245 Skip_Line;
1246 C := Getc;
1247 end loop;
1249 -- Here we process the restrictions lines (other than unit name cases)
1251 else
1252 Scan_Restrictions : declare
1253 Save_R : constant Restrictions_Info := Cumulative_Restrictions;
1254 -- Save cumulative restrictions in case we have a fatal error
1256 Bad_R_Line : exception;
1257 -- Signal bad restrictions line (raised on unexpected character)
1259 Typ : Character;
1260 R : Restriction_Id;
1261 N : Natural;
1263 begin
1264 -- Named restriction case
1266 if Nextc = 'N' then
1267 Skip_Line;
1268 C := Getc;
1270 -- Loop through RR and RV lines
1272 while C = 'R' and then Nextc /= ' ' loop
1273 Typ := Getc;
1274 Checkc (' ');
1276 -- Acquire restriction name
1278 Name_Len := 0;
1279 while not At_Eol and then Nextc /= '=' loop
1280 Name_Len := Name_Len + 1;
1281 Name_Buffer (Name_Len) := Getc;
1282 end loop;
1284 -- Now search list of restrictions to find match
1286 declare
1287 RN : String renames Name_Buffer (1 .. Name_Len);
1289 begin
1290 R := Restriction_Id'First;
1291 while R /= Not_A_Restriction_Id loop
1292 if Restriction_Id'Image (R) = RN then
1293 goto R_Found;
1294 end if;
1296 R := Restriction_Id'Succ (R);
1297 end loop;
1299 -- We don't recognize the restriction. This might be
1300 -- thought of as an error, and it really is, but we
1301 -- want to allow building with inconsistent versions
1302 -- of the binder and ali files (see comments at the
1303 -- start of package System.Rident), so we just ignore
1304 -- this situation.
1306 goto Done_With_Restriction_Line;
1307 end;
1309 <<R_Found>>
1311 case R is
1313 -- Boolean restriction case
1315 when All_Boolean_Restrictions =>
1316 case Typ is
1317 when 'V' =>
1318 ALIs.Table (Id).Restrictions.Violated (R) :=
1319 True;
1320 Cumulative_Restrictions.Violated (R) := True;
1322 when 'R' =>
1323 ALIs.Table (Id).Restrictions.Set (R) := True;
1324 Cumulative_Restrictions.Set (R) := True;
1326 when others =>
1327 raise Bad_R_Line;
1328 end case;
1330 -- Parameter restriction case
1332 when All_Parameter_Restrictions =>
1333 if At_Eol or else Nextc /= '=' then
1334 raise Bad_R_Line;
1335 else
1336 Skipc;
1337 end if;
1339 N := Natural (Get_Nat);
1341 case Typ is
1343 -- Restriction set
1345 when 'R' =>
1346 ALIs.Table (Id).Restrictions.Set (R) := True;
1347 ALIs.Table (Id).Restrictions.Value (R) := N;
1349 if Cumulative_Restrictions.Set (R) then
1350 Cumulative_Restrictions.Value (R) :=
1351 Integer'Min
1352 (Cumulative_Restrictions.Value (R), N);
1353 else
1354 Cumulative_Restrictions.Set (R) := True;
1355 Cumulative_Restrictions.Value (R) := N;
1356 end if;
1358 -- Restriction violated
1360 when 'V' =>
1361 ALIs.Table (Id).Restrictions.Violated (R) :=
1362 True;
1363 Cumulative_Restrictions.Violated (R) := True;
1364 ALIs.Table (Id).Restrictions.Count (R) := N;
1366 -- Checked Max_Parameter case
1368 if R in Checked_Max_Parameter_Restrictions then
1369 Cumulative_Restrictions.Count (R) :=
1370 Integer'Max
1371 (Cumulative_Restrictions.Count (R), N);
1373 -- Other checked parameter cases
1375 else
1376 declare
1377 pragma Unsuppress (Overflow_Check);
1379 begin
1380 Cumulative_Restrictions.Count (R) :=
1381 Cumulative_Restrictions.Count (R) + N;
1383 exception
1384 when Constraint_Error =>
1386 -- A constraint error comes from the
1387 -- addition. We reset to the maximum
1388 -- and indicate that the real value
1389 -- is now unknown.
1391 Cumulative_Restrictions.Value (R) :=
1392 Integer'Last;
1393 Cumulative_Restrictions.Unknown (R) :=
1394 True;
1395 end;
1396 end if;
1398 -- Deal with + case
1400 if Nextc = '+' then
1401 Skipc;
1402 ALIs.Table (Id).Restrictions.Unknown (R) :=
1403 True;
1404 Cumulative_Restrictions.Unknown (R) := True;
1405 end if;
1407 -- Other than 'R' or 'V'
1409 when others =>
1410 raise Bad_R_Line;
1411 end case;
1413 if not At_Eol then
1414 raise Bad_R_Line;
1415 end if;
1417 -- Bizarre error case NOT_A_RESTRICTION
1419 when Not_A_Restriction_Id =>
1420 raise Bad_R_Line;
1421 end case;
1423 if not At_Eol then
1424 raise Bad_R_Line;
1425 end if;
1427 <<Done_With_Restriction_Line>>
1428 Skip_Line;
1429 C := Getc;
1430 end loop;
1432 -- Positional restriction case
1434 else
1435 Checkc (' ');
1436 Skip_Space;
1438 -- Acquire information for boolean restrictions
1440 for R in All_Boolean_Restrictions loop
1441 C := Getc;
1443 case C is
1444 when 'v' =>
1445 ALIs.Table (Id).Restrictions.Violated (R) := True;
1446 Cumulative_Restrictions.Violated (R) := True;
1448 when 'r' =>
1449 ALIs.Table (Id).Restrictions.Set (R) := True;
1450 Cumulative_Restrictions.Set (R) := True;
1452 when 'n' =>
1453 null;
1455 when others =>
1456 raise Bad_R_Line;
1457 end case;
1458 end loop;
1460 -- Acquire information for parameter restrictions
1462 for RP in All_Parameter_Restrictions loop
1463 case Getc is
1464 when 'n' =>
1465 null;
1467 when 'r' =>
1468 ALIs.Table (Id).Restrictions.Set (RP) := True;
1470 declare
1471 N : constant Integer := Integer (Get_Nat);
1472 begin
1473 ALIs.Table (Id).Restrictions.Value (RP) := N;
1475 if Cumulative_Restrictions.Set (RP) then
1476 Cumulative_Restrictions.Value (RP) :=
1477 Integer'Min
1478 (Cumulative_Restrictions.Value (RP), N);
1479 else
1480 Cumulative_Restrictions.Set (RP) := True;
1481 Cumulative_Restrictions.Value (RP) := N;
1482 end if;
1483 end;
1485 when others =>
1486 raise Bad_R_Line;
1487 end case;
1489 -- Acquire restrictions violations information
1491 case Getc is
1493 when 'n' =>
1494 null;
1496 when 'v' =>
1497 ALIs.Table (Id).Restrictions.Violated (RP) := True;
1498 Cumulative_Restrictions.Violated (RP) := True;
1500 declare
1501 N : constant Integer := Integer (Get_Nat);
1503 begin
1504 ALIs.Table (Id).Restrictions.Count (RP) := N;
1506 if RP in Checked_Max_Parameter_Restrictions then
1507 Cumulative_Restrictions.Count (RP) :=
1508 Integer'Max
1509 (Cumulative_Restrictions.Count (RP), N);
1511 else
1512 declare
1513 pragma Unsuppress (Overflow_Check);
1515 begin
1516 Cumulative_Restrictions.Count (RP) :=
1517 Cumulative_Restrictions.Count (RP) + N;
1519 exception
1520 when Constraint_Error =>
1522 -- A constraint error comes from the add. We
1523 -- reset to the maximum and indicate that the
1524 -- real value is now unknown.
1526 Cumulative_Restrictions.Value (RP) :=
1527 Integer'Last;
1528 Cumulative_Restrictions.Unknown (RP) := True;
1529 end;
1530 end if;
1532 if Nextc = '+' then
1533 Skipc;
1534 ALIs.Table (Id).Restrictions.Unknown (RP) := True;
1535 Cumulative_Restrictions.Unknown (RP) := True;
1536 end if;
1537 end;
1539 when others =>
1540 raise Bad_R_Line;
1541 end case;
1542 end loop;
1544 if not At_Eol then
1545 raise Bad_R_Line;
1546 else
1547 Skip_Line;
1548 C := Getc;
1549 end if;
1550 end if;
1552 -- Here if error during scanning of restrictions line
1554 exception
1555 when Bad_R_Line =>
1557 -- In Ignore_Errors mode, undo any changes to restrictions
1558 -- from this unit, and continue on, skipping remaining R
1559 -- lines for this unit.
1561 if Ignore_Errors then
1562 Cumulative_Restrictions := Save_R;
1563 ALIs.Table (Id).Restrictions := No_Restrictions;
1565 loop
1566 Skip_Eol;
1567 C := Getc;
1568 exit when C /= 'R';
1569 end loop;
1571 -- In normal mode, this is a fatal error
1573 else
1574 Fatal_Error;
1575 end if;
1576 end Scan_Restrictions;
1577 end if;
1579 -- Acquire additional restrictions (No_Dependence) lines if present
1581 while C = 'R' loop
1582 if Ignore ('R') then
1583 Skip_Line;
1584 else
1585 Skip_Space;
1586 No_Deps.Append ((Id, Get_Name));
1587 Skip_Eol;
1588 end if;
1590 C := Getc;
1591 end loop;
1593 -- Acquire 'I' lines if present
1595 Check_Unknown_Line;
1597 while C = 'I' loop
1598 if Ignore ('I') then
1599 Skip_Line;
1601 else
1602 declare
1603 Int_Num : Nat;
1604 I_State : Character;
1605 Line_No : Nat;
1607 begin
1608 Int_Num := Get_Nat;
1609 Skip_Space;
1610 I_State := Getc;
1611 Line_No := Get_Nat;
1613 Interrupt_States.Append (
1614 (Interrupt_Id => Int_Num,
1615 Interrupt_State => I_State,
1616 IS_Pragma_Line => Line_No));
1618 ALIs.Table (Id).Last_Interrupt_State := Interrupt_States.Last;
1619 Skip_Eol;
1620 end;
1621 end if;
1623 C := Getc;
1624 end loop;
1626 -- Acquire 'S' lines if present
1628 Check_Unknown_Line;
1630 while C = 'S' loop
1631 if Ignore ('S') then
1632 Skip_Line;
1634 else
1635 declare
1636 Policy : Character;
1637 First_Prio : Nat;
1638 Last_Prio : Nat;
1639 Line_No : Nat;
1641 begin
1642 Checkc (' ');
1643 Skip_Space;
1645 Policy := Getc;
1646 Skip_Space;
1647 First_Prio := Get_Nat;
1648 Last_Prio := Get_Nat;
1649 Line_No := Get_Nat;
1651 Specific_Dispatching.Append (
1652 (Dispatching_Policy => Policy,
1653 First_Priority => First_Prio,
1654 Last_Priority => Last_Prio,
1655 PSD_Pragma_Line => Line_No));
1657 ALIs.Table (Id).Last_Specific_Dispatching :=
1658 Specific_Dispatching.Last;
1660 Skip_Eol;
1661 end;
1662 end if;
1664 C := Getc;
1665 end loop;
1667 -- Loop to acquire unit entries
1669 U_Loop : loop
1670 Check_Unknown_Line;
1671 exit U_Loop when C /= 'U';
1673 -- Note: as per spec, we never ignore U lines
1675 Checkc (' ');
1676 Skip_Space;
1677 Units.Increment_Last;
1679 if ALIs.Table (Id).First_Unit = No_Unit_Id then
1680 ALIs.Table (Id).First_Unit := Units.Last;
1681 end if;
1683 declare
1684 UL : Unit_Record renames Units.Table (Units.Last);
1686 begin
1687 UL.Uname := Get_Unit_Name;
1688 UL.Predefined := Is_Predefined_Unit;
1689 UL.Internal := Is_Internal_Unit;
1690 UL.My_ALI := Id;
1691 UL.Sfile := Get_File_Name (Lower => True);
1692 UL.Pure := False;
1693 UL.Preelab := False;
1694 UL.No_Elab := False;
1695 UL.Shared_Passive := False;
1696 UL.RCI := False;
1697 UL.Remote_Types := False;
1698 UL.Has_RACW := False;
1699 UL.Init_Scalars := False;
1700 UL.Is_Generic := False;
1701 UL.Icasing := Mixed_Case;
1702 UL.Kcasing := All_Lower_Case;
1703 UL.Dynamic_Elab := False;
1704 UL.Elaborate_Body := False;
1705 UL.Set_Elab_Entity := False;
1706 UL.Version := "00000000";
1707 UL.First_With := Withs.Last + 1;
1708 UL.First_Arg := First_Arg;
1709 UL.Elab_Position := 0;
1710 UL.SAL_Interface := ALIs.Table (Id).SAL_Interface;
1711 UL.Directly_Scanned := Directly_Scanned;
1712 UL.Body_Needed_For_SAL := False;
1713 UL.Elaborate_Body_Desirable := False;
1714 UL.Optimize_Alignment := 'O';
1715 UL.Has_Finalizer := False;
1717 if Debug_Flag_U then
1718 Write_Str (" ----> reading unit ");
1719 Write_Int (Int (Units.Last));
1720 Write_Str (" ");
1721 Write_Unit_Name (UL.Uname);
1722 Write_Str (" from file ");
1723 Write_Name (UL.Sfile);
1724 Write_Eol;
1725 end if;
1726 end;
1728 -- Check for duplicated unit in different files
1730 declare
1731 Info : constant Int := Get_Name_Table_Info
1732 (Units.Table (Units.Last).Uname);
1733 begin
1734 if Info /= 0
1735 and then Units.Table (Units.Last).Sfile /=
1736 Units.Table (Unit_Id (Info)).Sfile
1737 then
1738 -- If Err is set then ignore duplicate unit name. This is the
1739 -- case of a call from gnatmake, where the situation can arise
1740 -- from substitution of source files. In such situations, the
1741 -- processing in gnatmake will always result in any required
1742 -- recompilations in any case, and if we consider this to be
1743 -- an error we get strange cases (for example when a generic
1744 -- instantiation is replaced by a normal package) where we
1745 -- read the old ali file, decide to recompile, and then decide
1746 -- that the old and new ali files are incompatible.
1748 if Err then
1749 null;
1751 -- If Err is not set, then this is a fatal error. This is
1752 -- the case of being called from the binder, where we must
1753 -- definitely diagnose this as an error.
1755 else
1756 Set_Standard_Error;
1757 Write_Str ("error: duplicate unit name: ");
1758 Write_Eol;
1760 Write_Str ("error: unit """);
1761 Write_Unit_Name (Units.Table (Units.Last).Uname);
1762 Write_Str (""" found in file """);
1763 Write_Name_Decoded (Units.Table (Units.Last).Sfile);
1764 Write_Char ('"');
1765 Write_Eol;
1767 Write_Str ("error: unit """);
1768 Write_Unit_Name (Units.Table (Unit_Id (Info)).Uname);
1769 Write_Str (""" found in file """);
1770 Write_Name_Decoded (Units.Table (Unit_Id (Info)).Sfile);
1771 Write_Char ('"');
1772 Write_Eol;
1774 Exit_Program (E_Fatal);
1775 end if;
1776 end if;
1777 end;
1779 Set_Name_Table_Info
1780 (Units.Table (Units.Last).Uname, Int (Units.Last));
1782 -- Scan out possible version and other parameters
1784 loop
1785 Skip_Space;
1786 exit when At_Eol;
1787 C := Getc;
1789 -- Version field
1791 if C in '0' .. '9' or else C in 'a' .. 'f' then
1792 Units.Table (Units.Last).Version (1) := C;
1794 for J in 2 .. 8 loop
1795 C := Getc;
1796 Units.Table (Units.Last).Version (J) := C;
1797 end loop;
1799 -- BD/BN parameters
1801 elsif C = 'B' then
1802 C := Getc;
1804 if C = 'D' then
1805 Check_At_End_Of_Field;
1806 Units.Table (Units.Last).Elaborate_Body_Desirable := True;
1808 elsif C = 'N' then
1809 Check_At_End_Of_Field;
1810 Units.Table (Units.Last).Body_Needed_For_SAL := True;
1812 else
1813 Fatal_Error_Ignore;
1814 end if;
1816 -- DE parameter (Dynamic elaboration checks)
1818 elsif C = 'D' then
1819 C := Getc;
1821 if C = 'E' then
1822 Check_At_End_Of_Field;
1823 Units.Table (Units.Last).Dynamic_Elab := True;
1824 Dynamic_Elaboration_Checks_Specified := True;
1825 else
1826 Fatal_Error_Ignore;
1827 end if;
1829 -- EB/EE parameters
1831 elsif C = 'E' then
1832 C := Getc;
1834 if C = 'B' then
1835 Units.Table (Units.Last).Elaborate_Body := True;
1836 elsif C = 'E' then
1837 Units.Table (Units.Last).Set_Elab_Entity := True;
1838 else
1839 Fatal_Error_Ignore;
1840 end if;
1842 Check_At_End_Of_Field;
1844 -- GE parameter (generic)
1846 elsif C = 'G' then
1847 C := Getc;
1849 if C = 'E' then
1850 Check_At_End_Of_Field;
1851 Units.Table (Units.Last).Is_Generic := True;
1852 else
1853 Fatal_Error_Ignore;
1854 end if;
1856 -- IL/IS/IU parameters
1858 elsif C = 'I' then
1859 C := Getc;
1861 if C = 'L' then
1862 Units.Table (Units.Last).Icasing := All_Lower_Case;
1863 elsif C = 'S' then
1864 Units.Table (Units.Last).Init_Scalars := True;
1865 Initialize_Scalars_Used := True;
1866 elsif C = 'U' then
1867 Units.Table (Units.Last).Icasing := All_Upper_Case;
1868 else
1869 Fatal_Error_Ignore;
1870 end if;
1872 Check_At_End_Of_Field;
1874 -- KM/KU parameters
1876 elsif C = 'K' then
1877 C := Getc;
1879 if C = 'M' then
1880 Units.Table (Units.Last).Kcasing := Mixed_Case;
1881 elsif C = 'U' then
1882 Units.Table (Units.Last).Kcasing := All_Upper_Case;
1883 else
1884 Fatal_Error_Ignore;
1885 end if;
1887 Check_At_End_Of_Field;
1889 -- NE parameter
1891 elsif C = 'N' then
1892 C := Getc;
1894 if C = 'E' then
1895 Units.Table (Units.Last).No_Elab := True;
1896 Check_At_End_Of_Field;
1897 else
1898 Fatal_Error_Ignore;
1899 end if;
1901 -- PF/PR/PU/PK parameters
1903 elsif C = 'P' then
1904 C := Getc;
1906 if C = 'F' then
1907 Units.Table (Units.Last).Has_Finalizer := True;
1908 elsif C = 'R' then
1909 Units.Table (Units.Last).Preelab := True;
1910 elsif C = 'U' then
1911 Units.Table (Units.Last).Pure := True;
1912 elsif C = 'K' then
1913 Units.Table (Units.Last).Unit_Kind := 'p';
1914 else
1915 Fatal_Error_Ignore;
1916 end if;
1918 Check_At_End_Of_Field;
1920 -- OL/OO/OS/OT parameters
1922 elsif C = 'O' then
1923 C := Getc;
1925 if C = 'L' or else C = 'O' or else C = 'S' or else C = 'T' then
1926 Units.Table (Units.Last).Optimize_Alignment := C;
1927 else
1928 Fatal_Error_Ignore;
1929 end if;
1931 Check_At_End_Of_Field;
1933 -- RC/RT parameters
1935 elsif C = 'R' then
1936 C := Getc;
1938 if C = 'C' then
1939 Units.Table (Units.Last).RCI := True;
1940 elsif C = 'T' then
1941 Units.Table (Units.Last).Remote_Types := True;
1942 elsif C = 'A' then
1943 Units.Table (Units.Last).Has_RACW := True;
1944 else
1945 Fatal_Error_Ignore;
1946 end if;
1948 Check_At_End_Of_Field;
1950 elsif C = 'S' then
1951 C := Getc;
1953 if C = 'P' then
1954 Units.Table (Units.Last).Shared_Passive := True;
1955 elsif C = 'U' then
1956 Units.Table (Units.Last).Unit_Kind := 's';
1957 else
1958 Fatal_Error_Ignore;
1959 end if;
1961 Check_At_End_Of_Field;
1963 else
1964 C := Getc;
1965 Fatal_Error_Ignore;
1966 end if;
1967 end loop;
1969 Skip_Eol;
1971 -- Check if static elaboration model used
1973 if not Units.Table (Units.Last).Dynamic_Elab
1974 and then not Units.Table (Units.Last).Internal
1975 then
1976 Static_Elaboration_Model_Used := True;
1977 end if;
1979 C := Getc;
1981 -- Scan out With lines for this unit
1983 With_Loop : loop
1984 Check_Unknown_Line;
1985 exit With_Loop when C /= 'W' and then C /= 'Y' and then C /= 'Z';
1987 if Ignore ('W') then
1988 Skip_Line;
1990 else
1991 Checkc (' ');
1992 Skip_Space;
1993 Withs.Increment_Last;
1994 Withs.Table (Withs.Last).Uname := Get_Unit_Name;
1995 Withs.Table (Withs.Last).Elaborate := False;
1996 Withs.Table (Withs.Last).Elaborate_All := False;
1997 Withs.Table (Withs.Last).Elab_Desirable := False;
1998 Withs.Table (Withs.Last).Elab_All_Desirable := False;
1999 Withs.Table (Withs.Last).SAL_Interface := False;
2000 Withs.Table (Withs.Last).Limited_With := (C = 'Y');
2001 Withs.Table (Withs.Last).Implicit_With_From_Instantiation
2002 := (C = 'Z');
2004 -- Generic case with no object file available
2006 if At_Eol then
2007 Withs.Table (Withs.Last).Sfile := No_File;
2008 Withs.Table (Withs.Last).Afile := No_File;
2010 -- Normal case
2012 else
2013 Withs.Table (Withs.Last).Sfile := Get_File_Name
2014 (Lower => True);
2015 Withs.Table (Withs.Last).Afile := Get_File_Name
2016 (Lower => True);
2018 -- Scan out possible E, EA, ED, and AD parameters
2020 while not At_Eol loop
2021 Skip_Space;
2023 if Nextc = 'A' then
2024 P := P + 1;
2025 Checkc ('D');
2026 Check_At_End_Of_Field;
2028 -- Store AD indication unless ignore required
2030 if not Ignore_ED then
2031 Withs.Table (Withs.Last).Elab_All_Desirable :=
2032 True;
2033 end if;
2035 elsif Nextc = 'E' then
2036 P := P + 1;
2038 if At_End_Of_Field then
2039 Withs.Table (Withs.Last).Elaborate := True;
2041 elsif Nextc = 'A' then
2042 P := P + 1;
2043 Check_At_End_Of_Field;
2044 Withs.Table (Withs.Last).Elaborate_All := True;
2046 else
2047 Checkc ('D');
2048 Check_At_End_Of_Field;
2050 -- Store ED indication unless ignore required
2052 if not Ignore_ED then
2053 Withs.Table (Withs.Last).Elab_Desirable :=
2054 True;
2055 end if;
2056 end if;
2058 else
2059 Fatal_Error;
2060 end if;
2061 end loop;
2062 end if;
2064 Skip_Eol;
2065 end if;
2067 C := Getc;
2068 end loop With_Loop;
2070 Units.Table (Units.Last).Last_With := Withs.Last;
2071 Units.Table (Units.Last).Last_Arg := Args.Last;
2073 -- If there are linker options lines present, scan them
2075 Name_Len := 0;
2077 Linker_Options_Loop : loop
2078 Check_Unknown_Line;
2079 exit Linker_Options_Loop when C /= 'L';
2081 if Ignore ('L') then
2082 Skip_Line;
2084 else
2085 Checkc (' ');
2086 Skip_Space;
2087 Checkc ('"');
2089 loop
2090 C := Getc;
2092 if C < Character'Val (16#20#)
2093 or else C > Character'Val (16#7E#)
2094 then
2095 Fatal_Error_Ignore;
2097 elsif C = '{' then
2098 C := Character'Val (0);
2100 declare
2101 V : Natural;
2103 begin
2104 V := 0;
2105 for J in 1 .. 2 loop
2106 C := Getc;
2108 if C in '0' .. '9' then
2109 V := V * 16 +
2110 Character'Pos (C) -
2111 Character'Pos ('0');
2113 elsif C in 'A' .. 'F' then
2114 V := V * 16 +
2115 Character'Pos (C) -
2116 Character'Pos ('A') +
2119 else
2120 Fatal_Error_Ignore;
2121 end if;
2122 end loop;
2124 Checkc ('}');
2125 Add_Char_To_Name_Buffer (Character'Val (V));
2126 end;
2128 else
2129 if C = '"' then
2130 exit when Nextc /= '"';
2131 C := Getc;
2132 end if;
2134 Add_Char_To_Name_Buffer (C);
2135 end if;
2136 end loop;
2138 Add_Char_To_Name_Buffer (NUL);
2139 Skip_Eol;
2140 end if;
2142 C := Getc;
2143 end loop Linker_Options_Loop;
2145 -- Store the linker options entry if one was found
2147 if Name_Len /= 0 then
2148 Linker_Options.Increment_Last;
2150 Linker_Options.Table (Linker_Options.Last).Name :=
2151 Name_Enter;
2153 Linker_Options.Table (Linker_Options.Last).Unit :=
2154 Units.Last;
2156 Linker_Options.Table (Linker_Options.Last).Internal_File :=
2157 Is_Internal_File_Name (F);
2159 Linker_Options.Table (Linker_Options.Last).Original_Pos :=
2160 Linker_Options.Last;
2161 end if;
2163 -- If there are notes present, scan them
2165 Notes_Loop : loop
2166 Check_Unknown_Line;
2167 exit Notes_Loop when C /= 'N';
2169 if Ignore ('N') then
2170 Skip_Line;
2172 else
2173 Checkc (' ');
2175 Notes.Increment_Last;
2176 Notes.Table (Notes.Last).Pragma_Type := Getc;
2177 Notes.Table (Notes.Last).Pragma_Line := Get_Nat;
2178 Checkc (':');
2179 Notes.Table (Notes.Last).Pragma_Col := Get_Nat;
2181 if not At_Eol and then Nextc = ':' then
2182 Checkc (':');
2183 Notes.Table (Notes.Last).Pragma_Source_File :=
2184 Get_File_Name (Lower => True);
2185 else
2186 Notes.Table (Notes.Last).Pragma_Source_File :=
2187 Units.Table (Units.Last).Sfile;
2188 end if;
2190 if At_Eol then
2191 Notes.Table (Notes.Last).Pragma_Args := No_Name;
2193 else
2194 -- Note: can't use Get_Name here as the remainder of the
2195 -- line is unstructured text whose syntax depends on the
2196 -- particular pragma used.
2198 Checkc (' ');
2200 Name_Len := 0;
2201 while not At_Eol loop
2202 Add_Char_To_Name_Buffer (Getc);
2203 end loop;
2204 end if;
2206 Skip_Eol;
2207 end if;
2209 C := Getc;
2210 end loop Notes_Loop;
2211 end loop U_Loop;
2213 -- End loop through units for one ALI file
2215 ALIs.Table (Id).Last_Unit := Units.Last;
2216 ALIs.Table (Id).Sfile := Units.Table (ALIs.Table (Id).First_Unit).Sfile;
2218 -- Set types of the units (there can be at most 2 of them)
2220 if ALIs.Table (Id).First_Unit /= ALIs.Table (Id).Last_Unit then
2221 Units.Table (ALIs.Table (Id).First_Unit).Utype := Is_Body;
2222 Units.Table (ALIs.Table (Id).Last_Unit).Utype := Is_Spec;
2224 else
2225 -- Deal with body only and spec only cases, note that the reason we
2226 -- do our own checking of the name (rather than using Is_Body_Name)
2227 -- is that Uname drags in far too much compiler junk.
2229 Get_Name_String (Units.Table (Units.Last).Uname);
2231 if Name_Buffer (Name_Len) = 'b' then
2232 Units.Table (Units.Last).Utype := Is_Body_Only;
2233 else
2234 Units.Table (Units.Last).Utype := Is_Spec_Only;
2235 end if;
2236 end if;
2238 -- Scan out external version references and put in hash table
2240 E_Loop : loop
2241 Check_Unknown_Line;
2242 exit E_Loop when C /= 'E';
2244 if Ignore ('E') then
2245 Skip_Line;
2247 else
2248 Checkc (' ');
2249 Skip_Space;
2251 Name_Len := 0;
2252 Name_Len := 0;
2253 loop
2254 C := Getc;
2256 if C < ' ' then
2257 Fatal_Error;
2258 end if;
2260 exit when At_End_Of_Field;
2261 Add_Char_To_Name_Buffer (C);
2262 end loop;
2264 Version_Ref.Set (new String'(Name_Buffer (1 .. Name_Len)), True);
2265 Skip_Eol;
2266 end if;
2268 C := Getc;
2269 end loop E_Loop;
2271 -- Scan out source dependency lines for this ALI file
2273 ALIs.Table (Id).First_Sdep := Sdep.Last + 1;
2275 D_Loop : loop
2276 Check_Unknown_Line;
2277 exit D_Loop when C /= 'D';
2279 if Ignore ('D') then
2280 Skip_Line;
2282 else
2283 Checkc (' ');
2284 Skip_Space;
2285 Sdep.Increment_Last;
2287 -- In the following call, Lower is not set to True, this is either
2288 -- a bug, or it deserves a special comment as to why this is so???
2290 -- The file/path name may be quoted
2292 Sdep.Table (Sdep.Last).Sfile :=
2293 Get_File_Name (May_Be_Quoted => True);
2295 Sdep.Table (Sdep.Last).Stamp := Get_Stamp;
2296 Sdep.Table (Sdep.Last).Dummy_Entry :=
2297 (Sdep.Table (Sdep.Last).Stamp = Dummy_Time_Stamp);
2299 -- Acquire checksum value
2301 Skip_Space;
2303 declare
2304 Ctr : Natural;
2305 Chk : Word;
2307 begin
2308 Ctr := 0;
2309 Chk := 0;
2311 loop
2312 exit when At_Eol or else Ctr = 8;
2314 if Nextc in '0' .. '9' then
2315 Chk := Chk * 16 +
2316 Character'Pos (Nextc) - Character'Pos ('0');
2318 elsif Nextc in 'a' .. 'f' then
2319 Chk := Chk * 16 +
2320 Character'Pos (Nextc) - Character'Pos ('a') + 10;
2322 else
2323 exit;
2324 end if;
2326 Ctr := Ctr + 1;
2327 P := P + 1;
2328 end loop;
2330 if Ctr = 8 and then At_End_Of_Field then
2331 Sdep.Table (Sdep.Last).Checksum := Chk;
2332 else
2333 Fatal_Error;
2334 end if;
2335 end;
2337 -- Acquire (sub)unit and reference file name entries
2339 Sdep.Table (Sdep.Last).Subunit_Name := No_Name;
2340 Sdep.Table (Sdep.Last).Unit_Name := No_Name;
2341 Sdep.Table (Sdep.Last).Rfile :=
2342 Sdep.Table (Sdep.Last).Sfile;
2343 Sdep.Table (Sdep.Last).Start_Line := 1;
2345 if not At_Eol then
2346 Skip_Space;
2348 -- Here for (sub)unit name
2350 if Nextc not in '0' .. '9' then
2351 Name_Len := 0;
2352 while not At_End_Of_Field loop
2353 Add_Char_To_Name_Buffer (Getc);
2354 end loop;
2356 -- Set the (sub)unit name. Note that we use Name_Find rather
2357 -- than Name_Enter here as the subunit name may already
2358 -- have been put in the name table by the Project Manager.
2360 if Name_Len <= 2
2361 or else Name_Buffer (Name_Len - 1) /= '%'
2362 then
2363 Sdep.Table (Sdep.Last).Subunit_Name := Name_Find;
2364 else
2365 Name_Len := Name_Len - 2;
2366 Sdep.Table (Sdep.Last).Unit_Name := Name_Find;
2367 end if;
2369 Skip_Space;
2370 end if;
2372 -- Here for reference file name entry
2374 if Nextc in '0' .. '9' then
2375 Sdep.Table (Sdep.Last).Start_Line := Get_Nat;
2376 Checkc (':');
2378 Name_Len := 0;
2380 while not At_End_Of_Field loop
2381 Add_Char_To_Name_Buffer (Getc);
2382 end loop;
2384 Sdep.Table (Sdep.Last).Rfile := Name_Enter;
2385 end if;
2386 end if;
2388 Skip_Eol;
2389 end if;
2391 C := Getc;
2392 end loop D_Loop;
2394 ALIs.Table (Id).Last_Sdep := Sdep.Last;
2396 -- We must at this stage be at an Xref line or the end of file
2398 if C = EOF then
2399 return Id;
2400 end if;
2402 Check_Unknown_Line;
2404 if C /= 'X' then
2405 Fatal_Error;
2406 end if;
2408 -- If we are ignoring Xref sections we are done (we ignore all
2409 -- remaining lines since only xref related lines follow X).
2411 if Ignore ('X') and then not Debug_Flag_X then
2412 return Id;
2413 end if;
2415 -- Loop through Xref sections
2417 X_Loop : loop
2418 Check_Unknown_Line;
2419 exit X_Loop when C /= 'X';
2421 -- Make new entry in section table
2423 Xref_Section.Increment_Last;
2425 Read_Refs_For_One_File : declare
2426 XS : Xref_Section_Record renames
2427 Xref_Section.Table (Xref_Section.Last);
2429 Current_File_Num : Sdep_Id;
2430 -- Keeps track of the current file number (changed by nn|)
2432 begin
2433 XS.File_Num := Sdep_Id (Get_Nat + Nat (First_Sdep_Entry) - 1);
2434 XS.File_Name := Get_File_Name;
2435 XS.First_Entity := Xref_Entity.Last + 1;
2437 Current_File_Num := XS.File_Num;
2439 Skip_Space;
2441 Skip_Eol;
2442 C := Nextc;
2444 -- Loop through Xref entities
2446 while C /= 'X' and then C /= EOF loop
2447 Xref_Entity.Increment_Last;
2449 Read_Refs_For_One_Entity : declare
2450 XE : Xref_Entity_Record renames
2451 Xref_Entity.Table (Xref_Entity.Last);
2452 N : Nat;
2454 procedure Read_Instantiation_Reference;
2455 -- Acquire instantiation reference. Caller has checked
2456 -- that current character is '[' and on return the cursor
2457 -- is skipped past the corresponding closing ']'.
2459 ----------------------------------
2460 -- Read_Instantiation_Reference --
2461 ----------------------------------
2463 procedure Read_Instantiation_Reference is
2464 Local_File_Num : Sdep_Id := Current_File_Num;
2466 begin
2467 Xref.Increment_Last;
2469 declare
2470 XR : Xref_Record renames Xref.Table (Xref.Last);
2472 begin
2473 P := P + 1; -- skip [
2474 N := Get_Nat;
2476 if Nextc = '|' then
2477 XR.File_Num :=
2478 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2479 Local_File_Num := XR.File_Num;
2480 P := P + 1;
2481 N := Get_Nat;
2483 else
2484 XR.File_Num := Local_File_Num;
2485 end if;
2487 XR.Line := N;
2488 XR.Rtype := ' ';
2489 XR.Col := 0;
2491 -- Recursive call for next reference
2493 if Nextc = '[' then
2494 pragma Warnings (Off); -- kill recursion warning
2495 Read_Instantiation_Reference;
2496 pragma Warnings (On);
2497 end if;
2499 -- Skip closing bracket after recursive call
2501 P := P + 1;
2502 end;
2503 end Read_Instantiation_Reference;
2505 -- Start of processing for Read_Refs_For_One_Entity
2507 begin
2508 XE.Line := Get_Nat;
2509 XE.Etype := Getc;
2510 XE.Col := Get_Nat;
2512 case Getc is
2513 when '*' =>
2514 XE.Visibility := Global;
2515 when '+' =>
2516 XE.Visibility := Static;
2517 when others =>
2518 XE.Visibility := Other;
2519 end case;
2521 XE.Entity := Get_Name;
2523 -- Handle the information about generic instantiations
2525 if Nextc = '[' then
2526 Skipc; -- Opening '['
2527 N := Get_Nat;
2529 if Nextc /= '|' then
2530 XE.Iref_File_Num := Current_File_Num;
2531 XE.Iref_Line := N;
2532 else
2533 XE.Iref_File_Num :=
2534 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2535 Skipc;
2536 XE.Iref_Line := Get_Nat;
2537 end if;
2539 if Getc /= ']' then
2540 Fatal_Error;
2541 end if;
2543 else
2544 XE.Iref_File_Num := No_Sdep_Id;
2545 XE.Iref_Line := 0;
2546 end if;
2548 Current_File_Num := XS.File_Num;
2550 -- Renaming reference is present
2552 if Nextc = '=' then
2553 P := P + 1;
2554 XE.Rref_Line := Get_Nat;
2556 if Getc /= ':' then
2557 Fatal_Error;
2558 end if;
2560 XE.Rref_Col := Get_Nat;
2562 -- No renaming reference present
2564 else
2565 XE.Rref_Line := 0;
2566 XE.Rref_Col := 0;
2567 end if;
2569 Skip_Space;
2571 XE.Oref_File_Num := No_Sdep_Id;
2572 XE.Tref_File_Num := No_Sdep_Id;
2573 XE.Tref := Tref_None;
2574 XE.First_Xref := Xref.Last + 1;
2576 -- Loop to check for additional info present
2578 loop
2579 declare
2580 Ref : Tref_Kind;
2581 File : Sdep_Id;
2582 Line : Nat;
2583 Typ : Character;
2584 Col : Nat;
2585 Std : Name_Id;
2587 begin
2588 Get_Typeref
2589 (Current_File_Num, Ref, File, Line, Typ, Col, Std);
2590 exit when Ref = Tref_None;
2592 -- Do we have an overriding procedure?
2594 if Ref = Tref_Derived and then Typ = 'p' then
2595 XE.Oref_File_Num := File;
2596 XE.Oref_Line := Line;
2597 XE.Oref_Col := Col;
2599 -- Arrays never override anything, and <> points to
2600 -- the index types instead
2602 elsif Ref = Tref_Derived and then XE.Etype = 'A' then
2604 -- Index types are stored in the list of references
2606 Xref.Increment_Last;
2608 declare
2609 XR : Xref_Record renames Xref.Table (Xref.Last);
2610 begin
2611 XR.File_Num := File;
2612 XR.Line := Line;
2613 XR.Rtype := Array_Index_Reference;
2614 XR.Col := Col;
2615 XR.Name := Std;
2616 end;
2618 -- Interfaces are stored in the list of references,
2619 -- although the parent type itself is stored in XE.
2620 -- The first interface (when there are only
2621 -- interfaces) is stored in XE.Tref*)
2623 elsif Ref = Tref_Derived
2624 and then Typ = 'R'
2625 and then XE.Tref_File_Num /= No_Sdep_Id
2626 then
2627 Xref.Increment_Last;
2629 declare
2630 XR : Xref_Record renames Xref.Table (Xref.Last);
2631 begin
2632 XR.File_Num := File;
2633 XR.Line := Line;
2634 XR.Rtype := Interface_Reference;
2635 XR.Col := Col;
2636 XR.Name := Std;
2637 end;
2639 else
2640 XE.Tref := Ref;
2641 XE.Tref_File_Num := File;
2642 XE.Tref_Line := Line;
2643 XE.Tref_Type := Typ;
2644 XE.Tref_Col := Col;
2645 XE.Tref_Standard_Entity := Std;
2646 end if;
2647 end;
2648 end loop;
2650 -- Loop through cross-references for this entity
2652 loop
2653 Skip_Space;
2655 if At_Eol then
2656 Skip_Eol;
2657 exit when Nextc /= '.';
2658 P := P + 1;
2659 end if;
2661 Xref.Increment_Last;
2663 declare
2664 XR : Xref_Record renames Xref.Table (Xref.Last);
2666 begin
2667 N := Get_Nat;
2669 if Nextc = '|' then
2670 XR.File_Num :=
2671 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2672 Current_File_Num := XR.File_Num;
2673 P := P + 1;
2674 N := Get_Nat;
2675 else
2676 XR.File_Num := Current_File_Num;
2677 end if;
2679 XR.Line := N;
2680 XR.Rtype := Getc;
2682 -- Imported entities reference as in:
2683 -- 494b<c,__gnat_copy_attribs>25
2685 if Nextc = '<' then
2686 Skipc;
2687 XR.Imported_Lang := Get_Name;
2689 pragma Assert (Nextc = ',');
2690 Skipc;
2692 XR.Imported_Name := Get_Name;
2694 pragma Assert (Nextc = '>');
2695 Skipc;
2697 else
2698 XR.Imported_Lang := No_Name;
2699 XR.Imported_Name := No_Name;
2700 end if;
2702 XR.Col := Get_Nat;
2704 if Nextc = '[' then
2705 Read_Instantiation_Reference;
2706 end if;
2707 end;
2708 end loop;
2710 -- Record last cross-reference
2712 XE.Last_Xref := Xref.Last;
2713 C := Nextc;
2715 exception
2716 when Bad_ALI_Format =>
2718 -- If ignoring errors, then we skip a line with an
2719 -- unexpected error, and try to continue subsequent
2720 -- xref lines.
2722 if Ignore_Errors then
2723 Xref_Entity.Decrement_Last;
2724 Skip_Line;
2725 C := Nextc;
2727 -- Otherwise, we reraise the fatal exception
2729 else
2730 raise;
2731 end if;
2732 end Read_Refs_For_One_Entity;
2733 end loop;
2735 -- Record last entity
2737 XS.Last_Entity := Xref_Entity.Last;
2739 end Read_Refs_For_One_File;
2741 C := Getc;
2742 end loop X_Loop;
2744 -- Here after dealing with xref sections
2746 -- Ignore remaining lines, which belong to an additional section of the
2747 -- ALI file not considered here (like SCO or SPARK information).
2749 Check_Unknown_Line;
2751 return Id;
2753 exception
2754 when Bad_ALI_Format =>
2755 return No_ALI_Id;
2756 end Scan_ALI;
2758 ---------
2759 -- SEq --
2760 ---------
2762 function SEq (F1, F2 : String_Ptr) return Boolean is
2763 begin
2764 return F1.all = F2.all;
2765 end SEq;
2767 -----------
2768 -- SHash --
2769 -----------
2771 function SHash (S : String_Ptr) return Vindex is
2772 H : Word;
2774 begin
2775 H := 0;
2776 for J in S.all'Range loop
2777 H := H * 2 + Character'Pos (S (J));
2778 end loop;
2780 return Vindex (Vindex'First + Vindex (H mod Vindex'Range_Length));
2781 end SHash;
2783 end ALI;