1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Butil
; use Butil
;
27 with Debug
; use Debug
;
28 with Fname
; use Fname
;
30 with Osint
; use Osint
;
31 with Output
; use Output
;
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
51 'L' => True, -- linker option
53 'E' => True, -- external
54 'D' => True, -- dependency
56 'S' => True, -- specific dispatching
57 'Y' => True, -- limited_with
64 procedure Initialize_ALI
is
66 -- When (re)initializing ALI data structures the ALI user expects to
67 -- get a fresh set of data structures. Thus we first need to erase the
68 -- marks put in the name table by the previous set of ALI routine calls.
69 -- These two loops are empty and harmless the first time in.
71 for J
in ALIs
.First
.. ALIs
.Last
loop
72 Set_Name_Table_Info
(ALIs
.Table
(J
).Afile
, 0);
75 for J
in Units
.First
.. Units
.Last
loop
76 Set_Name_Table_Info
(Units
.Table
(J
).Uname
, 0);
79 -- Free argument table strings
81 for J
in Args
.First
.. Args
.Last
loop
82 Free
(Args
.Table
(J
));
85 -- Initialize all tables
99 -- Add dummy zero'th item in Linker_Options and Notes for sort calls
101 Linker_Options
.Increment_Last
;
102 Notes
.Increment_Last
;
104 -- Initialize global variables recording cumulative options in all
105 -- ALI files that are read for a given processing run in gnatbind.
107 Dynamic_Elaboration_Checks_Specified
:= False;
108 Float_Format_Specified
:= ' ';
109 Locking_Policy_Specified
:= ' ';
110 No_Normalize_Scalars_Specified
:= False;
111 No_Object_Specified
:= False;
112 Normalize_Scalars_Specified
:= False;
113 Queuing_Policy_Specified
:= ' ';
114 Static_Elaboration_Model_Used
:= False;
115 Task_Dispatching_Policy_Specified
:= ' ';
116 Unreserve_All_Interrupts_Specified
:= False;
117 Zero_Cost_Exceptions_Specified
:= False;
129 Read_Xref
: Boolean := False;
130 Read_Lines
: String := "";
131 Ignore_Lines
: String := "X";
132 Ignore_Errors
: Boolean := False;
133 Directly_Scanned
: Boolean := False) return ALI_Id
135 P
: Text_Ptr
:= T
'First;
136 Line
: Logical_Line_Number
:= 1;
142 Ignore
: array (Character range 'A' .. 'Z') of Boolean;
143 -- Ignore (X) is set to True if lines starting with X are to
144 -- be ignored by Scan_ALI and skipped, and False if the lines
145 -- are to be read and processed.
147 Bad_ALI_Format
: exception;
148 -- Exception raised by Fatal_Error if Err is True
150 function At_Eol
return Boolean;
151 -- Test if at end of line
153 function At_End_Of_Field
return Boolean;
154 -- Test if at end of line, or if at blank or horizontal tab
156 procedure Check_At_End_Of_Field
;
157 -- Check if we are at end of field, fatal error if not
159 procedure Checkc
(C
: Character);
160 -- Check next character is C. If so bump past it, if not fatal error
162 procedure Check_Unknown_Line
;
163 -- If Ignore_Errors mode, then checks C to make sure that it is not
164 -- an unknown ALI line type characters, and if so, skips lines
165 -- until the first character of the line is one of these characters,
166 -- at which point it does a Getc to put that character in C. The
167 -- call has no effect if C is already an appropriate character.
168 -- If not in Ignore_Errors mode, a fatal error is signalled if the
169 -- line is unknown. Note that if C is an EOL on entry, the line is
170 -- skipped (it is assumed that blank lines are never significant).
171 -- If C is EOF on entry, the call has no effect (it is assumed that
172 -- the caller will properly handle this case).
174 procedure Fatal_Error
;
175 -- Generate fatal error message for badly formatted ALI file if
176 -- Err is false, or raise Bad_ALI_Format if Err is True.
178 procedure Fatal_Error_Ignore
;
179 pragma Inline
(Fatal_Error_Ignore
);
180 -- In Ignore_Errors mode, has no effect, otherwise same as Fatal_Error
182 function Getc
return Character;
183 -- Get next character, bumping P past the character obtained
185 function Get_File_Name
(Lower
: Boolean := False) return File_Name_Type
;
186 -- Skip blanks, then scan out a file name (name is left in Name_Buffer
187 -- with length in Name_Len, as well as returning a File_Name_Type value.
188 -- If lower is false, the case is unchanged, if Lower is True then the
189 -- result is forced to all lower case for systems where file names are
190 -- not case sensitive. This ensures that gnatbind works correctly
191 -- regardless of the case of the file name on all systems. The scan
192 -- is terminated by a end of line, space or horizontal tab. Any other
193 -- special characters are included in the returned name.
196 (Ignore_Spaces
: Boolean := False;
197 Ignore_Special
: Boolean := False) return Name_Id
;
198 -- Skip blanks, then scan out a name (name is left in Name_Buffer with
199 -- length in Name_Len, as well as being returned in Name_Id form).
200 -- If Lower is set to True then the Name_Buffer will be converted to
201 -- all lower case, for systems where file names are not case sensitive.
202 -- This ensures that gnatbind works correctly regardless of the case
203 -- of the file name on all systems. The termination condition depends
204 -- on the settings of Ignore_Spaces and Ignore_Special:
206 -- If Ignore_Spaces is False (normal case), then scan is terminated
207 -- by the normal end of field condition (EOL, space, horizontal tab)
209 -- If Ignore_Special is False (normal case), the scan is terminated by
210 -- a typeref bracket or an equal sign except for the special case of
211 -- an operator name starting with a double quote which is terminated
212 -- by another double quote.
214 -- It is an error to set both Ignore_Spaces and Ignore_Special to True.
215 -- This function handles wide characters properly.
217 function Get_Nat
return Nat
;
218 -- Skip blanks, then scan out an unsigned integer value in Nat range
219 -- raises ALI_Reading_Error if the encoutered type is not natural.
221 function Get_Stamp
return Time_Stamp_Type
;
222 -- Skip blanks, then scan out a time stamp
224 function Get_Unit_Name
return Unit_Name_Type
;
225 -- Skip blanks, then scan out a file name (name is left in Name_Buffer
226 -- with length in Name_Len, as well as returning a Unit_Name_Type value.
227 -- The case is unchanged and terminated by a normal end of field.
229 function Nextc
return Character;
230 -- Return current character without modifying pointer P
232 procedure Get_Typeref
233 (Current_File_Num
: Sdep_Id
;
235 File_Num
: out Sdep_Id
;
237 Ref_Type
: out Character;
239 Standard_Entity
: out Name_Id
);
240 -- Parse the definition of a typeref (<...>, {...} or (...))
243 -- Skip past spaces, then skip past end of line (fatal error if not
244 -- at end of line). Also skips past any following blank lines.
247 -- Skip rest of current line and any following blank lines
249 procedure Skip_Space
;
250 -- Skip past white space (blanks or horizontal tab)
253 -- Skip past next character, does not affect value in C. This call
254 -- is like calling Getc and ignoring the returned result.
256 ---------------------
257 -- At_End_Of_Field --
258 ---------------------
260 function At_End_Of_Field
return Boolean is
269 function At_Eol
return Boolean is
271 return Nextc
= EOF
or else Nextc
= CR
or else Nextc
= LF
;
274 ---------------------------
275 -- Check_At_End_Of_Field --
276 ---------------------------
278 procedure Check_At_End_Of_Field
is
280 if not At_End_Of_Field
then
281 if Ignore_Errors
then
282 while Nextc
> ' ' loop
289 end Check_At_End_Of_Field
;
291 ------------------------
292 -- Check_Unknown_Line --
293 ------------------------
295 procedure Check_Unknown_Line
is
297 while C
not in 'A' .. 'Z'
298 or else not Known_ALI_Lines
(C
)
300 if C
= CR
or else C
= LF
then
307 elsif Ignore_Errors
then
315 end Check_Unknown_Line
;
321 procedure Checkc
(C
: Character) is
325 elsif Ignore_Errors
then
336 procedure Fatal_Error
is
341 procedure Wchar
(C
: Character);
342 -- Write a single character, replacing horizontal tab by spaces
344 procedure Wchar
(C
: Character) is
349 exit when Col
mod 8 = 0;
358 -- Start of processing for Fatal_Error
362 raise Bad_ALI_Format
;
366 Write_Str
("fatal error: file ");
368 Write_Str
(" is incorrectly formatted");
371 Write_Str
("make sure you are using consistent versions " &
373 -- Split the following line so that it can easily be transformed for
374 -- e.g. JVM/.NET back-ends where the compiler has a different name.
380 -- Find start of line
384 and then T
(Ptr1
- 1) /= CR
385 and then T
(Ptr1
- 1) /= LF
390 Write_Int
(Int
(Line
));
405 and then T
(Ptr2
) /= CR
406 and then T
(Ptr2
) /= LF
418 if T
(Ptr1
) = HT
then
430 Exit_Program
(E_Fatal
);
433 ------------------------
434 -- Fatal_Error_Ignore --
435 ------------------------
437 procedure Fatal_Error_Ignore
is
439 if not Ignore_Errors
then
442 end Fatal_Error_Ignore
;
448 function Get_File_Name
449 (Lower
: Boolean := False) return File_Name_Type
454 F
:= Get_Name
(Ignore_Special
=> True);
456 -- Convert file name to all lower case if file names are not case
457 -- sensitive. This ensures that we handle names in the canonical
458 -- lower case format, regardless of the actual case.
460 if Lower
and not File_Names_Case_Sensitive
then
461 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
464 return File_Name_Type
(F
);
473 (Ignore_Spaces
: Boolean := False;
474 Ignore_Special
: Boolean := False) return Name_Id
481 if Ignore_Errors
then
489 Add_Char_To_Name_Buffer
(Getc
);
491 exit when At_End_Of_Field
and then not Ignore_Spaces
;
493 if not Ignore_Special
then
494 if Name_Buffer
(1) = '"' then
495 exit when Name_Len
> 1 and then Name_Buffer
(Name_Len
) = '"';
498 -- Terminate on parens or angle brackets or equal sign
500 exit when Nextc
= '(' or else Nextc
= ')'
501 or else Nextc
= '{' or else Nextc
= '}'
502 or else Nextc
= '<' or else Nextc
= '>'
505 -- Terminate if left bracket not part of wide char sequence
506 -- Note that we only recognize brackets notation so far ???
508 exit when Nextc
= '[' and then T
(P
+ 1) /= '"';
510 -- Terminate if right bracket not part of wide char sequence
512 exit when Nextc
= ']' and then T
(P
- 1) /= '"';
524 function Get_Unit_Name
return Unit_Name_Type
is
526 return Unit_Name_Type
(Get_Name
);
533 function Get_Nat
return Nat
is
539 -- Check if we are on a number. In the case of bad ALI files, this
542 if not (Nextc
in '0' .. '9') then
548 V
:= V
* 10 + (Character'Pos (Getc
) - Character'Pos ('0'));
550 exit when At_End_Of_Field
;
551 exit when Nextc
< '0' or else Nextc
> '9';
561 function Get_Stamp
return Time_Stamp_Type
is
569 if Ignore_Errors
then
570 return Dummy_Time_Stamp
;
576 -- Following reads old style time stamp missing first two digits
578 if Nextc
in '7' .. '9' then
583 -- Normal case of full year in time stamp
589 for J
in Start
.. T
'Last loop
600 procedure Get_Typeref
601 (Current_File_Num
: Sdep_Id
;
603 File_Num
: out Sdep_Id
;
605 Ref_Type
: out Character;
607 Standard_Entity
: out Name_Id
)
612 when '<' => Ref
:= Tref_Derived
;
613 when '(' => Ref
:= Tref_Access
;
614 when '{' => Ref
:= Tref_Type
;
615 when others => Ref
:= Tref_None
;
618 -- Case of typeref field present
620 if Ref
/= Tref_None
then
621 P
:= P
+ 1; -- skip opening bracket
623 if Nextc
in 'a' .. 'z' then
624 File_Num
:= No_Sdep_Id
;
628 Standard_Entity
:= Get_Name
(Ignore_Spaces
=> True);
633 File_Num
:= Sdep_Id
(N
+ Nat
(First_Sdep_Entry
) - 1);
637 File_Num
:= Current_File_Num
;
643 Standard_Entity
:= No_Name
;
646 -- ??? Temporary workaround for nested generics case:
647 -- 4i4 Directories{1|4I9[4|6[3|3]]}
651 Nested_Brackets
: Natural := 0;
657 Nested_Brackets
:= Nested_Brackets
+ 1;
659 Nested_Brackets
:= Nested_Brackets
- 1;
661 if Nested_Brackets
= 0 then
670 P
:= P
+ 1; -- skip closing bracket
673 -- No typeref entry present
676 File_Num
:= No_Sdep_Id
;
680 Standard_Entity
:= No_Name
;
688 function Getc
return Character is
702 function Nextc
return Character is
711 procedure Skip_Eol
is
716 if Ignore_Errors
then
717 while not At_Eol
loop
725 -- Loop to skip past blank lines (first time through skips this EOL)
727 while Nextc
< ' ' and then Nextc
/= EOF
loop
740 procedure Skip_Line
is
742 while not At_Eol
loop
753 procedure Skip_Space
is
755 while Nextc
= ' ' or else Nextc
= HT
loop
771 -- Start of processing for Scan_ALI
774 First_Sdep_Entry
:= Sdep
.Last
+ 1;
776 -- Acquire lines to be ignored
779 Ignore
:= ('U' |
'W' |
'Y' |
'D' |
'X' => False, others => True);
781 -- Read_Lines parameter given
783 elsif Read_Lines
/= "" then
784 Ignore
:= ('U' => False, others => True);
786 for J
in Read_Lines
'Range loop
787 Ignore
(Read_Lines
(J
)) := False;
790 -- Process Ignore_Lines parameter
793 Ignore
:= (others => False);
795 for J
in Ignore_Lines
'Range loop
796 pragma Assert
(Ignore_Lines
(J
) /= 'U');
797 Ignore
(Ignore_Lines
(J
)) := True;
801 -- Setup ALI Table entry with appropriate defaults
805 Set_Name_Table_Info
(F
, Int
(Id
));
809 Compile_Errors
=> False,
810 First_Interrupt_State
=> Interrupt_States
.Last
+ 1,
811 First_Sdep
=> No_Sdep_Id
,
812 First_Specific_Dispatching
=> Specific_Dispatching
.Last
+ 1,
813 First_Unit
=> No_Unit_Id
,
815 Last_Interrupt_State
=> Interrupt_States
.Last
,
816 Last_Sdep
=> No_Sdep_Id
,
817 Last_Specific_Dispatching
=> Specific_Dispatching
.Last
,
818 Last_Unit
=> No_Unit_Id
,
819 Locking_Policy
=> ' ',
822 Main_Program
=> None
,
824 Normalize_Scalars
=> False,
825 Ofile_Full_Name
=> Full_Object_File_Name
,
826 Queuing_Policy
=> ' ',
827 Restrictions
=> No_Restrictions
,
828 SAL_Interface
=> False,
830 Task_Dispatching_Policy
=> ' ',
831 Time_Slice_Value
=> -1,
832 Allocator_In_Body
=> False,
834 Unit_Exception_Table
=> False,
835 Ver
=> (others => ' '),
837 Zero_Cost_Exceptions
=> False);
839 -- Now we acquire the input lines from the ALI file. Note that the
840 -- convention in the following code is that as we enter each section,
841 -- C is set to contain the first character of the following line.
846 -- Acquire library version
850 -- The V line missing really indicates trouble, most likely it
851 -- means we don't have an ALI file at all, so here we give a
852 -- fatal error even if we are in Ignore_Errors mode.
856 elsif Ignore
('V') then
864 for J
in 1 .. Ver_Len_Max
loop
867 ALIs
.Table
(Id
).Ver
(J
) := C
;
868 ALIs
.Table
(Id
).Ver_Len
:= J
;
877 -- Acquire main program line if present
890 ALIs
.Table
(Id
).Main_Program
:= Func
;
892 ALIs
.Table
(Id
).Main_Program
:= Proc
;
902 ALIs
.Table
(Id
).Main_Priority
:= Get_Nat
;
910 ALIs
.Table
(Id
).Time_Slice_Value
:= Get_Nat
;
918 ALIs
.Table
(Id
).Allocator_In_Body
:= True;
926 ALIs
.Table
(Id
).Main_CPU
:= Get_Nat
;
933 ALIs
.Table
(Id
).WC_Encoding
:= Getc
;
942 -- Acquire argument lines
944 First_Arg
:= Args
.Last
+ 1;
948 exit A_Loop
when C
/= 'A';
959 while not At_Eol
loop
960 Add_Char_To_Name_Buffer
(Getc
);
963 -- If -fstack-check, record that it occurred
965 if Name_Buffer
(1 .. Name_Len
) = "-fstack-check" then
966 Stack_Check_Switch_Set
:= True;
969 -- Store the argument
972 Args
.Table
(Args
.Last
) := new String'(Name_Buffer (1 .. Name_Len));
985 if Ignore_Errors then
1005 while not At_Eol loop
1010 -- Processing for CE
1014 ALIs.Table (Id).Compile_Errors := True;
1016 -- Processing for DB
1020 Detect_Blocking := True;
1022 -- Processing for FD/FG/FI
1025 Float_Format_Specified := Getc;
1026 ALIs.Table (Id).Float_Format := Float_Format_Specified;
1028 -- Processing for Lx
1031 Locking_Policy_Specified := Getc;
1032 ALIs.Table (Id).Locking_Policy := Locking_Policy_Specified;
1034 -- Processing for flags starting with N
1039 -- Processing for NO
1042 ALIs.Table (Id).No_Object := True;
1043 No_Object_Specified := True;
1045 -- Processing for NR
1048 No_Run_Time_Mode := True;
1049 Configurable_Run_Time_Mode := True;
1051 -- Processing for NS
1054 ALIs.Table (Id).Normalize_Scalars := True;
1055 Normalize_Scalars_Specified := True;
1058 -- Invalid switch starting with N
1064 -- Processing for Qx
1067 Queuing_Policy_Specified := Getc;
1068 ALIs.Table (Id).Queuing_Policy := Queuing_Policy_Specified;
1070 -- Processing for flags starting with S
1075 -- Processing for SL
1078 ALIs.Table (Id).SAL_Interface := True;
1080 -- Processing for SS
1083 Opt.Sec_Stack_Used := True;
1085 -- Invalid switch starting with S
1091 -- Processing for Tx
1094 Task_Dispatching_Policy_Specified := Getc;
1095 ALIs.Table (Id).Task_Dispatching_Policy :=
1096 Task_Dispatching_Policy_Specified;
1098 -- Processing for switch starting with U
1103 -- Processing for UA
1106 Unreserve_All_Interrupts_Specified := True;
1108 -- Processing for UX
1111 ALIs.Table (Id).Unit_Exception_Table := True;
1113 -- Invalid switches starting with U
1119 -- Processing for ZX
1125 ALIs.Table (Id).Zero_Cost_Exceptions := True;
1126 Zero_Cost_Exceptions_Specified := True;
1131 -- Invalid parameter
1139 if not NS_Found then
1140 No_Normalize_Scalars_Specified := True;
1149 -- Acquire first restrictions line
1152 if Ignore_Errors then
1164 if Ignore ('R
') then
1167 -- Process restrictions line
1170 Scan_Restrictions : declare
1171 Save_R : constant Restrictions_Info := Cumulative_Restrictions;
1172 -- Save cumulative restrictions in case we have a fatal error
1174 Bad_R_Line : exception;
1175 -- Signal bad restrictions line (raised on unexpected character)
1181 -- Acquire information for boolean restrictions
1183 for R in All_Boolean_Restrictions loop
1188 ALIs.Table (Id).Restrictions.Violated (R) := True;
1189 Cumulative_Restrictions.Violated (R) := True;
1192 ALIs.Table (Id).Restrictions.Set (R) := True;
1193 Cumulative_Restrictions.Set (R) := True;
1203 -- Acquire information for parameter restrictions
1205 for RP in All_Parameter_Restrictions loop
1207 -- Acquire restrictions pragma information
1214 ALIs.Table (Id).Restrictions.Set (RP) := True;
1217 N : constant Integer := Integer (Get_Nat);
1219 ALIs.Table (Id).Restrictions.Value (RP) := N;
1221 if Cumulative_Restrictions.Set (RP) then
1222 Cumulative_Restrictions.Value (RP) :=
1224 (Cumulative_Restrictions.Value (RP), N);
1226 Cumulative_Restrictions.Set (RP) := True;
1227 Cumulative_Restrictions.Value (RP) := N;
1235 -- Acquire restrictions violations information
1242 ALIs.Table (Id).Restrictions.Violated (RP) := True;
1243 Cumulative_Restrictions.Violated (RP) := True;
1246 N : constant Integer := Integer (Get_Nat);
1247 pragma Unsuppress (Overflow_Check);
1250 ALIs.Table (Id).Restrictions.Count (RP) := N;
1252 if RP in Checked_Max_Parameter_Restrictions then
1253 Cumulative_Restrictions.Count (RP) :=
1255 (Cumulative_Restrictions.Count (RP), N);
1257 Cumulative_Restrictions.Count (RP) :=
1258 Cumulative_Restrictions.Count (RP) + N;
1262 when Constraint_Error =>
1264 -- A constraint error comes from the addition in
1265 -- the else branch. We reset to the maximum and
1266 -- indicate that the real value is now unknown.
1268 Cumulative_Restrictions.Value (RP) := Integer'Last;
1269 Cumulative_Restrictions.Unknown (RP) := True;
1274 ALIs.Table (Id).Restrictions.Unknown (RP) := True;
1275 Cumulative_Restrictions.Unknown (RP) := True;
1285 -- Here if error during scanning of restrictions line
1290 -- In Ignore_Errors mode, undo any changes to restrictions
1291 -- from this unit, and continue on.
1293 if Ignore_Errors then
1294 Cumulative_Restrictions := Save_R;
1295 ALIs.Table (Id).Restrictions := No_Restrictions;
1298 -- In normal mode, this is a fatal error
1304 end Scan_Restrictions;
1307 -- Acquire additional restrictions (No_Dependence) lines if present
1311 if Ignore ('R
') then
1315 No_Deps.Append ((Id, Get_Name));
1322 -- Acquire 'I
' lines if present
1327 if Ignore ('I
') then
1333 I_State : Character;
1342 Interrupt_States.Append (
1343 (Interrupt_Id => Int_Num,
1344 Interrupt_State => I_State,
1345 IS_Pragma_Line => Line_No));
1347 ALIs.Table (Id).Last_Interrupt_State := Interrupt_States.Last;
1355 -- Acquire 'S
' lines if present
1360 if Ignore ('S
') then
1376 First_Prio := Get_Nat;
1377 Last_Prio := Get_Nat;
1380 Specific_Dispatching.Append (
1381 (Dispatching_Policy => Policy,
1382 First_Priority => First_Prio,
1383 Last_Priority => Last_Prio,
1384 PSD_Pragma_Line => Line_No));
1386 ALIs.Table (Id).Last_Specific_Dispatching :=
1387 Specific_Dispatching.Last;
1396 -- Loop to acquire unit entries
1400 exit U_Loop when C /= 'U
';
1402 -- Note: as per spec, we never ignore U lines
1406 Units.Increment_Last;
1408 if ALIs.Table (Id).First_Unit = No_Unit_Id then
1409 ALIs.Table (Id).First_Unit := Units.Last;
1413 UL : Unit_Record renames Units.Table (Units.Last);
1416 UL.Uname := Get_Unit_Name;
1417 UL.Predefined := Is_Predefined_Unit;
1418 UL.Internal := Is_Internal_Unit;
1420 UL.Sfile := Get_File_Name (Lower => True);
1422 UL.Preelab := False;
1423 UL.No_Elab := False;
1424 UL.Shared_Passive := False;
1426 UL.Remote_Types := False;
1427 UL.Has_RACW := False;
1428 UL.Init_Scalars := False;
1429 UL.Is_Generic := False;
1430 UL.Icasing := Mixed_Case;
1431 UL.Kcasing := All_Lower_Case;
1432 UL.Dynamic_Elab := False;
1433 UL.Elaborate_Body := False;
1434 UL.Set_Elab_Entity := False;
1435 UL.Version := "00000000";
1436 UL.First_With := Withs.Last + 1;
1437 UL.First_Arg := First_Arg;
1438 UL.Elab_Position := 0;
1439 UL.SAL_Interface := ALIs.Table (Id).SAL_Interface;
1440 UL.Directly_Scanned := Directly_Scanned;
1441 UL.Body_Needed_For_SAL := False;
1442 UL.Elaborate_Body_Desirable := False;
1443 UL.Optimize_Alignment := 'O
';
1445 if Debug_Flag_U then
1446 Write_Str (" ----> reading unit ");
1447 Write_Int (Int (Units.Last));
1449 Write_Unit_Name (UL.Uname);
1450 Write_Str (" from file ");
1451 Write_Name (UL.Sfile);
1456 -- Check for duplicated unit in different files
1459 Info : constant Int := Get_Name_Table_Info
1460 (Units.Table (Units.Last).Uname);
1463 and then Units.Table (Units.Last).Sfile /=
1464 Units.Table (Unit_Id (Info)).Sfile
1466 -- If Err is set then ignore duplicate unit name. This is the
1467 -- case of a call from gnatmake, where the situation can arise
1468 -- from substitution of source files. In such situations, the
1469 -- processing in gnatmake will always result in any required
1470 -- recompilations in any case, and if we consider this to be
1471 -- an error we get strange cases (for example when a generic
1472 -- instantiation is replaced by a normal package) where we
1473 -- read the old ali file, decide to recompile, and then decide
1474 -- that the old and new ali files are incompatible.
1479 -- If Err is not set, then this is a fatal error. This is
1480 -- the case of being called from the binder, where we must
1481 -- definitely diagnose this as an error.
1485 Write_Str ("error: duplicate unit name: ");
1488 Write_Str ("error: unit """);
1489 Write_Unit_Name (Units.Table (Units.Last).Uname);
1490 Write_Str (""" found in file """);
1491 Write_Name_Decoded (Units.Table (Units.Last).Sfile);
1495 Write_Str ("error
: unit
""");
1496 Write_Unit_Name (Units.Table (Unit_Id (Info)).Uname);
1497 Write_Str (""" found
in file
""");
1498 Write_Name_Decoded (Units.Table (Unit_Id (Info)).Sfile);
1502 Exit_Program (E_Fatal);
1508 (Units.Table (Units.Last).Uname, Int (Units.Last));
1510 -- Scan out possible version and other parameters
1519 if C in '0' .. '9' or else C in 'a
' .. 'f
' then
1520 Units.Table (Units.Last).Version (1) := C;
1522 for J in 2 .. 8 loop
1524 Units.Table (Units.Last).Version (J) := C;
1533 Check_At_End_Of_Field;
1534 Units.Table (Units.Last).Elaborate_Body_Desirable := True;
1537 Check_At_End_Of_Field;
1538 Units.Table (Units.Last).Body_Needed_For_SAL := True;
1544 -- DE parameter (Dynamic elaboration checks)
1550 Check_At_End_Of_Field;
1551 Units.Table (Units.Last).Dynamic_Elab := True;
1552 Dynamic_Elaboration_Checks_Specified := True;
1563 Units.Table (Units.Last).Elaborate_Body := True;
1565 Units.Table (Units.Last).Set_Elab_Entity := True;
1570 Check_At_End_Of_Field;
1572 -- GE parameter (generic)
1578 Check_At_End_Of_Field;
1579 Units.Table (Units.Last).Is_Generic := True;
1584 -- IL/IS/IU parameters
1590 Units.Table (Units.Last).Icasing := All_Lower_Case;
1592 Units.Table (Units.Last).Init_Scalars := True;
1593 Initialize_Scalars_Used := True;
1595 Units.Table (Units.Last).Icasing := All_Upper_Case;
1600 Check_At_End_Of_Field;
1608 Units.Table (Units.Last).Kcasing := Mixed_Case;
1610 Units.Table (Units.Last).Kcasing := All_Upper_Case;
1615 Check_At_End_Of_Field;
1623 Units.Table (Units.Last).No_Elab := True;
1624 Check_At_End_Of_Field;
1629 -- PR/PU/PK parameters
1635 Units.Table (Units.Last).Preelab := True;
1637 Units.Table (Units.Last).Pure := True;
1639 Units.Table (Units.Last).Unit_Kind := 'p
';
1644 Check_At_End_Of_Field;
1646 -- OL/OO/OS/OT parameters
1651 if C = 'L
' or else C = 'O
' or else C = 'S
' or else C = 'T
' then
1652 Units.Table (Units.Last).Optimize_Alignment := C;
1657 Check_At_End_Of_Field;
1665 Units.Table (Units.Last).RCI := True;
1667 Units.Table (Units.Last).Remote_Types := True;
1669 Units.Table (Units.Last).Has_RACW := True;
1674 Check_At_End_Of_Field;
1680 Units.Table (Units.Last).Shared_Passive := True;
1682 Units.Table (Units.Last).Unit_Kind := 's
';
1687 Check_At_End_Of_Field;
1697 -- Check if static elaboration model used
1699 if not Units.Table (Units.Last).Dynamic_Elab
1700 and then not Units.Table (Units.Last).Internal
1702 Static_Elaboration_Model_Used := True;
1707 -- Scan out With lines for this unit
1711 exit With_Loop when C /= 'W
' and then C /= 'Y
';
1713 if Ignore ('W
') then
1719 Withs.Increment_Last;
1720 Withs.Table (Withs.Last).Uname := Get_Unit_Name;
1721 Withs.Table (Withs.Last).Elaborate := False;
1722 Withs.Table (Withs.Last).Elaborate_All := False;
1723 Withs.Table (Withs.Last).Elab_Desirable := False;
1724 Withs.Table (Withs.Last).Elab_All_Desirable := False;
1725 Withs.Table (Withs.Last).SAL_Interface := False;
1726 Withs.Table (Withs.Last).Limited_With := (C = 'Y
');
1728 -- Generic case with no object file available
1731 Withs.Table (Withs.Last).Sfile := No_File;
1732 Withs.Table (Withs.Last).Afile := No_File;
1737 Withs.Table (Withs.Last).Sfile := Get_File_Name
1739 Withs.Table (Withs.Last).Afile := Get_File_Name
1742 -- Scan out possible E, EA, ED, and AD parameters
1744 while not At_Eol loop
1750 Check_At_End_Of_Field;
1752 -- Store AD indication unless ignore required
1754 if not Ignore_ED then
1755 Withs.Table (Withs.Last).Elab_All_Desirable :=
1759 elsif Nextc = 'E
' then
1762 if At_End_Of_Field then
1763 Withs.Table (Withs.Last).Elaborate := True;
1765 elsif Nextc = 'A
' then
1767 Check_At_End_Of_Field;
1768 Withs.Table (Withs.Last).Elaborate_All := True;
1772 Check_At_End_Of_Field;
1774 -- Store ED indication unless ignore required
1776 if not Ignore_ED then
1777 Withs.Table (Withs.Last).Elab_Desirable :=
1794 Units.Table (Units.Last).Last_With := Withs.Last;
1795 Units.Table (Units.Last).Last_Arg := Args.Last;
1797 -- If there are linker options lines present, scan them
1801 Linker_Options_Loop : loop
1803 exit Linker_Options_Loop when C /= 'L
';
1805 if Ignore ('L
') then
1816 if C < Character'Val (16#20#)
1817 or else C > Character'Val (16#7E#)
1822 C := Character'Val (0);
1829 for J in 1 .. 2 loop
1832 if C in '0' .. '9' then
1835 Character'Pos ('0');
1837 elsif C in 'A' .. 'F' then
1840 Character'Pos ('A') +
1849 Add_Char_To_Name_Buffer (Character'Val (V));
1854 exit when Nextc /= '"';
1858 Add_Char_To_Name_Buffer (C);
1862 Add_Char_To_Name_Buffer (NUL);
1867 end loop Linker_Options_Loop;
1869 -- Store the linker options entry if one was found
1871 if Name_Len /= 0 then
1872 Linker_Options.Increment_Last;
1874 Linker_Options.Table (Linker_Options.Last).Name :=
1877 Linker_Options.Table (Linker_Options.Last).Unit :=
1880 Linker_Options.Table (Linker_Options.Last).Internal_File :=
1881 Is_Internal_File_Name (F);
1883 Linker_Options.Table (Linker_Options.Last).Original_Pos :=
1884 Linker_Options.Last;
1887 -- If there are notes present, scan them
1891 exit Notes_Loop when C /= 'N';
1893 if Ignore ('N') then
1899 Notes.Increment_Last;
1900 Notes.Table (Notes.Last).Pragma_Type := Getc;
1901 Notes.Table (Notes.Last).Pragma_Line := Get_Nat;
1903 Notes.Table (Notes.Last).Pragma_Col := Get_Nat;
1904 Notes.Table (Notes.Last).Unit := Units.Last;
1907 Notes.Table (Notes.Last).Pragma_Args := No_Name;
1913 while not At_Eol loop
1914 Add_Char_To_Name_Buffer (Getc);
1917 Notes.Table (Notes.Last).Pragma_Args := Name_Enter;
1924 end loop Notes_Loop;
1927 -- End loop through units for one ALI file
1929 ALIs.Table (Id).Last_Unit := Units.Last;
1930 ALIs.Table (Id).Sfile := Units.Table (ALIs.Table (Id).First_Unit).Sfile;
1932 -- Set types of the units (there can be at most 2 of them)
1934 if ALIs.Table (Id).First_Unit /= ALIs.Table (Id).Last_Unit then
1935 Units.Table (ALIs.Table (Id).First_Unit).Utype := Is_Body;
1936 Units.Table (ALIs.Table (Id).Last_Unit).Utype := Is_Spec;
1939 -- Deal with body only and spec only cases, note that the reason we
1940 -- do our own checking of the name (rather than using Is_Body_Name)
1941 -- is that Uname drags in far too much compiler junk!
1943 Get_Name_String (Units.Table (Units.Last).Uname);
1945 if Name_Buffer (Name_Len) = 'b' then
1946 Units.Table (Units.Last).Utype := Is_Body_Only;
1948 Units.Table (Units.Last).Utype := Is_Spec_Only;
1952 -- Scan out external version references and put in hash table
1956 exit E_Loop when C /= 'E';
1958 if Ignore ('E') then
1974 exit when At_End_Of_Field;
1975 Add_Char_To_Name_Buffer (C);
1978 Version_Ref.Set (new String'(Name_Buffer (1 .. Name_Len)), True);
1985 -- Scan out source dependency lines for this ALI file
1987 ALIs.Table (Id).First_Sdep := Sdep.Last + 1;
1991 exit D_Loop when C /= 'D';
1993 if Ignore ('D') then
1999 Sdep.Increment_Last;
2001 -- In the following call, Lower is not set to True, this is either
2002 -- a bug, or it deserves a special comment as to why this is so???
2004 Sdep.Table (Sdep.Last).Sfile := Get_File_Name;
2006 Sdep.Table (Sdep.Last).Stamp := Get_Stamp;
2007 Sdep.Table (Sdep.Last).Dummy_Entry :=
2008 (Sdep.Table (Sdep.Last).Stamp = Dummy_Time_Stamp);
2010 -- Acquire checksum value
2023 exit when At_Eol or else Ctr = 8;
2025 if Nextc in '0' .. '9' then
2027 Character'Pos (Nextc) - Character'Pos ('0');
2029 elsif Nextc in 'a' .. 'f' then
2031 Character'Pos (Nextc) - Character'Pos ('a') + 10;
2041 if Ctr = 8 and then At_End_Of_Field then
2042 Sdep.Table (Sdep.Last).Checksum := Chk;
2048 -- Acquire subunit and reference file name entries
2050 Sdep.Table (Sdep.Last).Subunit_Name := No_Name;
2051 Sdep.Table (Sdep.Last).Rfile :=
2052 Sdep.Table (Sdep.Last).Sfile;
2053 Sdep.Table (Sdep.Last).Start_Line := 1;
2058 -- Here for subunit name
2060 if Nextc not in '0' .. '9' then
2062 while not At_End_Of_Field loop
2063 Add_Char_To_Name_Buffer (Getc);
2066 -- Set the subunit name. Note that we use Name_Find rather
2067 -- than Name_Enter here as the subunit name may already
2068 -- have been put in the name table by the Project Manager.
2070 Sdep.Table (Sdep.Last).Subunit_Name := Name_Find;
2075 -- Here for reference file name entry
2077 if Nextc in '0' .. '9' then
2078 Sdep.Table (Sdep.Last).Start_Line := Get_Nat;
2083 while not At_End_Of_Field loop
2084 Add_Char_To_Name_Buffer (Getc);
2087 Sdep.Table (Sdep.Last).Rfile := Name_Enter;
2097 ALIs.Table (Id).Last_Sdep := Sdep.Last;
2099 -- We must at this stage be at an Xref line or the end of file
2111 -- If we are ignoring Xref sections we are done (we ignore all
2112 -- remaining lines since only xref related lines follow X).
2114 if Ignore ('X') and then not Debug_Flag_X then
2118 -- Loop through Xref sections
2122 exit X_Loop when C /= 'X';
2124 -- Make new entry in section table
2126 Xref_Section.Increment_Last;
2128 Read_Refs_For_One_File : declare
2129 XS : Xref_Section_Record renames
2130 Xref_Section.Table (Xref_Section.Last);
2132 Current_File_Num : Sdep_Id;
2133 -- Keeps track of the current file number (changed by nn|)
2136 XS.File_Num := Sdep_Id (Get_Nat + Nat (First_Sdep_Entry) - 1);
2137 XS.File_Name := Get_File_Name;
2138 XS.First_Entity := Xref_Entity.Last + 1;
2140 Current_File_Num := XS.File_Num;
2147 -- Loop through Xref entities
2149 while C /= 'X' and then C /= EOF loop
2150 Xref_Entity.Increment_Last;
2152 Read_Refs_For_One_Entity : declare
2153 XE : Xref_Entity_Record renames
2154 Xref_Entity.Table (Xref_Entity.Last);
2157 procedure Read_Instantiation_Reference;
2158 -- Acquire instantiation reference. Caller has checked
2159 -- that current character is '[' and on return the cursor
2160 -- is skipped past the corresponding closing ']'.
2162 ----------------------------------
2163 -- Read_Instantiation_Reference --
2164 ----------------------------------
2166 procedure Read_Instantiation_Reference is
2167 Local_File_Num : Sdep_Id := Current_File_Num;
2170 Xref.Increment_Last;
2173 XR : Xref_Record renames Xref.Table (Xref.Last);
2176 P := P + 1; -- skip [
2181 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2182 Local_File_Num := XR.File_Num;
2187 XR.File_Num := Local_File_Num;
2194 -- Recursive call for next reference
2197 pragma Warnings (Off); -- kill recursion warning
2198 Read_Instantiation_Reference;
2199 pragma Warnings (On);
2202 -- Skip closing bracket after recursive call
2206 end Read_Instantiation_Reference;
2208 -- Start of processing for Read_Refs_For_One_Entity
2217 XE.Visibility := Global;
2219 XE.Visibility := Static;
2221 XE.Visibility := Other;
2224 XE.Entity := Get_Name;
2226 -- Handle the information about generic instantiations
2229 Skipc; -- Opening '['
2232 if Nextc /= '|' then
2233 XE.Iref_File_Num := Current_File_Num;
2237 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2239 XE.Iref_Line := Get_Nat;
2247 XE.Iref_File_Num := No_Sdep_Id;
2251 Current_File_Num := XS.File_Num;
2253 -- Renaming reference is present
2257 XE.Rref_Line := Get_Nat;
2263 XE.Rref_Col := Get_Nat;
2265 -- No renaming reference present
2274 XE.Oref_File_Num := No_Sdep_Id;
2275 XE.Tref_File_Num := No_Sdep_Id;
2276 XE.Tref := Tref_None;
2277 XE.First_Xref := Xref.Last + 1;
2279 -- Loop to check for additional info present
2292 (Current_File_Num, Ref, File, Line, Typ, Col, Std);
2293 exit when Ref = Tref_None;
2295 -- Do we have an overriding procedure?
2297 if Ref = Tref_Derived and then Typ = 'p' then
2298 XE.Oref_File_Num := File;
2299 XE.Oref_Line := Line;
2302 -- Arrays never override anything, and <> points to
2303 -- the index types instead
2305 elsif Ref = Tref_Derived and then XE.Etype = 'A' then
2307 -- Index types are stored in the list of references
2309 Xref.Increment_Last;
2312 XR : Xref_Record renames Xref.Table (Xref.Last);
2314 XR.File_Num := File;
2316 XR.Rtype := Array_Index_Reference;
2321 -- Interfaces are stored in the list of references,
2322 -- although the parent type itself is stored in XE.
2323 -- The first interface (when there are only
2324 -- interfaces) is stored in XE.Tref*)
2326 elsif Ref = Tref_Derived
2328 and then XE.Tref_File_Num /= No_Sdep_Id
2330 Xref.Increment_Last;
2333 XR : Xref_Record renames Xref.Table (Xref.Last);
2335 XR.File_Num := File;
2337 XR.Rtype := Interface_Reference;
2344 XE.Tref_File_Num := File;
2345 XE.Tref_Line := Line;
2346 XE.Tref_Type := Typ;
2348 XE.Tref_Standard_Entity := Std;
2353 -- Loop through cross-references for this entity
2360 exit when Nextc /= '.';
2364 Xref.Increment_Last;
2367 XR : Xref_Record renames Xref.Table (Xref.Last);
2374 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2375 Current_File_Num := XR.File_Num;
2379 XR.File_Num := Current_File_Num;
2385 -- Imported entities reference as in:
2386 -- 494b<c,__gnat_copy_attribs>25
2387 -- ??? Simply skipped for now
2390 while Getc /= '>' loop
2398 Read_Instantiation_Reference;
2403 -- Record last cross-reference
2405 XE.Last_Xref := Xref.Last;
2409 when Bad_ALI_Format =>
2411 -- If ignoring errors, then we skip a line with an
2412 -- unexpected error, and try to continue subsequent
2415 if Ignore_Errors then
2416 Xref_Entity.Decrement_Last;
2420 -- Otherwise, we reraise the fatal exception
2425 end Read_Refs_For_One_Entity;
2428 -- Record last entity
2430 XS.Last_Entity := Xref_Entity.Last;
2432 end Read_Refs_For_One_File;
2437 -- Here after dealing with xref sections
2439 if C /= EOF and then C /= 'X' then
2446 when Bad_ALI_Format =>
2454 function SEq (F1, F2 : String_Ptr) return Boolean is
2456 return F1.all = F2.all;
2463 function SHash (S : String_Ptr) return Vindex is
2468 for J in S.all'Range loop
2469 H := H * 2 + Character'Pos (S (J));
2472 return Vindex (Vindex'First + Vindex (H mod Vindex'Range_Length));