1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2005, 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 with Butil
; use Butil
;
28 with Debug
; use Debug
;
29 with Fname
; use Fname
;
30 with Namet
; use Namet
;
32 with Osint
; use Osint
;
33 with Output
; use Output
;
38 -- Make control characters visible
40 -- The following variable records which characters currently are
41 -- used as line type markers in the ALI file. This is used in
42 -- Scan_ALI to detect (or skip) invalid lines.
44 Known_ALI_Lines
: constant array (Character range 'A' .. 'Z') of Boolean :=
45 ('V' => True, -- version
46 'M' => True, -- main program
47 'A' => True, -- argument
48 'P' => True, -- program
49 'R' => True, -- restriction
50 'I' => True, -- interrupt
53 'L' => True, -- linker option
54 'E' => True, -- external
55 'D' => True, -- dependency
63 procedure Initialize_ALI
is
65 -- When (re)initializing ALI data structures the ALI user expects to
66 -- get a fresh set of data structures. Thus we first need to erase the
67 -- marks put in the name table by the previous set of ALI routine calls.
68 -- These two loops are empty and harmless the first time in.
70 for J
in ALIs
.First
.. ALIs
.Last
loop
71 Set_Name_Table_Info
(ALIs
.Table
(J
).Afile
, 0);
74 for J
in Units
.First
.. Units
.Last
loop
75 Set_Name_Table_Info
(Units
.Table
(J
).Uname
, 0);
78 -- Free argument table strings
80 for J
in Args
.First
.. Args
.Last
loop
81 Free
(Args
.Table
(J
));
84 -- Initialize all tables
97 -- Add dummy zero'th item in Linker_Options for the sort function
99 Linker_Options
.Increment_Last
;
101 -- Initialize global variables recording cumulative options in all
102 -- ALI files that are read for a given processing run in gnatbind.
104 Dynamic_Elaboration_Checks_Specified
:= False;
105 Float_Format_Specified
:= ' ';
106 Locking_Policy_Specified
:= ' ';
107 No_Normalize_Scalars_Specified
:= False;
108 No_Object_Specified
:= False;
109 Normalize_Scalars_Specified
:= False;
110 Queuing_Policy_Specified
:= ' ';
111 Static_Elaboration_Model_Used
:= False;
112 Task_Dispatching_Policy_Specified
:= ' ';
113 Unreserve_All_Interrupts_Specified
:= False;
114 Zero_Cost_Exceptions_Specified
:= False;
126 Read_Xref
: Boolean := False;
127 Read_Lines
: String := "";
128 Ignore_Lines
: String := "X";
129 Ignore_Errors
: Boolean := False) return ALI_Id
131 P
: Text_Ptr
:= T
'First;
132 Line
: Logical_Line_Number
:= 1;
138 Ignore
: array (Character range 'A' .. 'Z') of Boolean;
139 -- Ignore (X) is set to True if lines starting with X are to
140 -- be ignored by Scan_ALI and skipped, and False if the lines
141 -- are to be read and processed.
143 Restrictions_Initial
: Rident
.Restrictions_Info
;
144 pragma Warnings
(Off
, Restrictions_Initial
);
145 -- This variable, which should really be a constant (but that's not
146 -- allowed by the language) is used only for initialization, and the
147 -- reason we are declaring it is to get the default initialization
148 -- set for the object.
150 Bad_ALI_Format
: exception;
151 -- Exception raised by Fatal_Error if Err is True
153 function At_Eol
return Boolean;
154 -- Test if at end of line
156 function At_End_Of_Field
return Boolean;
157 -- Test if at end of line, or if at blank or horizontal tab
159 procedure Check_At_End_Of_Field
;
160 -- Check if we are at end of field, fatal error if not
162 procedure Checkc
(C
: Character);
163 -- Check next character is C. If so bump past it, if not fatal error
165 procedure Check_Unknown_Line
;
166 -- If Ignore_Errors mode, then checks C to make sure that it is not
167 -- an unknown ALI line type characters, and if so, skips lines
168 -- until the first character of the line is one of these characters,
169 -- at which point it does a Getc to put that character in C. The
170 -- call has no effect if C is already an appropriate character.
171 -- If not in Ignore_Errors mode, a fatal error is signalled if the
172 -- line is unknown. Note that if C is an EOL on entry, the line is
173 -- skipped (it is assumed that blank lines are never significant).
174 -- If C is EOF on entry, the call has no effect (it is assumed that
175 -- the caller will properly handle this case).
177 procedure Fatal_Error
;
178 -- Generate fatal error message for badly formatted ALI file if
179 -- Err is false, or raise Bad_ALI_Format if Err is True.
181 procedure Fatal_Error_Ignore
;
182 pragma Inline
(Fatal_Error_Ignore
);
183 -- In Ignore_Errors mode, has no effect, otherwise same as Fatal_Error
185 function Getc
return Character;
186 -- Get next character, bumping P past the character obtained
189 (Lower
: Boolean := False;
190 Ignore_Spaces
: Boolean := False) return Name_Id
;
191 -- Skip blanks, then scan out a name (name is left in Name_Buffer with
192 -- length in Name_Len, as well as being returned in Name_Id form).
193 -- If Lower is set to True then the Name_Buffer will be converted to
194 -- all lower case, for systems where file names are not case sensitive.
195 -- This ensures that gnatbind works correctly regardless of the case
196 -- of the file name on all systems. The name is terminated by a either
197 -- white space (when Ignore_Spaces is False) or a typeref bracket or
198 -- an equal sign except for the special case of an operator name
199 -- starting with a double quite which is terminated by another double
202 function Get_Nat
return Nat
;
203 -- Skip blanks, then scan out an unsigned integer value in Nat range
205 function Get_Stamp
return Time_Stamp_Type
;
206 -- Skip blanks, then scan out a time stamp
208 function Nextc
return Character;
209 -- Return current character without modifying pointer P
211 procedure Get_Typeref
212 (Current_File_Num
: Sdep_Id
;
214 File_Num
: out Sdep_Id
;
216 Ref_Type
: out Character;
218 Standard_Entity
: out Name_Id
);
219 -- Parse the definition of a typeref (<...>, {...} or (...))
222 -- Skip past spaces, then skip past end of line (fatal error if not
223 -- at end of line). Also skips past any following blank lines.
226 -- Skip rest of current line and any following blank lines
228 procedure Skip_Space
;
229 -- Skip past white space (blanks or horizontal tab)
232 -- Skip past next character, does not affect value in C. This call
233 -- is like calling Getc and ignoring the returned result.
235 ---------------------
236 -- At_End_Of_Field --
237 ---------------------
239 function At_End_Of_Field
return Boolean is
248 function At_Eol
return Boolean is
250 return Nextc
= EOF
or else Nextc
= CR
or else Nextc
= LF
;
253 ---------------------------
254 -- Check_At_End_Of_Field --
255 ---------------------------
257 procedure Check_At_End_Of_Field
is
259 if not At_End_Of_Field
then
260 if Ignore_Errors
then
261 while Nextc
> ' ' loop
268 end Check_At_End_Of_Field
;
274 procedure Checkc
(C
: Character) is
278 elsif Ignore_Errors
then
285 ------------------------
286 -- Check_Unknown_Line --
287 ------------------------
289 procedure Check_Unknown_Line
is
291 while C
not in 'A' .. 'Z'
292 or else not Known_ALI_Lines
(C
)
294 if C
= CR
or else C
= LF
then
301 elsif Ignore_Errors
then
309 end Check_Unknown_Line
;
315 procedure Fatal_Error
is
320 procedure Wchar
(C
: Character);
321 -- Write a single character, replacing horizontal tab by spaces
323 procedure Wchar
(C
: Character) is
328 exit when Col
mod 8 = 0;
337 -- Start of processing for Fatal_Error
341 raise Bad_ALI_Format
;
345 Write_Str
("fatal error: file ");
347 Write_Str
(" is incorrectly formatted");
350 ("make sure you are using consistent versions of gcc/gnatbind");
353 -- Find start of line
358 and then T
(Ptr1
- 1) /= CR
359 and then T
(Ptr1
- 1) /= LF
364 Write_Int
(Int
(Line
));
379 and then T
(Ptr2
) /= CR
380 and then T
(Ptr2
) /= LF
392 if T
(Ptr1
) = HT
then
404 Exit_Program
(E_Fatal
);
407 ------------------------
408 -- Fatal_Error_Ignore --
409 ------------------------
411 procedure Fatal_Error_Ignore
is
413 if not Ignore_Errors
then
416 end Fatal_Error_Ignore
;
423 (Lower
: Boolean := False;
424 Ignore_Spaces
: Boolean := False) return Name_Id
431 if Ignore_Errors
then
439 Name_Len
:= Name_Len
+ 1;
440 Name_Buffer
(Name_Len
) := Getc
;
442 exit when At_End_Of_Field
and not Ignore_Spaces
;
444 if Name_Buffer
(1) = '"' then
445 exit when Name_Len
> 1 and then Name_Buffer
(Name_Len
) = '"';
448 exit when (At_End_Of_Field
and not Ignore_Spaces
)
449 or else Nextc
= '(' or else Nextc
= ')'
450 or else Nextc
= '{' or else Nextc
= '}'
451 or else Nextc
= '<' or else Nextc
= '>'
452 or else Nextc
= '[' or else Nextc
= ']'
457 -- Convert file name to all lower case if file names are not case
458 -- sensitive. This ensures that we handle names in the canonical
459 -- lower case format, regardless of the actual case.
461 if Lower
and not File_Names_Case_Sensitive
then
462 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
472 function Get_Nat
return Nat
is
480 V
:= V
* 10 + (Character'Pos (Getc
) - Character'Pos ('0'));
481 exit when At_End_Of_Field
;
482 exit when Nextc
< '0' or Nextc
> '9';
492 function Get_Stamp
return Time_Stamp_Type
is
500 if Ignore_Errors
then
501 return Dummy_Time_Stamp
;
507 -- Following reads old style time stamp missing first two digits
509 if Nextc
in '7' .. '9' then
514 -- Normal case of full year in time stamp
520 for J
in Start
.. T
'Last loop
531 function Getc
return Character is
545 function Nextc
return Character is
554 procedure Get_Typeref
555 (Current_File_Num
: Sdep_Id
;
557 File_Num
: out Sdep_Id
;
559 Ref_Type
: out Character;
561 Standard_Entity
: out Name_Id
)
566 when '<' => Ref
:= Tref_Derived
;
567 when '(' => Ref
:= Tref_Access
;
568 when '{' => Ref
:= Tref_Type
;
569 when others => Ref
:= Tref_None
;
572 -- Case of typeref field present
574 if Ref
/= Tref_None
then
575 P
:= P
+ 1; -- skip opening bracket
577 if Nextc
in 'a' .. 'z' then
578 File_Num
:= No_Sdep_Id
;
582 Standard_Entity
:= Get_Name
(Ignore_Spaces
=> True);
587 File_Num
:= Sdep_Id
(N
+ Nat
(First_Sdep_Entry
) - 1);
591 File_Num
:= Current_File_Num
;
597 Standard_Entity
:= No_Name
;
600 -- ??? Temporary workaround for nested generics case:
601 -- 4i4 Directories{1|4I9[4|6[3|3]]}
605 Nested_Brackets
: Natural := 0;
611 Nested_Brackets
:= Nested_Brackets
+ 1;
613 Nested_Brackets
:= Nested_Brackets
- 1;
615 if Nested_Brackets
= 0 then
624 P
:= P
+ 1; -- skip closing bracket
627 -- No typeref entry present
630 File_Num
:= No_Sdep_Id
;
634 Standard_Entity
:= No_Name
;
642 procedure Skip_Eol
is
647 if Ignore_Errors
then
648 while not At_Eol
loop
656 -- Loop to skip past blank lines (first time through skips this EOL)
658 while Nextc
< ' ' and then Nextc
/= EOF
loop
671 procedure Skip_Line
is
673 while not At_Eol
loop
684 procedure Skip_Space
is
686 while Nextc
= ' ' or else Nextc
= HT
loop
702 -- Start of processing for Scan_ALI
705 First_Sdep_Entry
:= Sdep
.Last
+ 1;
707 -- Acquire lines to be ignored
710 Ignore
:= ('U' |
'W' |
'D' |
'X' => False, others => True);
712 -- Read_Lines parameter given
714 elsif Read_Lines
/= "" then
715 Ignore
:= ('U' => False, others => True);
717 for J
in Read_Lines
'Range loop
718 Ignore
(Read_Lines
(J
)) := False;
721 -- Process Ignore_Lines parameter
724 Ignore
:= (others => False);
726 for J
in Ignore_Lines
'Range loop
727 pragma Assert
(Ignore_Lines
(J
) /= 'U');
728 Ignore
(Ignore_Lines
(J
)) := True;
732 -- Setup ALI Table entry with appropriate defaults
736 Set_Name_Table_Info
(F
, Int
(Id
));
740 Compile_Errors
=> False,
741 First_Interrupt_State
=> Interrupt_States
.Last
+ 1,
742 First_Sdep
=> No_Sdep_Id
,
743 First_Unit
=> No_Unit_Id
,
745 Last_Interrupt_State
=> Interrupt_States
.Last
,
746 Last_Sdep
=> No_Sdep_Id
,
747 Last_Unit
=> No_Unit_Id
,
748 Locking_Policy
=> ' ',
750 Main_Program
=> None
,
752 Normalize_Scalars
=> False,
753 Ofile_Full_Name
=> Full_Object_File_Name
,
754 Queuing_Policy
=> ' ',
755 Restrictions
=> Restrictions_Initial
,
756 SAL_Interface
=> False,
758 Task_Dispatching_Policy
=> ' ',
759 Time_Slice_Value
=> -1,
761 Unit_Exception_Table
=> False,
762 Ver
=> (others => ' '),
764 Zero_Cost_Exceptions
=> False);
766 -- Now we acquire the input lines from the ALI file. Note that the
767 -- convention in the following code is that as we enter each section,
768 -- C is set to contain the first character of the following line.
773 -- Acquire library version
777 -- The V line missing really indicates trouble, most likely it
778 -- means we don't have an ALI file at all, so here we give a
779 -- fatal error even if we are in Ignore_Errors mode.
783 elsif Ignore
('V') then
791 for J
in 1 .. Ver_Len_Max
loop
794 ALIs
.Table
(Id
).Ver
(J
) := C
;
795 ALIs
.Table
(Id
).Ver_Len
:= J
;
804 -- Acquire main program line if present
817 ALIs
.Table
(Id
).Main_Program
:= Func
;
819 ALIs
.Table
(Id
).Main_Program
:= Proc
;
829 ALIs
.Table
(Id
).Main_Priority
:= Get_Nat
;
837 ALIs
.Table
(Id
).Time_Slice_Value
:= Get_Nat
;
844 ALIs
.Table
(Id
).WC_Encoding
:= Getc
;
853 -- Acquire argument lines
855 First_Arg
:= Args
.Last
+ 1;
859 exit A_Loop
when C
/= 'A';
868 while not At_Eol
loop
869 Name_Len
:= Name_Len
+ 1;
870 Name_Buffer
(Name_Len
) := Getc
;
874 Args
.Table
(Args
.Last
) := new String'(Name_Buffer (1 .. Name_Len));
887 if Ignore_Errors then
907 while not At_Eol loop
916 ALIs.Table (Id).Compile_Errors := True;
922 Detect_Blocking := True;
924 -- Processing for FD/FG/FI
927 Float_Format_Specified := Getc;
928 ALIs.Table (Id).Float_Format := Float_Format_Specified;
933 Locking_Policy_Specified := Getc;
934 ALIs.Table (Id).Locking_Policy := Locking_Policy_Specified;
936 -- Processing for flags starting with N
944 ALIs.Table (Id).No_Object := True;
945 No_Object_Specified := True;
950 No_Run_Time_Mode := True;
951 Configurable_Run_Time_Mode := True;
956 ALIs.Table (Id).Normalize_Scalars := True;
957 Normalize_Scalars_Specified := True;
960 -- Invalid switch starting with N
969 Queuing_Policy_Specified := Getc;
970 ALIs.Table (Id).Queuing_Policy := Queuing_Policy_Specified;
972 -- Processing for flags starting with S
980 ALIs.Table (Id).SAL_Interface := True;
985 Opt.Sec_Stack_Used := True;
987 -- Invalid switch starting with S
996 Task_Dispatching_Policy_Specified := Getc;
997 ALIs.Table (Id).Task_Dispatching_Policy :=
998 Task_Dispatching_Policy_Specified;
1000 -- Processing for switch starting with U
1005 -- Processing for UA
1008 Unreserve_All_Interrupts_Specified := True;
1010 -- Processing for UX
1013 ALIs.Table (Id).Unit_Exception_Table := True;
1015 -- Invalid switches starting with U
1021 -- Processing for ZX
1027 ALIs.Table (Id).Zero_Cost_Exceptions := True;
1028 Zero_Cost_Exceptions_Specified := True;
1033 -- Invalid parameter
1041 if not NS_Found then
1042 No_Normalize_Scalars_Specified := True;
1051 -- Acquire first restrictions line
1054 if Ignore_Errors then
1066 if Ignore ('R
') then
1069 -- Process restrictions line
1072 Scan_Restrictions : declare
1073 Save_R : constant Restrictions_Info := Cumulative_Restrictions;
1074 -- Save cumulative restrictions in case we have a fatal error
1076 Bad_R_Line : exception;
1077 -- Signal bad restrictions line (raised on unexpected character)
1083 -- Acquire information for boolean restrictions
1085 for R in All_Boolean_Restrictions loop
1090 ALIs.Table (Id).Restrictions.Violated (R) := True;
1091 Cumulative_Restrictions.Violated (R) := True;
1094 ALIs.Table (Id).Restrictions.Set (R) := True;
1095 Cumulative_Restrictions.Set (R) := True;
1105 -- Acquire information for parameter restrictions
1107 for RP in All_Parameter_Restrictions loop
1109 -- Acquire restrictions pragma information
1116 ALIs.Table (Id).Restrictions.Set (RP) := True;
1119 N : constant Integer := Integer (Get_Nat);
1121 ALIs.Table (Id).Restrictions.Value (RP) := N;
1123 if Cumulative_Restrictions.Set (RP) then
1124 Cumulative_Restrictions.Value (RP) :=
1126 (Cumulative_Restrictions.Value (RP), N);
1128 Cumulative_Restrictions.Set (RP) := True;
1129 Cumulative_Restrictions.Value (RP) := N;
1137 -- Acquire restrictions violations information
1144 ALIs.Table (Id).Restrictions.Violated (RP) := True;
1145 Cumulative_Restrictions.Violated (RP) := True;
1148 N : constant Integer := Integer (Get_Nat);
1149 pragma Unsuppress (Overflow_Check);
1152 ALIs.Table (Id).Restrictions.Count (RP) := N;
1154 if RP in Checked_Max_Parameter_Restrictions then
1155 Cumulative_Restrictions.Count (RP) :=
1157 (Cumulative_Restrictions.Count (RP), N);
1159 Cumulative_Restrictions.Count (RP) :=
1160 Cumulative_Restrictions.Count (RP) + N;
1164 when Constraint_Error =>
1166 -- A constraint error comes from the addition in
1167 -- the else branch. We reset to the maximum and
1168 -- indicate that the real value is now unknown.
1170 Cumulative_Restrictions.Value (RP) := Integer'Last;
1171 Cumulative_Restrictions.Unknown (RP) := True;
1176 ALIs.Table (Id).Restrictions.Unknown (RP) := True;
1177 Cumulative_Restrictions.Unknown (RP) := True;
1187 -- Here if error during scanning of restrictions line
1192 -- In Ignore_Errors mode, undo any changes to restrictions
1193 -- from this unit, and continue on.
1195 if Ignore_Errors then
1196 Cumulative_Restrictions := Save_R;
1197 ALIs.Table (Id).Restrictions := Restrictions_Initial;
1200 -- In normal mode, this is a fatal error
1206 end Scan_Restrictions;
1209 -- Acquire additional restrictions (No_Dependence) lines if present
1213 if Ignore ('R
') then
1217 No_Deps.Append ((Id, Get_Name));
1224 -- Acquire 'I
' lines if present
1229 if Ignore ('I
') then
1235 I_State : Character;
1244 Interrupt_States.Append (
1245 (Interrupt_Id => Int_Num,
1246 Interrupt_State => I_State,
1247 IS_Pragma_Line => Line_No));
1249 ALIs.Table (Id).Last_Interrupt_State := Interrupt_States.Last;
1257 -- Loop to acquire unit entries
1261 exit U_Loop when C /= 'U
';
1263 -- Note: as per spec, we never ignore U lines
1267 Units.Increment_Last;
1269 if ALIs.Table (Id).First_Unit = No_Unit_Id then
1270 ALIs.Table (Id).First_Unit := Units.Last;
1273 Units.Table (Units.Last).Uname := Get_Name;
1274 Units.Table (Units.Last).Predefined := Is_Predefined_Unit;
1275 Units.Table (Units.Last).Internal := Is_Internal_Unit;
1276 Units.Table (Units.Last).My_ALI := Id;
1277 Units.Table (Units.Last).Sfile := Get_Name (Lower => True);
1278 Units.Table (Units.Last).Pure := False;
1279 Units.Table (Units.Last).Preelab := False;
1280 Units.Table (Units.Last).No_Elab := False;
1281 Units.Table (Units.Last).Shared_Passive := False;
1282 Units.Table (Units.Last).RCI := False;
1283 Units.Table (Units.Last).Remote_Types := False;
1284 Units.Table (Units.Last).Has_RACW := False;
1285 Units.Table (Units.Last).Init_Scalars := False;
1286 Units.Table (Units.Last).Is_Generic := False;
1287 Units.Table (Units.Last).Icasing := Mixed_Case;
1288 Units.Table (Units.Last).Kcasing := All_Lower_Case;
1289 Units.Table (Units.Last).Dynamic_Elab := False;
1290 Units.Table (Units.Last).Elaborate_Body := False;
1291 Units.Table (Units.Last).Set_Elab_Entity := False;
1292 Units.Table (Units.Last).Version := "00000000";
1293 Units.Table (Units.Last).First_With := Withs.Last + 1;
1294 Units.Table (Units.Last).First_Arg := First_Arg;
1295 Units.Table (Units.Last).Elab_Position := 0;
1296 Units.Table (Units.Last).SAL_Interface := ALIs.Table (Id).
1298 Units.Table (Units.Last).Body_Needed_For_SAL := False;
1300 if Debug_Flag_U then
1301 Write_Str (" ----> reading unit ");
1302 Write_Int (Int (Units.Last));
1304 Write_Unit_Name (Units.Table (Units.Last).Uname);
1305 Write_Str (" from file ");
1306 Write_Name (Units.Table (Units.Last).Sfile);
1310 -- Check for duplicated unit in different files
1313 Info : constant Int := Get_Name_Table_Info
1314 (Units.Table (Units.Last).Uname);
1317 and then Units.Table (Units.Last).Sfile /=
1318 Units.Table (Unit_Id (Info)).Sfile
1320 -- If Err is set then ignore duplicate unit name. This is the
1321 -- case of a call from gnatmake, where the situation can arise
1322 -- from substitution of source files. In such situations, the
1323 -- processing in gnatmake will always result in any required
1324 -- recompilations in any case, and if we consider this to be
1325 -- an error we get strange cases (for example when a generic
1326 -- instantiation is replaced by a normal package) where we
1327 -- read the old ali file, decide to recompile, and then decide
1328 -- that the old and new ali files are incompatible.
1333 -- If Err is not set, then this is a fatal error. This is
1334 -- the case of being called from the binder, where we must
1335 -- definitely diagnose this as an error.
1339 Write_Str ("error: duplicate unit name: ");
1342 Write_Str ("error: unit """);
1343 Write_Unit_Name (Units.Table (Units.Last).Uname);
1344 Write_Str (""" found in file """);
1345 Write_Name_Decoded (Units.Table (Units.Last).Sfile);
1349 Write_Str ("error
: unit
""");
1350 Write_Unit_Name (Units.Table (Unit_Id (Info)).Uname);
1351 Write_Str (""" found
in file
""");
1352 Write_Name_Decoded (Units.Table (Unit_Id (Info)).Sfile);
1356 Exit_Program (E_Fatal);
1362 (Units.Table (Units.Last).Uname, Int (Units.Last));
1364 -- Scan out possible version and other parameters
1373 if C in '0' .. '9' or else C in 'a
' .. 'f
' then
1374 Units.Table (Units.Last).Version (1) := C;
1376 for J in 2 .. 8 loop
1378 Units.Table (Units.Last).Version (J) := C;
1381 -- BN parameter (Body needed)
1387 Check_At_End_Of_Field;
1388 Units.Table (Units.Last).Body_Needed_For_SAL := True;
1393 -- DE parameter (Dynamic elaboration checks)
1399 Check_At_End_Of_Field;
1400 Units.Table (Units.Last).Dynamic_Elab := True;
1401 Dynamic_Elaboration_Checks_Specified := True;
1412 Units.Table (Units.Last).Elaborate_Body := True;
1414 Units.Table (Units.Last).Set_Elab_Entity := True;
1419 Check_At_End_Of_Field;
1421 -- GE parameter (generic)
1427 Check_At_End_Of_Field;
1428 Units.Table (Units.Last).Is_Generic := True;
1433 -- IL/IS/IU parameters
1439 Units.Table (Units.Last).Icasing := All_Lower_Case;
1441 Units.Table (Units.Last).Init_Scalars := True;
1442 Initialize_Scalars_Used := True;
1444 Units.Table (Units.Last).Icasing := All_Upper_Case;
1449 Check_At_End_Of_Field;
1457 Units.Table (Units.Last).Kcasing := Mixed_Case;
1459 Units.Table (Units.Last).Kcasing := All_Upper_Case;
1464 Check_At_End_Of_Field;
1472 Units.Table (Units.Last).No_Elab := True;
1473 Check_At_End_Of_Field;
1478 -- PR/PU/PK parameters
1484 Units.Table (Units.Last).Preelab := True;
1486 Units.Table (Units.Last).Pure := True;
1488 Units.Table (Units.Last).Unit_Kind := 'p
';
1493 Check_At_End_Of_Field;
1501 Units.Table (Units.Last).RCI := True;
1503 Units.Table (Units.Last).Remote_Types := True;
1505 Units.Table (Units.Last).Has_RACW := True;
1510 Check_At_End_Of_Field;
1516 Units.Table (Units.Last).Shared_Passive := True;
1518 Units.Table (Units.Last).Unit_Kind := 's
';
1523 Check_At_End_Of_Field;
1533 -- Check if static elaboration model used
1535 if not Units.Table (Units.Last).Dynamic_Elab
1536 and then not Units.Table (Units.Last).Internal
1538 Static_Elaboration_Model_Used := True;
1543 -- Scan out With lines for this unit
1547 exit With_Loop when C /= 'W
';
1549 if Ignore ('W
') then
1555 Withs.Increment_Last;
1556 Withs.Table (Withs.Last).Uname := Get_Name;
1557 Withs.Table (Withs.Last).Elaborate := False;
1558 Withs.Table (Withs.Last).Elaborate_All := False;
1559 Withs.Table (Withs.Last).Elab_Desirable := False;
1560 Withs.Table (Withs.Last).Elab_All_Desirable := False;
1561 Withs.Table (Withs.Last).SAL_Interface := False;
1563 -- Generic case with no object file available
1566 Withs.Table (Withs.Last).Sfile := No_File;
1567 Withs.Table (Withs.Last).Afile := No_File;
1572 Withs.Table (Withs.Last).Sfile := Get_Name (Lower => True);
1573 Withs.Table (Withs.Last).Afile := Get_Name;
1575 -- Scan out possible E, EA, ED, and AD parameters
1577 while not At_Eol loop
1583 Check_At_End_Of_Field;
1585 -- Store AD indication unless ignore required
1587 if not Ignore_ED then
1588 Withs.Table (Withs.Last).Elab_All_Desirable :=
1592 elsif Nextc = 'E
' then
1595 if At_End_Of_Field then
1596 Withs.Table (Withs.Last).Elaborate := True;
1598 elsif Nextc = 'A
' then
1600 Check_At_End_Of_Field;
1601 Withs.Table (Withs.Last).Elaborate_All := True;
1605 Check_At_End_Of_Field;
1607 -- Store ED indication unless ignore required
1609 if not Ignore_ED then
1610 Withs.Table (Withs.Last).Elab_Desirable :=
1624 Units.Table (Units.Last).Last_With := Withs.Last;
1625 Units.Table (Units.Last).Last_Arg := Args.Last;
1627 -- If there are linker options lines present, scan them
1631 Linker_Options_Loop : loop
1633 exit Linker_Options_Loop when C /= 'L
';
1635 if Ignore ('L
') then
1646 if C < Character'Val (16#20#)
1647 or else C > Character'Val (16#7E#)
1652 C := Character'Val (0);
1659 for J in 1 .. 2 loop
1662 if C in '0' .. '9' then
1665 Character'Pos ('0');
1667 elsif C in 'A' .. 'F' then
1670 Character'Pos ('A') +
1679 Add_Char_To_Name_Buffer (Character'Val (V));
1684 exit when Nextc /= '"';
1688 Add_Char_To_Name_Buffer (C);
1692 Add_Char_To_Name_Buffer (nul);
1697 end loop Linker_Options_Loop;
1699 -- Store the linker options entry if one was found
1701 if Name_Len /= 0 then
1702 Linker_Options.Increment_Last;
1704 Linker_Options.Table (Linker_Options.Last).Name :=
1707 Linker_Options.Table (Linker_Options.Last).Unit :=
1710 Linker_Options.Table (Linker_Options.Last).Internal_File :=
1711 Is_Internal_File_Name (F);
1713 Linker_Options.Table (Linker_Options.Last).Original_Pos :=
1714 Linker_Options.Last;
1718 -- End loop through units for one ALI file
1720 ALIs.Table (Id).Last_Unit := Units.Last;
1721 ALIs.Table (Id).Sfile := Units.Table (ALIs.Table (Id).First_Unit).Sfile;
1723 -- Set types of the units (there can be at most 2 of them)
1725 if ALIs.Table (Id).First_Unit /= ALIs.Table (Id).Last_Unit then
1726 Units.Table (ALIs.Table (Id).First_Unit).Utype := Is_Body;
1727 Units.Table (ALIs.Table (Id).Last_Unit).Utype := Is_Spec;
1730 -- Deal with body only and spec only cases, note that the reason we
1731 -- do our own checking of the name (rather than using Is_Body_Name)
1732 -- is that Uname drags in far too much compiler junk!
1734 Get_Name_String (Units.Table (Units.Last).Uname);
1736 if Name_Buffer (Name_Len) = 'b' then
1737 Units.Table (Units.Last).Utype := Is_Body_Only;
1739 Units.Table (Units.Last).Utype := Is_Spec_Only;
1743 -- Scan out external version references and put in hash table
1747 exit E_Loop when C /= 'E';
1749 if Ignore ('E') then
1765 exit when At_End_Of_Field;
1766 Add_Char_To_Name_Buffer (C);
1769 Version_Ref.Set (new String'(Name_Buffer (1 .. Name_Len)), True);
1776 -- Scan out source dependency lines for this ALI file
1778 ALIs.Table (Id).First_Sdep := Sdep.Last + 1;
1782 exit D_Loop when C /= 'D';
1784 if Ignore ('D') then
1790 Sdep.Increment_Last;
1791 Sdep.Table (Sdep.Last).Sfile := Get_Name (Lower => True);
1792 Sdep.Table (Sdep.Last).Stamp := Get_Stamp;
1793 Sdep.Table (Sdep.Last).Dummy_Entry :=
1794 (Sdep.Table (Sdep.Last).Stamp = Dummy_Time_Stamp);
1796 -- Acquire checksum value
1809 exit when At_Eol or else Ctr = 8;
1811 if Nextc in '0' .. '9' then
1813 Character'Pos (Nextc) - Character'Pos ('0');
1815 elsif Nextc in 'a' .. 'f' then
1817 Character'Pos (Nextc) - Character'Pos ('a') + 10;
1827 if Ctr = 8 and then At_End_Of_Field then
1828 Sdep.Table (Sdep.Last).Checksum := Chk;
1834 -- Acquire subunit and reference file name entries
1836 Sdep.Table (Sdep.Last).Subunit_Name := No_Name;
1837 Sdep.Table (Sdep.Last).Rfile :=
1838 Sdep.Table (Sdep.Last).Sfile;
1839 Sdep.Table (Sdep.Last).Start_Line := 1;
1844 -- Here for subunit name
1846 if Nextc not in '0' .. '9' then
1849 while not At_End_Of_Field loop
1850 Name_Len := Name_Len + 1;
1851 Name_Buffer (Name_Len) := Getc;
1854 Sdep.Table (Sdep.Last).Subunit_Name := Name_Enter;
1858 -- Here for reference file name entry
1860 if Nextc in '0' .. '9' then
1861 Sdep.Table (Sdep.Last).Start_Line := Get_Nat;
1866 while not At_End_Of_Field loop
1867 Name_Len := Name_Len + 1;
1868 Name_Buffer (Name_Len) := Getc;
1871 Sdep.Table (Sdep.Last).Rfile := Name_Enter;
1881 ALIs.Table (Id).Last_Sdep := Sdep.Last;
1883 -- We must at this stage be at an Xref line or the end of file
1895 -- If we are ignoring Xref sections we are done (we ignore all
1896 -- remaining lines since only xref related lines follow X).
1898 if Ignore ('X') and then not Debug_Flag_X then
1902 -- Loop through Xref sections
1906 exit X_Loop when C /= 'X';
1908 -- Make new entry in section table
1910 Xref_Section.Increment_Last;
1912 Read_Refs_For_One_File : declare
1913 XS : Xref_Section_Record renames
1914 Xref_Section.Table (Xref_Section.Last);
1916 Current_File_Num : Sdep_Id;
1917 -- Keeps track of the current file number (changed by nn|)
1920 XS.File_Num := Sdep_Id (Get_Nat + Nat (First_Sdep_Entry) - 1);
1921 XS.File_Name := Get_Name;
1922 XS.First_Entity := Xref_Entity.Last + 1;
1924 Current_File_Num := XS.File_Num;
1931 -- Loop through Xref entities
1933 while C /= 'X' and then C /= EOF loop
1934 Xref_Entity.Increment_Last;
1936 Read_Refs_For_One_Entity : declare
1937 XE : Xref_Entity_Record renames
1938 Xref_Entity.Table (Xref_Entity.Last);
1941 procedure Read_Instantiation_Reference;
1942 -- Acquire instantiation reference. Caller has checked
1943 -- that current character is '[' and on return the cursor
1944 -- is skipped past the corresponding closing ']'.
1946 ----------------------------------
1947 -- Read_Instantiation_Reference --
1948 ----------------------------------
1950 procedure Read_Instantiation_Reference is
1951 Local_File_Num : Sdep_Id := Current_File_Num;
1954 Xref.Increment_Last;
1957 XR : Xref_Record renames Xref.Table (Xref.Last);
1960 P := P + 1; -- skip [
1965 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
1966 Local_File_Num := XR.File_Num;
1971 XR.File_Num := Local_File_Num;
1978 -- Recursive call for next reference
1981 pragma Warnings (Off); -- kill recursion warning
1982 Read_Instantiation_Reference;
1983 pragma Warnings (On);
1986 -- Skip closing bracket after recursive call
1990 end Read_Instantiation_Reference;
1992 -- Start of processing for Read_Refs_For_One_Entity
1998 XE.Lib := (Getc = '*');
1999 XE.Entity := Get_Name;
2001 -- Handle the information about generic instantiations
2004 Skipc; -- Opening '['
2007 if Nextc /= '|' then
2008 XE.Iref_File_Num := Current_File_Num;
2012 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2014 XE.Iref_Line := Get_Nat;
2022 XE.Iref_File_Num := No_Sdep_Id;
2026 Current_File_Num := XS.File_Num;
2028 -- Renaming reference is present
2032 XE.Rref_Line := Get_Nat;
2038 XE.Rref_Col := Get_Nat;
2040 -- No renaming reference present
2049 -- See if type reference present
2052 (Current_File_Num, XE.Tref, XE.Tref_File_Num, XE.Tref_Line,
2053 XE.Tref_Type, XE.Tref_Col, XE.Tref_Standard_Entity);
2055 -- Do we have an overriding procedure, instead ?
2056 if XE.Tref_Type = 'p' then
2057 XE.Oref_File_Num := XE.Tref_File_Num;
2058 XE.Oref_Line := XE.Tref_Line;
2059 XE.Oref_Col := XE.Tref_Col;
2060 XE.Tref_File_Num := No_Sdep_Id;
2061 XE.Tref := Tref_None;
2063 -- We might have additional information about the
2064 -- overloaded subprograms
2068 Standard_Entity : Name_Id;
2072 Ref, XE.Oref_File_Num,
2073 XE.Oref_Line, Typ, XE.Oref_Col, Standard_Entity);
2077 XE.First_Xref := Xref.Last + 1;
2079 -- Loop through cross-references for this entity
2086 exit when Nextc /= '.';
2090 Xref.Increment_Last;
2093 XR : Xref_Record renames Xref.Table (Xref.Last);
2100 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2101 Current_File_Num := XR.File_Num;
2105 XR.File_Num := Current_File_Num;
2111 -- Imported entities reference as in:
2112 -- 494b<c,__gnat_copy_attribs>25
2113 -- ??? Simply skipped for now
2116 while Getc /= '>' loop
2124 Read_Instantiation_Reference;
2129 -- Record last cross-reference
2131 XE.Last_Xref := Xref.Last;
2133 end Read_Refs_For_One_Entity;
2136 -- Record last entity
2138 XS.Last_Entity := Xref_Entity.Last;
2140 end Read_Refs_For_One_File;
2145 -- Here after dealing with xref sections
2147 if C /= EOF and then C /= 'X' then
2154 when Bad_ALI_Format =>
2163 function SEq (F1, F2 : String_Ptr) return Boolean is
2165 return F1.all = F2.all;
2172 function SHash (S : String_Ptr) return Vindex is
2177 for J in S.all'Range loop
2178 H := H * 2 + Character'Pos (S (J));
2181 return Vindex (Vindex'First + Vindex (H mod Vindex'Range_Length));