1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2012, 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
58 'Z' => True, -- implicit with from instantiation
59 'C' => True, -- SCO information
60 'F' => True, -- Alfa information
67 procedure Initialize_ALI
is
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);
78 for J
in Units
.First
.. Units
.Last
loop
79 Set_Name_Table_Info
(Units
.Table
(J
).Uname
, 0);
82 -- Free argument table strings
84 for J
in Args
.First
.. Args
.Last
loop
85 Free
(Args
.Table
(J
));
88 -- Initialize all tables
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 Float_Format_Specified
:= ' ';
112 Locking_Policy_Specified
:= ' ';
113 No_Normalize_Scalars_Specified
:= False;
114 No_Object_Specified
:= False;
115 Normalize_Scalars_Specified
:= False;
116 Queuing_Policy_Specified
:= ' ';
117 Static_Elaboration_Model_Used
:= False;
118 Task_Dispatching_Policy_Specified
:= ' ';
119 Unreserve_All_Interrupts_Specified
:= False;
120 Zero_Cost_Exceptions_Specified
:= False;
132 Read_Xref
: Boolean := False;
133 Read_Lines
: String := "";
134 Ignore_Lines
: String := "X";
135 Ignore_Errors
: Boolean := False;
136 Directly_Scanned
: Boolean := False) return ALI_Id
138 P
: Text_Ptr
:= T
'First;
139 Line
: Logical_Line_Number
:= 1;
145 Ignore
: array (Character range 'A' .. 'Z') of Boolean;
146 -- Ignore (X) is set to True if lines starting with X are to
147 -- be ignored by Scan_ALI and skipped, and False if the lines
148 -- are to be read and processed.
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
188 function Get_File_Name
(Lower
: Boolean := False) return File_Name_Type
;
189 -- Skip blanks, then scan out a file name (name is left in Name_Buffer
190 -- with length in Name_Len, as well as returning a File_Name_Type value.
191 -- If lower is false, the case is unchanged, if Lower is True then the
192 -- result is forced to all lower case for systems where file names are
193 -- not case sensitive. This ensures that gnatbind works correctly
194 -- regardless of the case of the file name on all systems. The scan
195 -- is terminated by a end of line, space or horizontal tab. Any other
196 -- special characters are included in the returned name.
199 (Ignore_Spaces
: Boolean := False;
200 Ignore_Special
: Boolean := False) return Name_Id
;
201 -- Skip blanks, then scan out a name (name is left in Name_Buffer with
202 -- length in Name_Len, as well as being returned in Name_Id form).
203 -- If Lower is set to True then the Name_Buffer will be converted to
204 -- all lower case, for systems where file names are not case sensitive.
205 -- This ensures that gnatbind works correctly regardless of the case
206 -- of the file name on all systems. The termination condition depends
207 -- on the settings of Ignore_Spaces and Ignore_Special:
209 -- If Ignore_Spaces is False (normal case), then scan is terminated
210 -- by the normal end of field condition (EOL, space, horizontal tab)
212 -- If Ignore_Special is False (normal case), the scan is terminated by
213 -- a typeref bracket or an equal sign except for the special case of
214 -- an operator name starting with a double quote which is terminated
215 -- by another double quote.
217 -- It is an error to set both Ignore_Spaces and Ignore_Special to True.
218 -- This function handles wide characters properly.
220 function Get_Nat
return Nat
;
221 -- Skip blanks, then scan out an unsigned integer value in Nat range
222 -- raises ALI_Reading_Error if the encoutered type is not natural.
224 function Get_Stamp
return Time_Stamp_Type
;
225 -- Skip blanks, then scan out a time stamp
227 function Get_Unit_Name
return Unit_Name_Type
;
228 -- Skip blanks, then scan out a file name (name is left in Name_Buffer
229 -- with length in Name_Len, as well as returning a Unit_Name_Type value.
230 -- The case is unchanged and terminated by a normal end of field.
232 function Nextc
return Character;
233 -- Return current character without modifying pointer P
235 procedure Get_Typeref
236 (Current_File_Num
: Sdep_Id
;
238 File_Num
: out Sdep_Id
;
240 Ref_Type
: out Character;
242 Standard_Entity
: out Name_Id
);
243 -- Parse the definition of a typeref (<...>, {...} or (...))
246 -- Skip past spaces, then skip past end of line (fatal error if not
247 -- at end of line). Also skips past any following blank lines.
250 -- Skip rest of current line and any following blank lines
252 procedure Skip_Space
;
253 -- Skip past white space (blanks or horizontal tab)
256 -- Skip past next character, does not affect value in C. This call
257 -- is like calling Getc and ignoring the returned result.
259 ---------------------
260 -- At_End_Of_Field --
261 ---------------------
263 function At_End_Of_Field
return Boolean is
272 function At_Eol
return Boolean is
274 return Nextc
= EOF
or else Nextc
= CR
or else Nextc
= LF
;
277 ---------------------------
278 -- Check_At_End_Of_Field --
279 ---------------------------
281 procedure Check_At_End_Of_Field
is
283 if not At_End_Of_Field
then
284 if Ignore_Errors
then
285 while Nextc
> ' ' loop
292 end Check_At_End_Of_Field
;
294 ------------------------
295 -- Check_Unknown_Line --
296 ------------------------
298 procedure Check_Unknown_Line
is
300 while C
not in 'A' .. 'Z'
301 or else not Known_ALI_Lines
(C
)
303 if C
= CR
or else C
= LF
then
310 elsif Ignore_Errors
then
318 end Check_Unknown_Line
;
324 procedure Checkc
(C
: Character) is
328 elsif Ignore_Errors
then
339 procedure Fatal_Error
is
344 procedure Wchar
(C
: Character);
345 -- Write a single character, replacing horizontal tab by spaces
347 procedure Wchar
(C
: Character) is
352 exit when Col
mod 8 = 0;
361 -- Start of processing for Fatal_Error
365 raise Bad_ALI_Format
;
369 Write_Str
("fatal error: file ");
371 Write_Str
(" is incorrectly formatted");
374 Write_Str
("make sure you are using consistent versions " &
376 -- Split the following line so that it can easily be transformed for
377 -- e.g. JVM/.NET back-ends where the compiler has a different name.
383 -- Find start of line
387 and then T
(Ptr1
- 1) /= CR
388 and then T
(Ptr1
- 1) /= LF
393 Write_Int
(Int
(Line
));
408 and then T
(Ptr2
) /= CR
409 and then T
(Ptr2
) /= LF
421 if T
(Ptr1
) = HT
then
433 Exit_Program
(E_Fatal
);
436 ------------------------
437 -- Fatal_Error_Ignore --
438 ------------------------
440 procedure Fatal_Error_Ignore
is
442 if not Ignore_Errors
then
445 end Fatal_Error_Ignore
;
451 function Get_File_Name
452 (Lower
: Boolean := False) return File_Name_Type
457 F
:= Get_Name
(Ignore_Special
=> True);
459 -- Convert file name to all lower case if file names are not case
460 -- sensitive. This ensures that we handle names in the canonical
461 -- lower case format, regardless of the actual case.
463 if Lower
and not File_Names_Case_Sensitive
then
464 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
467 return File_Name_Type
(F
);
476 (Ignore_Spaces
: Boolean := False;
477 Ignore_Special
: Boolean := False) return Name_Id
484 if Ignore_Errors
then
492 Add_Char_To_Name_Buffer
(Getc
);
494 exit when At_End_Of_Field
and then not Ignore_Spaces
;
496 if not Ignore_Special
then
497 if Name_Buffer
(1) = '"' then
498 exit when Name_Len
> 1 and then Name_Buffer
(Name_Len
) = '"';
501 -- Terminate on parens or angle brackets or equal sign
503 exit when Nextc
= '(' or else Nextc
= ')'
504 or else Nextc
= '{' or else Nextc
= '}'
505 or else Nextc
= '<' or else Nextc
= '>'
508 -- Terminate on comma
510 exit when Nextc
= ',';
512 -- Terminate if left bracket not part of wide char sequence
513 -- Note that we only recognize brackets notation so far ???
515 exit when Nextc
= '[' and then T
(P
+ 1) /= '"';
517 -- Terminate if right bracket not part of wide char sequence
519 exit when Nextc
= ']' and then T
(P
- 1) /= '"';
531 function Get_Unit_Name
return Unit_Name_Type
is
533 return Unit_Name_Type
(Get_Name
);
540 function Get_Nat
return Nat
is
546 -- Check if we are on a number. In the case of bad ALI files, this
549 if not (Nextc
in '0' .. '9') then
555 V
:= V
* 10 + (Character'Pos (Getc
) - Character'Pos ('0'));
557 exit when At_End_Of_Field
;
558 exit when Nextc
< '0' or else Nextc
> '9';
568 function Get_Stamp
return Time_Stamp_Type
is
576 if Ignore_Errors
then
577 return Dummy_Time_Stamp
;
583 -- Following reads old style time stamp missing first two digits
585 if Nextc
in '7' .. '9' then
590 -- Normal case of full year in time stamp
596 for J
in Start
.. T
'Last loop
607 procedure Get_Typeref
608 (Current_File_Num
: Sdep_Id
;
610 File_Num
: out Sdep_Id
;
612 Ref_Type
: out Character;
614 Standard_Entity
: out Name_Id
)
619 when '<' => Ref
:= Tref_Derived
;
620 when '(' => Ref
:= Tref_Access
;
621 when '{' => Ref
:= Tref_Type
;
622 when others => Ref
:= Tref_None
;
625 -- Case of typeref field present
627 if Ref
/= Tref_None
then
628 P
:= P
+ 1; -- skip opening bracket
630 if Nextc
in 'a' .. 'z' then
631 File_Num
:= No_Sdep_Id
;
635 Standard_Entity
:= Get_Name
(Ignore_Spaces
=> True);
640 File_Num
:= Sdep_Id
(N
+ Nat
(First_Sdep_Entry
) - 1);
644 File_Num
:= Current_File_Num
;
650 Standard_Entity
:= No_Name
;
653 -- ??? Temporary workaround for nested generics case:
654 -- 4i4 Directories{1|4I9[4|6[3|3]]}
658 Nested_Brackets
: Natural := 0;
664 Nested_Brackets
:= Nested_Brackets
+ 1;
666 Nested_Brackets
:= Nested_Brackets
- 1;
668 if Nested_Brackets
= 0 then
677 P
:= P
+ 1; -- skip closing bracket
680 -- No typeref entry present
683 File_Num
:= No_Sdep_Id
;
687 Standard_Entity
:= No_Name
;
695 function Getc
return Character is
709 function Nextc
return Character is
718 procedure Skip_Eol
is
723 if Ignore_Errors
then
724 while not At_Eol
loop
732 -- Loop to skip past blank lines (first time through skips this EOL)
734 while Nextc
< ' ' and then Nextc
/= EOF
loop
747 procedure Skip_Line
is
749 while not At_Eol
loop
760 procedure Skip_Space
is
762 while Nextc
= ' ' or else Nextc
= HT
loop
778 -- Start of processing for Scan_ALI
781 First_Sdep_Entry
:= Sdep
.Last
+ 1;
783 -- Acquire lines to be ignored
787 ('U' |
'W' |
'Y' |
'Z' |
'D' |
'X' => False, others => True);
789 -- Read_Lines parameter given
791 elsif Read_Lines
/= "" then
792 Ignore
:= ('U' => False, others => True);
794 for J
in Read_Lines
'Range loop
795 Ignore
(Read_Lines
(J
)) := False;
798 -- Process Ignore_Lines parameter
801 Ignore
:= (others => False);
803 for J
in Ignore_Lines
'Range loop
804 pragma Assert
(Ignore_Lines
(J
) /= 'U');
805 Ignore
(Ignore_Lines
(J
)) := True;
809 -- Setup ALI Table entry with appropriate defaults
813 Set_Name_Table_Info
(F
, Int
(Id
));
817 Compile_Errors
=> False,
818 First_Interrupt_State
=> Interrupt_States
.Last
+ 1,
819 First_Sdep
=> No_Sdep_Id
,
820 First_Specific_Dispatching
=> Specific_Dispatching
.Last
+ 1,
821 First_Unit
=> No_Unit_Id
,
823 Last_Interrupt_State
=> Interrupt_States
.Last
,
824 Last_Sdep
=> No_Sdep_Id
,
825 Last_Specific_Dispatching
=> Specific_Dispatching
.Last
,
826 Last_Unit
=> No_Unit_Id
,
827 Locking_Policy
=> ' ',
830 Main_Program
=> None
,
832 Normalize_Scalars
=> False,
833 Ofile_Full_Name
=> Full_Object_File_Name
,
834 Queuing_Policy
=> ' ',
835 Restrictions
=> No_Restrictions
,
836 SAL_Interface
=> False,
838 Task_Dispatching_Policy
=> ' ',
839 Time_Slice_Value
=> -1,
840 Allocator_In_Body
=> False,
842 Unit_Exception_Table
=> False,
843 Ver
=> (others => ' '),
845 Zero_Cost_Exceptions
=> False);
847 -- Now we acquire the input lines from the ALI file. Note that the
848 -- convention in the following code is that as we enter each section,
849 -- C is set to contain the first character of the following line.
854 -- Acquire library version
858 -- The V line missing really indicates trouble, most likely it
859 -- means we don't have an ALI file at all, so here we give a
860 -- fatal error even if we are in Ignore_Errors mode.
864 elsif Ignore
('V') then
872 for J
in 1 .. Ver_Len_Max
loop
875 ALIs
.Table
(Id
).Ver
(J
) := C
;
876 ALIs
.Table
(Id
).Ver_Len
:= J
;
885 -- Acquire main program line if present
898 ALIs
.Table
(Id
).Main_Program
:= Func
;
900 ALIs
.Table
(Id
).Main_Program
:= Proc
;
910 ALIs
.Table
(Id
).Main_Priority
:= Get_Nat
;
918 ALIs
.Table
(Id
).Time_Slice_Value
:= Get_Nat
;
926 ALIs
.Table
(Id
).Allocator_In_Body
:= True;
934 ALIs
.Table
(Id
).Main_CPU
:= Get_Nat
;
941 ALIs
.Table
(Id
).WC_Encoding
:= Getc
;
950 -- Acquire argument lines
952 First_Arg
:= Args
.Last
+ 1;
956 exit A_Loop
when C
/= 'A';
967 while not At_Eol
loop
968 Add_Char_To_Name_Buffer
(Getc
);
971 -- If -fstack-check, record that it occurred
973 if Name_Buffer
(1 .. Name_Len
) = "-fstack-check" then
974 Stack_Check_Switch_Set
:= True;
977 -- Store the argument
980 Args
.Table
(Args
.Last
) := new String'(Name_Buffer (1 .. Name_Len));
993 if Ignore_Errors then
1005 if Ignore ('P
') then
1013 while not At_Eol loop
1018 -- Processing for CE
1022 ALIs.Table (Id).Compile_Errors := True;
1024 -- Processing for DB
1028 Detect_Blocking := True;
1030 -- Processing for FD/FG/FI
1033 Float_Format_Specified := Getc;
1034 ALIs.Table (Id).Float_Format := Float_Format_Specified;
1036 -- Processing for Lx
1039 Locking_Policy_Specified := Getc;
1040 ALIs.Table (Id).Locking_Policy := Locking_Policy_Specified;
1042 -- Processing for flags starting with N
1047 -- Processing for NO
1050 ALIs.Table (Id).No_Object := True;
1051 No_Object_Specified := True;
1053 -- Processing for NR
1056 No_Run_Time_Mode := True;
1057 Configurable_Run_Time_Mode := True;
1059 -- Processing for NS
1062 ALIs.Table (Id).Normalize_Scalars := True;
1063 Normalize_Scalars_Specified := True;
1066 -- Invalid switch starting with N
1072 -- Processing for Qx
1075 Queuing_Policy_Specified := Getc;
1076 ALIs.Table (Id).Queuing_Policy := Queuing_Policy_Specified;
1078 -- Processing for flags starting with S
1083 -- Processing for SL
1086 ALIs.Table (Id).SAL_Interface := True;
1088 -- Processing for SS
1091 Opt.Sec_Stack_Used := True;
1093 -- Invalid switch starting with S
1099 -- Processing for Tx
1102 Task_Dispatching_Policy_Specified := Getc;
1103 ALIs.Table (Id).Task_Dispatching_Policy :=
1104 Task_Dispatching_Policy_Specified;
1106 -- Processing for switch starting with U
1111 -- Processing for UA
1114 Unreserve_All_Interrupts_Specified := True;
1116 -- Processing for UX
1119 ALIs.Table (Id).Unit_Exception_Table := True;
1121 -- Invalid switches starting with U
1127 -- Processing for ZX
1133 ALIs.Table (Id).Zero_Cost_Exceptions := True;
1134 Zero_Cost_Exceptions_Specified := True;
1139 -- Invalid parameter
1147 if not NS_Found then
1148 No_Normalize_Scalars_Specified := True;
1157 -- Loop to skip to first restrictions line
1160 if Ignore_Errors then
1172 -- Ignore all 'R
' lines if that is required
1174 if Ignore ('R
') then
1180 -- Here we process the restrictions lines (other than unit name cases)
1183 Scan_Restrictions : declare
1184 Save_R : constant Restrictions_Info := Cumulative_Restrictions;
1185 -- Save cumulative restrictions in case we have a fatal error
1187 Bad_R_Line : exception;
1188 -- Signal bad restrictions line (raised on unexpected character)
1195 -- Named restriction case
1201 -- Loop through RR and RV lines
1203 while C = 'R
' and then Nextc /= ' ' loop
1207 -- Acquire restriction name
1210 while not At_Eol and then Nextc /= '=' loop
1211 Name_Len := Name_Len + 1;
1212 Name_Buffer (Name_Len) := Getc;
1215 -- Now search list of restrictions to find match
1218 RN : String renames Name_Buffer (1 .. Name_Len);
1221 R := Restriction_Id'First;
1222 while R < Not_A_Restriction_Id loop
1223 if Restriction_Id'Image (R) = RN then
1227 R := Restriction_Id'Succ (R);
1230 -- We don't recognize the restriction. This might be
1231 -- thought of as an error, and it really is, but we
1232 -- want to allow building with inconsistent versions
1233 -- of the binder and ali files (see comments at the
1234 -- start of package System.Rident), so we just ignore
1237 goto Done_With_Restriction_Line;
1244 -- Boolean restriction case
1246 when All_Boolean_Restrictions =>
1249 ALIs.Table (Id).Restrictions.Violated (R) :=
1251 Cumulative_Restrictions.Violated (R) := True;
1254 ALIs.Table (Id).Restrictions.Set (R) := True;
1255 Cumulative_Restrictions.Set (R) := True;
1261 -- Parameter restriction case
1263 when All_Parameter_Restrictions =>
1264 if At_Eol or else Nextc /= '=' then
1270 N := Natural (Get_Nat);
1277 ALIs.Table (Id).Restrictions.Set (R) := True;
1278 ALIs.Table (Id).Restrictions.Value (R) := N;
1280 if Cumulative_Restrictions.Set (R) then
1281 Cumulative_Restrictions.Value (R) :=
1283 (Cumulative_Restrictions.Value (R), N);
1285 Cumulative_Restrictions.Set (R) := True;
1286 Cumulative_Restrictions.Value (R) := N;
1289 -- Restriction violated
1292 ALIs.Table (Id).Restrictions.Violated (R) :=
1294 Cumulative_Restrictions.Violated (R) := True;
1295 ALIs.Table (Id).Restrictions.Count (R) := N;
1297 -- Checked Max_Parameter case
1299 if R in Checked_Max_Parameter_Restrictions then
1300 Cumulative_Restrictions.Count (R) :=
1302 (Cumulative_Restrictions.Count (R), N);
1304 -- Other checked parameter cases
1308 pragma Unsuppress (Overflow_Check);
1311 Cumulative_Restrictions.Count (R) :=
1312 Cumulative_Restrictions.Count (R) + N;
1315 when Constraint_Error =>
1317 -- A constraint error comes from the
1318 -- additionh. We reset to the maximum
1319 -- and indicate that the real value is
1322 Cumulative_Restrictions.Value (R) :=
1324 Cumulative_Restrictions.Unknown (R) :=
1333 ALIs.Table (Id).Restrictions.Unknown (R) :=
1335 Cumulative_Restrictions.Unknown (R) := True;
1338 -- Other than 'R
' or 'V
'
1348 -- Bizarre error case NOT_A_RESTRICTION
1350 when Not_A_Restriction_Id =>
1358 <<Done_With_Restriction_Line>>
1363 -- Positional restriction case
1369 -- Acquire information for boolean restrictions
1371 for R in All_Boolean_Restrictions loop
1376 ALIs.Table (Id).Restrictions.Violated (R) := True;
1377 Cumulative_Restrictions.Violated (R) := True;
1380 ALIs.Table (Id).Restrictions.Set (R) := True;
1381 Cumulative_Restrictions.Set (R) := True;
1391 -- Acquire information for parameter restrictions
1393 for RP in All_Parameter_Restrictions loop
1399 ALIs.Table (Id).Restrictions.Set (RP) := True;
1402 N : constant Integer := Integer (Get_Nat);
1404 ALIs.Table (Id).Restrictions.Value (RP) := N;
1406 if Cumulative_Restrictions.Set (RP) then
1407 Cumulative_Restrictions.Value (RP) :=
1409 (Cumulative_Restrictions.Value (RP), N);
1411 Cumulative_Restrictions.Set (RP) := True;
1412 Cumulative_Restrictions.Value (RP) := N;
1420 -- Acquire restrictions violations information
1428 ALIs.Table (Id).Restrictions.Violated (RP) := True;
1429 Cumulative_Restrictions.Violated (RP) := True;
1432 N : constant Integer := Integer (Get_Nat);
1435 ALIs.Table (Id).Restrictions.Count (RP) := N;
1437 if RP in Checked_Max_Parameter_Restrictions then
1438 Cumulative_Restrictions.Count (RP) :=
1440 (Cumulative_Restrictions.Count (RP), N);
1444 pragma Unsuppress (Overflow_Check);
1447 Cumulative_Restrictions.Count (RP) :=
1448 Cumulative_Restrictions.Count (RP) + N;
1451 when Constraint_Error =>
1453 -- A constraint error comes from the add. We
1454 -- reset to the maximum and indicate that the
1455 -- real value is now unknown.
1457 Cumulative_Restrictions.Value (RP) :=
1459 Cumulative_Restrictions.Unknown (RP) := True;
1465 ALIs.Table (Id).Restrictions.Unknown (RP) := True;
1466 Cumulative_Restrictions.Unknown (RP) := True;
1483 -- Here if error during scanning of restrictions line
1488 -- In Ignore_Errors mode, undo any changes to restrictions
1489 -- from this unit, and continue on, skipping remaining R
1490 -- lines for this unit.
1492 if Ignore_Errors then
1493 Cumulative_Restrictions := Save_R;
1494 ALIs.Table (Id).Restrictions := No_Restrictions;
1502 -- In normal mode, this is a fatal error
1507 end Scan_Restrictions;
1510 -- Acquire additional restrictions (No_Dependence) lines if present
1513 if Ignore ('R
') then
1517 No_Deps.Append ((Id, Get_Name));
1524 -- Acquire 'I
' lines if present
1529 if Ignore ('I
') then
1535 I_State : Character;
1544 Interrupt_States.Append (
1545 (Interrupt_Id => Int_Num,
1546 Interrupt_State => I_State,
1547 IS_Pragma_Line => Line_No));
1549 ALIs.Table (Id).Last_Interrupt_State := Interrupt_States.Last;
1557 -- Acquire 'S
' lines if present
1562 if Ignore ('S
') then
1578 First_Prio := Get_Nat;
1579 Last_Prio := Get_Nat;
1582 Specific_Dispatching.Append (
1583 (Dispatching_Policy => Policy,
1584 First_Priority => First_Prio,
1585 Last_Priority => Last_Prio,
1586 PSD_Pragma_Line => Line_No));
1588 ALIs.Table (Id).Last_Specific_Dispatching :=
1589 Specific_Dispatching.Last;
1598 -- Loop to acquire unit entries
1602 exit U_Loop when C /= 'U
';
1604 -- Note: as per spec, we never ignore U lines
1608 Units.Increment_Last;
1610 if ALIs.Table (Id).First_Unit = No_Unit_Id then
1611 ALIs.Table (Id).First_Unit := Units.Last;
1615 UL : Unit_Record renames Units.Table (Units.Last);
1618 UL.Uname := Get_Unit_Name;
1619 UL.Predefined := Is_Predefined_Unit;
1620 UL.Internal := Is_Internal_Unit;
1622 UL.Sfile := Get_File_Name (Lower => True);
1624 UL.Preelab := False;
1625 UL.No_Elab := False;
1626 UL.Shared_Passive := False;
1628 UL.Remote_Types := False;
1629 UL.Has_RACW := False;
1630 UL.Init_Scalars := False;
1631 UL.Is_Generic := False;
1632 UL.Icasing := Mixed_Case;
1633 UL.Kcasing := All_Lower_Case;
1634 UL.Dynamic_Elab := False;
1635 UL.Elaborate_Body := False;
1636 UL.Set_Elab_Entity := False;
1637 UL.Version := "00000000";
1638 UL.First_With := Withs.Last + 1;
1639 UL.First_Arg := First_Arg;
1640 UL.Elab_Position := 0;
1641 UL.SAL_Interface := ALIs.Table (Id).SAL_Interface;
1642 UL.Directly_Scanned := Directly_Scanned;
1643 UL.Body_Needed_For_SAL := False;
1644 UL.Elaborate_Body_Desirable := False;
1645 UL.Optimize_Alignment := 'O
';
1646 UL.Has_Finalizer := False;
1648 if Debug_Flag_U then
1649 Write_Str (" ----> reading unit ");
1650 Write_Int (Int (Units.Last));
1652 Write_Unit_Name (UL.Uname);
1653 Write_Str (" from file ");
1654 Write_Name (UL.Sfile);
1659 -- Check for duplicated unit in different files
1662 Info : constant Int := Get_Name_Table_Info
1663 (Units.Table (Units.Last).Uname);
1666 and then Units.Table (Units.Last).Sfile /=
1667 Units.Table (Unit_Id (Info)).Sfile
1669 -- If Err is set then ignore duplicate unit name. This is the
1670 -- case of a call from gnatmake, where the situation can arise
1671 -- from substitution of source files. In such situations, the
1672 -- processing in gnatmake will always result in any required
1673 -- recompilations in any case, and if we consider this to be
1674 -- an error we get strange cases (for example when a generic
1675 -- instantiation is replaced by a normal package) where we
1676 -- read the old ali file, decide to recompile, and then decide
1677 -- that the old and new ali files are incompatible.
1682 -- If Err is not set, then this is a fatal error. This is
1683 -- the case of being called from the binder, where we must
1684 -- definitely diagnose this as an error.
1688 Write_Str ("error: duplicate unit name: ");
1691 Write_Str ("error: unit """);
1692 Write_Unit_Name (Units.Table (Units.Last).Uname);
1693 Write_Str (""" found in file """);
1694 Write_Name_Decoded (Units.Table (Units.Last).Sfile);
1698 Write_Str ("error
: unit
""");
1699 Write_Unit_Name (Units.Table (Unit_Id (Info)).Uname);
1700 Write_Str (""" found
in file
""");
1701 Write_Name_Decoded (Units.Table (Unit_Id (Info)).Sfile);
1705 Exit_Program (E_Fatal);
1711 (Units.Table (Units.Last).Uname, Int (Units.Last));
1713 -- Scan out possible version and other parameters
1722 if C in '0' .. '9' or else C in 'a
' .. 'f
' then
1723 Units.Table (Units.Last).Version (1) := C;
1725 for J in 2 .. 8 loop
1727 Units.Table (Units.Last).Version (J) := C;
1736 Check_At_End_Of_Field;
1737 Units.Table (Units.Last).Elaborate_Body_Desirable := True;
1740 Check_At_End_Of_Field;
1741 Units.Table (Units.Last).Body_Needed_For_SAL := True;
1747 -- DE parameter (Dynamic elaboration checks)
1753 Check_At_End_Of_Field;
1754 Units.Table (Units.Last).Dynamic_Elab := True;
1755 Dynamic_Elaboration_Checks_Specified := True;
1766 Units.Table (Units.Last).Elaborate_Body := True;
1768 Units.Table (Units.Last).Set_Elab_Entity := True;
1773 Check_At_End_Of_Field;
1775 -- GE parameter (generic)
1781 Check_At_End_Of_Field;
1782 Units.Table (Units.Last).Is_Generic := True;
1787 -- IL/IS/IU parameters
1793 Units.Table (Units.Last).Icasing := All_Lower_Case;
1795 Units.Table (Units.Last).Init_Scalars := True;
1796 Initialize_Scalars_Used := True;
1798 Units.Table (Units.Last).Icasing := All_Upper_Case;
1803 Check_At_End_Of_Field;
1811 Units.Table (Units.Last).Kcasing := Mixed_Case;
1813 Units.Table (Units.Last).Kcasing := All_Upper_Case;
1818 Check_At_End_Of_Field;
1826 Units.Table (Units.Last).No_Elab := True;
1827 Check_At_End_Of_Field;
1832 -- PF/PR/PU/PK parameters
1838 Units.Table (Units.Last).Has_Finalizer := True;
1840 Units.Table (Units.Last).Preelab := True;
1842 Units.Table (Units.Last).Pure := True;
1844 Units.Table (Units.Last).Unit_Kind := 'p
';
1849 Check_At_End_Of_Field;
1851 -- OL/OO/OS/OT parameters
1856 if C = 'L
' or else C = 'O
' or else C = 'S
' or else C = 'T
' then
1857 Units.Table (Units.Last).Optimize_Alignment := C;
1862 Check_At_End_Of_Field;
1870 Units.Table (Units.Last).RCI := True;
1872 Units.Table (Units.Last).Remote_Types := True;
1874 Units.Table (Units.Last).Has_RACW := True;
1879 Check_At_End_Of_Field;
1885 Units.Table (Units.Last).Shared_Passive := True;
1887 Units.Table (Units.Last).Unit_Kind := 's
';
1892 Check_At_End_Of_Field;
1902 -- Check if static elaboration model used
1904 if not Units.Table (Units.Last).Dynamic_Elab
1905 and then not Units.Table (Units.Last).Internal
1907 Static_Elaboration_Model_Used := True;
1912 -- Scan out With lines for this unit
1916 exit With_Loop when C /= 'W
' and then C /= 'Y
' and then C /= 'Z
';
1918 if Ignore ('W
') then
1924 Withs.Increment_Last;
1925 Withs.Table (Withs.Last).Uname := Get_Unit_Name;
1926 Withs.Table (Withs.Last).Elaborate := False;
1927 Withs.Table (Withs.Last).Elaborate_All := False;
1928 Withs.Table (Withs.Last).Elab_Desirable := False;
1929 Withs.Table (Withs.Last).Elab_All_Desirable := False;
1930 Withs.Table (Withs.Last).SAL_Interface := False;
1931 Withs.Table (Withs.Last).Limited_With := (C = 'Y
');
1932 Withs.Table (Withs.Last).Implicit_With_From_Instantiation
1935 -- Generic case with no object file available
1938 Withs.Table (Withs.Last).Sfile := No_File;
1939 Withs.Table (Withs.Last).Afile := No_File;
1944 Withs.Table (Withs.Last).Sfile := Get_File_Name
1946 Withs.Table (Withs.Last).Afile := Get_File_Name
1949 -- Scan out possible E, EA, ED, and AD parameters
1951 while not At_Eol loop
1957 Check_At_End_Of_Field;
1959 -- Store AD indication unless ignore required
1961 if not Ignore_ED then
1962 Withs.Table (Withs.Last).Elab_All_Desirable :=
1966 elsif Nextc = 'E
' then
1969 if At_End_Of_Field then
1970 Withs.Table (Withs.Last).Elaborate := True;
1972 elsif Nextc = 'A
' then
1974 Check_At_End_Of_Field;
1975 Withs.Table (Withs.Last).Elaborate_All := True;
1979 Check_At_End_Of_Field;
1981 -- Store ED indication unless ignore required
1983 if not Ignore_ED then
1984 Withs.Table (Withs.Last).Elab_Desirable :=
2001 Units.Table (Units.Last).Last_With := Withs.Last;
2002 Units.Table (Units.Last).Last_Arg := Args.Last;
2004 -- If there are linker options lines present, scan them
2008 Linker_Options_Loop : loop
2010 exit Linker_Options_Loop when C /= 'L
';
2012 if Ignore ('L
') then
2023 if C < Character'Val (16#20#)
2024 or else C > Character'Val (16#7E#)
2029 C := Character'Val (0);
2036 for J in 1 .. 2 loop
2039 if C in '0' .. '9' then
2042 Character'Pos ('0');
2044 elsif C in 'A' .. 'F' then
2047 Character'Pos ('A') +
2056 Add_Char_To_Name_Buffer (Character'Val (V));
2061 exit when Nextc /= '"';
2065 Add_Char_To_Name_Buffer (C);
2069 Add_Char_To_Name_Buffer (NUL);
2074 end loop Linker_Options_Loop;
2076 -- Store the linker options entry if one was found
2078 if Name_Len /= 0 then
2079 Linker_Options.Increment_Last;
2081 Linker_Options.Table (Linker_Options.Last).Name :=
2084 Linker_Options.Table (Linker_Options.Last).Unit :=
2087 Linker_Options.Table (Linker_Options.Last).Internal_File :=
2088 Is_Internal_File_Name (F);
2090 Linker_Options.Table (Linker_Options.Last).Original_Pos :=
2091 Linker_Options.Last;
2094 -- If there are notes present, scan them
2098 exit Notes_Loop when C /= 'N';
2100 if Ignore ('N') then
2106 Notes.Increment_Last;
2107 Notes.Table (Notes.Last).Pragma_Type := Getc;
2108 Notes.Table (Notes.Last).Pragma_Line := Get_Nat;
2110 Notes.Table (Notes.Last).Pragma_Col := Get_Nat;
2111 Notes.Table (Notes.Last).Unit := Units.Last;
2114 Notes.Table (Notes.Last).Pragma_Args := No_Name;
2120 while not At_Eol loop
2121 Add_Char_To_Name_Buffer (Getc);
2124 Notes.Table (Notes.Last).Pragma_Args := Name_Enter;
2131 end loop Notes_Loop;
2134 -- End loop through units for one ALI file
2136 ALIs.Table (Id).Last_Unit := Units.Last;
2137 ALIs.Table (Id).Sfile := Units.Table (ALIs.Table (Id).First_Unit).Sfile;
2139 -- Set types of the units (there can be at most 2 of them)
2141 if ALIs.Table (Id).First_Unit /= ALIs.Table (Id).Last_Unit then
2142 Units.Table (ALIs.Table (Id).First_Unit).Utype := Is_Body;
2143 Units.Table (ALIs.Table (Id).Last_Unit).Utype := Is_Spec;
2146 -- Deal with body only and spec only cases, note that the reason we
2147 -- do our own checking of the name (rather than using Is_Body_Name)
2148 -- is that Uname drags in far too much compiler junk!
2150 Get_Name_String (Units.Table (Units.Last).Uname);
2152 if Name_Buffer (Name_Len) = 'b' then
2153 Units.Table (Units.Last).Utype := Is_Body_Only;
2155 Units.Table (Units.Last).Utype := Is_Spec_Only;
2159 -- Scan out external version references and put in hash table
2163 exit E_Loop when C /= 'E';
2165 if Ignore ('E') then
2181 exit when At_End_Of_Field;
2182 Add_Char_To_Name_Buffer (C);
2185 Version_Ref.Set (new String'(Name_Buffer (1 .. Name_Len)), True);
2192 -- Scan out source dependency lines for this ALI file
2194 ALIs.Table (Id).First_Sdep := Sdep.Last + 1;
2198 exit D_Loop when C /= 'D';
2200 if Ignore ('D') then
2206 Sdep.Increment_Last;
2208 -- In the following call, Lower is not set to True, this is either
2209 -- a bug, or it deserves a special comment as to why this is so???
2211 Sdep.Table (Sdep.Last).Sfile := Get_File_Name;
2213 Sdep.Table (Sdep.Last).Stamp := Get_Stamp;
2214 Sdep.Table (Sdep.Last).Dummy_Entry :=
2215 (Sdep.Table (Sdep.Last).Stamp = Dummy_Time_Stamp);
2217 -- Acquire checksum value
2230 exit when At_Eol or else Ctr = 8;
2232 if Nextc in '0' .. '9' then
2234 Character'Pos (Nextc) - Character'Pos ('0');
2236 elsif Nextc in 'a' .. 'f' then
2238 Character'Pos (Nextc) - Character'Pos ('a') + 10;
2248 if Ctr = 8 and then At_End_Of_Field then
2249 Sdep.Table (Sdep.Last).Checksum := Chk;
2255 -- Acquire subunit and reference file name entries
2257 Sdep.Table (Sdep.Last).Subunit_Name := No_Name;
2258 Sdep.Table (Sdep.Last).Rfile :=
2259 Sdep.Table (Sdep.Last).Sfile;
2260 Sdep.Table (Sdep.Last).Start_Line := 1;
2265 -- Here for subunit name
2267 if Nextc not in '0' .. '9' then
2269 while not At_End_Of_Field loop
2270 Add_Char_To_Name_Buffer (Getc);
2273 -- Set the subunit name. Note that we use Name_Find rather
2274 -- than Name_Enter here as the subunit name may already
2275 -- have been put in the name table by the Project Manager.
2277 Sdep.Table (Sdep.Last).Subunit_Name := Name_Find;
2282 -- Here for reference file name entry
2284 if Nextc in '0' .. '9' then
2285 Sdep.Table (Sdep.Last).Start_Line := Get_Nat;
2290 while not At_End_Of_Field loop
2291 Add_Char_To_Name_Buffer (Getc);
2294 Sdep.Table (Sdep.Last).Rfile := Name_Enter;
2304 ALIs.Table (Id).Last_Sdep := Sdep.Last;
2306 -- We must at this stage be at an Xref line or the end of file
2318 -- If we are ignoring Xref sections we are done (we ignore all
2319 -- remaining lines since only xref related lines follow X).
2321 if Ignore ('X') and then not Debug_Flag_X then
2325 -- Loop through Xref sections
2329 exit X_Loop when C /= 'X';
2331 -- Make new entry in section table
2333 Xref_Section.Increment_Last;
2335 Read_Refs_For_One_File : declare
2336 XS : Xref_Section_Record renames
2337 Xref_Section.Table (Xref_Section.Last);
2339 Current_File_Num : Sdep_Id;
2340 -- Keeps track of the current file number (changed by nn|)
2343 XS.File_Num := Sdep_Id (Get_Nat + Nat (First_Sdep_Entry) - 1);
2344 XS.File_Name := Get_File_Name;
2345 XS.First_Entity := Xref_Entity.Last + 1;
2347 Current_File_Num := XS.File_Num;
2354 -- Loop through Xref entities
2356 while C /= 'X' and then C /= EOF loop
2357 Xref_Entity.Increment_Last;
2359 Read_Refs_For_One_Entity : declare
2360 XE : Xref_Entity_Record renames
2361 Xref_Entity.Table (Xref_Entity.Last);
2364 procedure Read_Instantiation_Reference;
2365 -- Acquire instantiation reference. Caller has checked
2366 -- that current character is '[' and on return the cursor
2367 -- is skipped past the corresponding closing ']'.
2369 ----------------------------------
2370 -- Read_Instantiation_Reference --
2371 ----------------------------------
2373 procedure Read_Instantiation_Reference is
2374 Local_File_Num : Sdep_Id := Current_File_Num;
2377 Xref.Increment_Last;
2380 XR : Xref_Record renames Xref.Table (Xref.Last);
2383 P := P + 1; -- skip [
2388 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2389 Local_File_Num := XR.File_Num;
2394 XR.File_Num := Local_File_Num;
2401 -- Recursive call for next reference
2404 pragma Warnings (Off); -- kill recursion warning
2405 Read_Instantiation_Reference;
2406 pragma Warnings (On);
2409 -- Skip closing bracket after recursive call
2413 end Read_Instantiation_Reference;
2415 -- Start of processing for Read_Refs_For_One_Entity
2424 XE.Visibility := Global;
2426 XE.Visibility := Static;
2428 XE.Visibility := Other;
2431 XE.Entity := Get_Name;
2433 -- Handle the information about generic instantiations
2436 Skipc; -- Opening '['
2439 if Nextc /= '|' then
2440 XE.Iref_File_Num := Current_File_Num;
2444 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2446 XE.Iref_Line := Get_Nat;
2454 XE.Iref_File_Num := No_Sdep_Id;
2458 Current_File_Num := XS.File_Num;
2460 -- Renaming reference is present
2464 XE.Rref_Line := Get_Nat;
2470 XE.Rref_Col := Get_Nat;
2472 -- No renaming reference present
2481 XE.Oref_File_Num := No_Sdep_Id;
2482 XE.Tref_File_Num := No_Sdep_Id;
2483 XE.Tref := Tref_None;
2484 XE.First_Xref := Xref.Last + 1;
2486 -- Loop to check for additional info present
2499 (Current_File_Num, Ref, File, Line, Typ, Col, Std);
2500 exit when Ref = Tref_None;
2502 -- Do we have an overriding procedure?
2504 if Ref = Tref_Derived and then Typ = 'p' then
2505 XE.Oref_File_Num := File;
2506 XE.Oref_Line := Line;
2509 -- Arrays never override anything, and <> points to
2510 -- the index types instead
2512 elsif Ref = Tref_Derived and then XE.Etype = 'A' then
2514 -- Index types are stored in the list of references
2516 Xref.Increment_Last;
2519 XR : Xref_Record renames Xref.Table (Xref.Last);
2521 XR.File_Num := File;
2523 XR.Rtype := Array_Index_Reference;
2528 -- Interfaces are stored in the list of references,
2529 -- although the parent type itself is stored in XE.
2530 -- The first interface (when there are only
2531 -- interfaces) is stored in XE.Tref*)
2533 elsif Ref = Tref_Derived
2535 and then XE.Tref_File_Num /= No_Sdep_Id
2537 Xref.Increment_Last;
2540 XR : Xref_Record renames Xref.Table (Xref.Last);
2542 XR.File_Num := File;
2544 XR.Rtype := Interface_Reference;
2551 XE.Tref_File_Num := File;
2552 XE.Tref_Line := Line;
2553 XE.Tref_Type := Typ;
2555 XE.Tref_Standard_Entity := Std;
2560 -- Loop through cross-references for this entity
2567 exit when Nextc /= '.';
2571 Xref.Increment_Last;
2574 XR : Xref_Record renames Xref.Table (Xref.Last);
2581 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2582 Current_File_Num := XR.File_Num;
2586 XR.File_Num := Current_File_Num;
2592 -- Imported entities reference as in:
2593 -- 494b<c,__gnat_copy_attribs>25
2597 XR.Imported_Lang := Get_Name;
2599 pragma Assert (Nextc = ',');
2602 XR.Imported_Name := Get_Name;
2604 pragma Assert (Nextc = '>');
2608 XR.Imported_Lang := No_Name;
2609 XR.Imported_Name := No_Name;
2615 Read_Instantiation_Reference;
2620 -- Record last cross-reference
2622 XE.Last_Xref := Xref.Last;
2626 when Bad_ALI_Format =>
2628 -- If ignoring errors, then we skip a line with an
2629 -- unexpected error, and try to continue subsequent
2632 if Ignore_Errors then
2633 Xref_Entity.Decrement_Last;
2637 -- Otherwise, we reraise the fatal exception
2642 end Read_Refs_For_One_Entity;
2645 -- Record last entity
2647 XS.Last_Entity := Xref_Entity.Last;
2649 end Read_Refs_For_One_File;
2654 -- Here after dealing with xref sections
2656 -- Ignore remaining lines, which belong to an additional section of the
2657 -- ALI file not considered here (like SCO or Alfa).
2664 when Bad_ALI_Format =>
2672 function SEq (F1, F2 : String_Ptr) return Boolean is
2674 return F1.all = F2.all;
2681 function SHash (S : String_Ptr) return Vindex is
2686 for J in S.all'Range loop
2687 H := H * 2 + Character'Pos (S (J));
2690 return Vindex (Vindex'First + Vindex (H mod Vindex'Range_Length));