Add assember CFI directives to millicode division and remainder routines.
[official-gcc.git] / gcc / ada / bcheck.adb
blobf09de1bef3b6c6a531c415b5b822f5f34170da65
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- B C H E C K --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2023, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 with ALI; use ALI;
27 with ALI.Util; use ALI.Util;
28 with Binderr; use Binderr;
29 with Butil; use Butil;
30 with Casing; use Casing;
31 with Fname; use Fname;
32 with Gnatvsn;
33 with Namet; use Namet;
34 with Opt; use Opt;
35 with Osint;
36 with Output; use Output;
37 with Rident; use Rident;
38 with Types; use Types;
40 package body Bcheck is
42 -----------------------
43 -- Local Subprograms --
44 -----------------------
46 -- The following checking subprograms make up the parts of the
47 -- configuration consistency check. See bodies for details of checks.
49 procedure Check_Consistent_Dispatching_Policy;
50 procedure Check_Consistent_Dynamic_Elaboration_Checking;
51 procedure Check_Consistent_Interrupt_States;
52 procedure Check_Consistent_Locking_Policy;
53 procedure Check_Consistent_No_Component_Reordering;
54 procedure Check_Consistent_Normalize_Scalars;
55 procedure Check_Consistent_Optimize_Alignment;
56 procedure Check_Consistent_Partition_Elaboration_Policy;
57 procedure Check_Consistent_Queuing_Policy;
58 procedure Check_Consistent_Restrictions;
59 procedure Check_Consistent_Restriction_No_Default_Initialization;
60 procedure Check_Consistent_SSO_Default;
61 procedure Check_Consistent_Exception_Handling;
63 procedure Consistency_Error_Msg (Msg : String);
64 -- Produce an error or a warning message, depending on whether an
65 -- inconsistent configuration is permitted or not.
67 function Same_Unit (U1 : Unit_Name_Type; U2 : Name_Id) return Boolean;
68 -- Used to compare two unit names for No_Dependence checks. U1 is in
69 -- standard unit name format, and U2 is in literal form with periods.
71 -------------------------------------
72 -- Check_Configuration_Consistency --
73 -------------------------------------
75 procedure Check_Configuration_Consistency is
76 begin
77 if Queuing_Policy_Specified /= ' ' then
78 Check_Consistent_Queuing_Policy;
79 end if;
81 if Locking_Policy_Specified /= ' ' then
82 Check_Consistent_Locking_Policy;
83 end if;
85 if No_Component_Reordering_Specified then
86 Check_Consistent_No_Component_Reordering;
87 end if;
89 if Partition_Elaboration_Policy_Specified /= ' ' then
90 Check_Consistent_Partition_Elaboration_Policy;
91 end if;
93 if SSO_Default_Specified then
94 Check_Consistent_SSO_Default;
95 end if;
97 if Zero_Cost_Exceptions_Specified then
98 Check_Consistent_Exception_Handling;
99 end if;
101 Check_Consistent_Normalize_Scalars;
102 Check_Consistent_Optimize_Alignment;
103 Check_Consistent_Dynamic_Elaboration_Checking;
104 Check_Consistent_Restrictions;
105 Check_Consistent_Restriction_No_Default_Initialization;
106 Check_Consistent_Interrupt_States;
107 Check_Consistent_Dispatching_Policy;
108 end Check_Configuration_Consistency;
110 -----------------------
111 -- Check_Consistency --
112 -----------------------
114 procedure Check_Consistency is
115 Src : Source_Id;
116 -- Source file Id for this Sdep entry
118 ALI_Path_Id : File_Name_Type;
120 begin
121 -- First, we go through the source table to see if there are any cases
122 -- in which we should go after source files and compute checksums of
123 -- the source files. We need to do this for any file for which we have
124 -- mismatching time stamps and (so far) matching checksums.
126 for S in Source.First .. Source.Last loop
128 -- If all time stamps for a file match, then there is nothing to
129 -- do, since we will not be checking checksums in that case anyway
131 if Source.Table (S).All_Timestamps_Match then
132 null;
134 -- If we did not find the source file, then we can't compute its
135 -- checksum anyway. Note that when we have a time stamp mismatch,
136 -- we try to find the source file unconditionally (i.e. if
137 -- Check_Source_Files is False).
139 elsif not Source.Table (S).Source_Found then
140 null;
142 -- If we already have non-matching or missing checksums, then no
143 -- need to try going after source file, since we won't trust the
144 -- checksums in any case.
146 elsif not Source.Table (S).All_Checksums_Match then
147 null;
149 -- Now we have the case where we have time stamp mismatches, and
150 -- the source file is around, but so far all checksums match. This
151 -- is the case where we need to compute the checksum from the source
152 -- file, since otherwise we would ignore the time stamp mismatches,
153 -- and that is wrong if the checksum of the source does not agree
154 -- with the checksums in the ALI files.
156 elsif Check_Source_Files then
157 if not Checksums_Match
158 (Source.Table (S).Checksum,
159 Get_File_Checksum (Source.Table (S).Sfile))
160 then
161 Source.Table (S).All_Checksums_Match := False;
162 end if;
163 end if;
164 end loop;
166 -- Loop through ALI files
168 ALIs_Loop : for A in ALIs.First .. ALIs.Last loop
170 -- Loop through Sdep entries in one ALI file
172 Sdep_Loop : for D in
173 ALIs.Table (A).First_Sdep .. ALIs.Table (A).Last_Sdep
174 loop
175 if Sdep.Table (D).Dummy_Entry then
176 goto Continue;
177 end if;
179 Src := Source_Id (Get_Name_Table_Int (Sdep.Table (D).Sfile));
181 -- If the time stamps match, or all checksums match, then we
182 -- are OK, otherwise we have a definite error.
184 if Sdep.Table (D).Stamp /= Source.Table (Src).Stamp
185 and then not Source.Table (Src).All_Checksums_Match
186 then
187 Error_Msg_File_1 := ALIs.Table (A).Sfile;
188 Error_Msg_File_2 := Sdep.Table (D).Sfile;
190 -- Two styles of message, depending on whether or not
191 -- the updated file is the one that must be recompiled
193 if Error_Msg_File_1 = Error_Msg_File_2 then
194 if Tolerate_Consistency_Errors then
195 Error_Msg
196 ("?{ has been modified and should be recompiled");
197 else
198 Error_Msg
199 ("{ has been modified and must be recompiled");
200 end if;
202 else
203 ALI_Path_Id :=
204 Osint.Full_Lib_File_Name (ALIs.Table (A).Afile);
206 if Osint.Is_Readonly_Library (ALI_Path_Id) then
207 if Tolerate_Consistency_Errors then
208 Error_Msg ("?{ should be recompiled");
209 Error_Msg_File_1 := ALI_Path_Id;
210 Error_Msg ("?({ is obsolete and read-only)");
211 else
212 Error_Msg ("{ must be compiled");
213 Error_Msg_File_1 := ALI_Path_Id;
214 Error_Msg ("({ is obsolete and read-only)");
215 end if;
217 elsif Tolerate_Consistency_Errors then
218 Error_Msg
219 ("?{ should be recompiled ({ has been modified)");
221 else
222 Error_Msg ("{ must be recompiled ({ has been modified)");
223 end if;
224 end if;
226 if (not Tolerate_Consistency_Errors) and Verbose_Mode then
227 Error_Msg_File_1 := Source.Table (Src).Stamp_File;
229 if Source.Table (Src).Source_Found then
230 Error_Msg_File_1 :=
231 Osint.Full_Source_Name (Error_Msg_File_1);
232 else
233 Error_Msg_File_1 :=
234 Osint.Full_Lib_File_Name (Error_Msg_File_1);
235 end if;
237 Error_Msg
238 ("time stamp from { " & String (Source.Table (Src).Stamp));
240 Error_Msg_File_1 := Sdep.Table (D).Sfile;
241 Error_Msg
242 (" conflicts with { timestamp " &
243 String (Sdep.Table (D).Stamp));
245 Error_Msg_File_1 :=
246 Osint.Full_Lib_File_Name (ALIs.Table (A).Afile);
247 Error_Msg (" from {");
248 end if;
250 -- Exit from the loop through Sdep entries once we find one
251 -- that does not match.
253 exit Sdep_Loop;
254 end if;
256 <<Continue>>
257 null;
258 end loop Sdep_Loop;
259 end loop ALIs_Loop;
260 end Check_Consistency;
262 -----------------------------------------
263 -- Check_Consistent_Dispatching_Policy --
264 -----------------------------------------
266 -- The rule is that all files for which the dispatching policy is
267 -- significant must meet the following rules:
269 -- 1. All files for which a task dispatching policy is significant must
270 -- be compiled with the same setting.
272 -- 2. If a partition contains one or more Priority_Specific_Dispatching
273 -- pragmas it cannot contain a Task_Dispatching_Policy pragma.
275 -- 3. No overlap is allowed in the priority ranges specified in
276 -- Priority_Specific_Dispatching pragmas within the same partition.
278 -- 4. If a partition contains one or more Priority_Specific_Dispatching
279 -- pragmas then the Ceiling_Locking policy is the only one allowed for
280 -- the partition.
282 procedure Check_Consistent_Dispatching_Policy is
283 Max_Prio : Nat := 0;
284 -- Maximum priority value for which a Priority_Specific_Dispatching
285 -- pragma has been specified.
287 TDP_Pragma_Afile : ALI_Id := No_ALI_Id;
288 -- ALI file where a Task_Dispatching_Policy pragma appears
290 begin
291 -- Consistency checks in units specifying a Task_Dispatching_Policy
293 if Task_Dispatching_Policy_Specified /= ' ' then
294 Find_Policy : for A1 in ALIs.First .. ALIs.Last loop
295 if ALIs.Table (A1).Task_Dispatching_Policy /= ' ' then
297 -- Store the place where the first task dispatching pragma
298 -- appears. We may need this value for issuing consistency
299 -- errors if Priority_Specific_Dispatching pragmas are used.
301 TDP_Pragma_Afile := A1;
303 Check_Policy : declare
304 Policy : constant Character :=
305 ALIs.Table (A1).Task_Dispatching_Policy;
307 begin
308 for A2 in A1 + 1 .. ALIs.Last loop
309 if ALIs.Table (A2).Task_Dispatching_Policy /= ' '
310 and then
311 ALIs.Table (A2).Task_Dispatching_Policy /= Policy
312 then
313 Error_Msg_File_1 := ALIs.Table (A1).Sfile;
314 Error_Msg_File_2 := ALIs.Table (A2).Sfile;
316 Consistency_Error_Msg
317 ("{ and { compiled with different task" &
318 " dispatching policies");
319 exit Find_Policy;
320 end if;
321 end loop;
322 end Check_Policy;
324 exit Find_Policy;
325 end if;
326 end loop Find_Policy;
327 end if;
329 -- If no Priority_Specific_Dispatching entries, nothing else to do
331 if Specific_Dispatching.Last >= Specific_Dispatching.First then
333 -- Find out the maximum priority value for which one of the
334 -- Priority_Specific_Dispatching pragmas applies.
336 Max_Prio := 0;
337 for J in Specific_Dispatching.First .. Specific_Dispatching.Last loop
338 if Specific_Dispatching.Table (J).Last_Priority > Max_Prio then
339 Max_Prio := Specific_Dispatching.Table (J).Last_Priority;
340 end if;
341 end loop;
343 -- Now establish tables to be used for consistency checking
345 declare
346 -- The following record type is used to record locations of the
347 -- Priority_Specific_Dispatching pragmas applying to the Priority.
349 type Specific_Dispatching_Entry is record
350 Dispatching_Policy : Character := ' ';
351 -- First character (upper case) of corresponding policy name
353 Afile : ALI_Id := No_ALI_Id;
354 -- ALI file that generated Priority Specific Dispatching
355 -- entry for consistency message.
357 Loc : Nat := 0;
358 -- Line numbers from Priority_Specific_Dispatching pragma
359 end record;
361 PSD_Table : array (0 .. Max_Prio) of Specific_Dispatching_Entry :=
362 (others => Specific_Dispatching_Entry'
363 (Dispatching_Policy => ' ',
364 Afile => No_ALI_Id,
365 Loc => 0));
366 -- Array containing an entry per priority containing the location
367 -- where there is a Priority_Specific_Dispatching pragma that
368 -- applies to the priority.
370 begin
371 for F in ALIs.First .. ALIs.Last loop
372 for K in ALIs.Table (F).First_Specific_Dispatching ..
373 ALIs.Table (F).Last_Specific_Dispatching
374 loop
375 declare
376 DTK : Specific_Dispatching_Record
377 renames Specific_Dispatching.Table (K);
378 begin
379 -- Check whether pragma Task_Dispatching_Policy and
380 -- pragma Priority_Specific_Dispatching are used in the
381 -- same partition.
383 if Task_Dispatching_Policy_Specified /= ' ' then
384 Error_Msg_File_1 := ALIs.Table (F).Sfile;
385 Error_Msg_File_2 :=
386 ALIs.Table (TDP_Pragma_Afile).Sfile;
388 Error_Msg_Nat_1 := DTK.PSD_Pragma_Line;
390 Consistency_Error_Msg
391 ("Priority_Specific_Dispatching at {:#" &
392 " incompatible with Task_Dispatching_Policy at {");
393 end if;
395 -- Ceiling_Locking must also be specified for a partition
396 -- with at least one Priority_Specific_Dispatching
397 -- pragma.
399 if Locking_Policy_Specified /= ' '
400 and then Locking_Policy_Specified /= 'C'
401 then
402 for A in ALIs.First .. ALIs.Last loop
403 if ALIs.Table (A).Locking_Policy /= ' '
404 and then ALIs.Table (A).Locking_Policy /= 'C'
405 then
406 Error_Msg_File_1 := ALIs.Table (F).Sfile;
407 Error_Msg_File_2 := ALIs.Table (A).Sfile;
409 Error_Msg_Nat_1 := DTK.PSD_Pragma_Line;
411 Consistency_Error_Msg
412 ("Priority_Specific_Dispatching at {:#" &
413 " incompatible with Locking_Policy at {");
414 end if;
415 end loop;
416 end if;
418 -- Check overlapping priority ranges
420 Find_Overlapping : for Prio in
421 DTK.First_Priority .. DTK.Last_Priority
422 loop
423 if PSD_Table (Prio).Afile = No_ALI_Id then
424 PSD_Table (Prio) :=
425 (Dispatching_Policy => DTK.Dispatching_Policy,
426 Afile => F, Loc => DTK.PSD_Pragma_Line);
428 elsif PSD_Table (Prio).Dispatching_Policy /=
429 DTK.Dispatching_Policy
431 then
432 Error_Msg_File_1 :=
433 ALIs.Table (PSD_Table (Prio).Afile).Sfile;
434 Error_Msg_File_2 := ALIs.Table (F).Sfile;
435 Error_Msg_Nat_1 := PSD_Table (Prio).Loc;
436 Error_Msg_Nat_2 := DTK.PSD_Pragma_Line;
438 Consistency_Error_Msg
439 ("overlapping priority ranges at {:# and {:#");
441 exit Find_Overlapping;
442 end if;
443 end loop Find_Overlapping;
444 end;
445 end loop;
446 end loop;
447 end;
448 end if;
449 end Check_Consistent_Dispatching_Policy;
451 ---------------------------------------------------
452 -- Check_Consistent_Dynamic_Elaboration_Checking --
453 ---------------------------------------------------
455 -- The rule here is that if a unit has dynamic elaboration checks,
456 -- then any unit it withs must meet one of the following criteria:
458 -- 1. There is a pragma Elaborate_All for the with'ed unit
459 -- 2. The with'ed unit was compiled with dynamic elaboration checks
460 -- 3. The with'ed unit has pragma Preelaborate or Pure
461 -- 4. It is an internal GNAT unit (including children of GNAT)
462 -- 5. It is an interface of a Stand-Alone Library
464 procedure Check_Consistent_Dynamic_Elaboration_Checking is
465 begin
466 if Dynamic_Elaboration_Checks_Specified then
467 for U in First_Unit_Entry .. Units.Last loop
468 declare
469 UR : Unit_Record renames Units.Table (U);
471 begin
472 if UR.Dynamic_Elab then
473 for W in UR.First_With .. UR.Last_With loop
474 declare
475 WR : With_Record renames Withs.Table (W);
477 begin
478 if Get_Name_Table_Int (WR.Uname) /= 0 then
479 declare
480 WU : Unit_Record renames
481 Units.Table
482 (Unit_Id
483 (Get_Name_Table_Int (WR.Uname)));
485 begin
486 -- Case 1. Elaborate_All for with'ed unit
488 if WR.Elaborate_All then
489 null;
491 -- Case 2. With'ed unit has dynamic elab checks
493 elsif WU.Dynamic_Elab then
494 null;
496 -- Case 3. With'ed unit is Preelaborate or Pure
498 elsif WU.Preelab or else WU.Pure then
499 null;
501 -- Case 4. With'ed unit is internal file
503 elsif Is_Internal_File_Name (WU.Sfile) then
504 null;
506 -- Case 5. With'ed unit is a SAL interface
508 elsif WU.SAL_Interface then
509 null;
511 -- Issue warning, not one of the safe cases
513 else
514 Error_Msg_File_1 := UR.Sfile;
515 Error_Msg
516 ("?{ has dynamic elaboration checks " &
517 "and with's");
519 Error_Msg_File_1 := WU.Sfile;
520 Error_Msg
521 ("? { which has static elaboration " &
522 "checks");
524 Warnings_Detected := Warnings_Detected + 1;
525 end if;
526 end;
527 end if;
528 end;
529 end loop;
530 end if;
531 end;
532 end loop;
533 end if;
534 end Check_Consistent_Dynamic_Elaboration_Checking;
536 ---------------------------------------
537 -- Check_Consistent_Interrupt_States --
538 ---------------------------------------
540 -- The rule is that if the state of a given interrupt is specified
541 -- in more than one unit, it must be specified with a consistent state.
543 procedure Check_Consistent_Interrupt_States is
544 Max_Intrup : Nat;
546 begin
547 -- If no Interrupt_State entries, nothing to do
549 if Interrupt_States.Last < Interrupt_States.First then
550 return;
551 end if;
553 -- First find out the maximum interrupt value
555 Max_Intrup := 0;
556 for J in Interrupt_States.First .. Interrupt_States.Last loop
557 if Interrupt_States.Table (J).Interrupt_Id > Max_Intrup then
558 Max_Intrup := Interrupt_States.Table (J).Interrupt_Id;
559 end if;
560 end loop;
562 -- Now establish tables to be used for consistency checking
564 declare
565 Istate : array (0 .. Max_Intrup) of Character := (others => 'n');
566 -- Interrupt state entries, 'u'/'s'/'r' or 'n' to indicate an
567 -- entry that has not been set.
569 Afile : array (0 .. Max_Intrup) of ALI_Id;
570 -- ALI file that generated Istate entry for consistency message
572 Loc : array (0 .. Max_Intrup) of Nat;
573 -- Line numbers from IS pragma generating Istate entry
575 Inum : Nat;
576 -- Interrupt number from entry being tested
578 Stat : Character;
579 -- Interrupt state from entry being tested
581 Lnum : Nat;
582 -- Line number from entry being tested
584 begin
585 for F in ALIs.First .. ALIs.Last loop
586 for K in ALIs.Table (F).First_Interrupt_State ..
587 ALIs.Table (F).Last_Interrupt_State
588 loop
589 Inum := Interrupt_States.Table (K).Interrupt_Id;
590 Stat := Interrupt_States.Table (K).Interrupt_State;
591 Lnum := Interrupt_States.Table (K).IS_Pragma_Line;
593 if Istate (Inum) = 'n' then
594 Istate (Inum) := Stat;
595 Afile (Inum) := F;
596 Loc (Inum) := Lnum;
598 elsif Istate (Inum) /= Stat then
599 Error_Msg_File_1 := ALIs.Table (Afile (Inum)).Sfile;
600 Error_Msg_File_2 := ALIs.Table (F).Sfile;
601 Error_Msg_Nat_1 := Loc (Inum);
602 Error_Msg_Nat_2 := Lnum;
604 Consistency_Error_Msg
605 ("inconsistent interrupt states at {:# and {:#");
606 end if;
607 end loop;
608 end loop;
609 end;
610 end Check_Consistent_Interrupt_States;
612 -------------------------------------
613 -- Check_Consistent_Locking_Policy --
614 -------------------------------------
616 -- The rule is that all files for which the locking policy is
617 -- significant must be compiled with the same setting.
619 procedure Check_Consistent_Locking_Policy is
620 begin
621 -- First search for a unit specifying a policy and then
622 -- check all remaining units against it.
624 Find_Policy : for A1 in ALIs.First .. ALIs.Last loop
625 if ALIs.Table (A1).Locking_Policy /= ' ' then
626 Check_Policy : declare
627 Policy : constant Character := ALIs.Table (A1).Locking_Policy;
629 begin
630 for A2 in A1 + 1 .. ALIs.Last loop
631 if ALIs.Table (A2).Locking_Policy /= ' '
632 and then
633 ALIs.Table (A2).Locking_Policy /= Policy
634 then
635 Error_Msg_File_1 := ALIs.Table (A1).Sfile;
636 Error_Msg_File_2 := ALIs.Table (A2).Sfile;
638 Consistency_Error_Msg
639 ("{ and { compiled with different locking policies");
640 exit Find_Policy;
641 end if;
642 end loop;
643 end Check_Policy;
645 exit Find_Policy;
646 end if;
647 end loop Find_Policy;
648 end Check_Consistent_Locking_Policy;
650 ----------------------------------------------
651 -- Check_Consistent_No_Component_Reordering --
652 ----------------------------------------------
654 -- This routine checks for a consistent No_Component_Reordering setting.
655 -- Note that internal units are excluded from this check, since we don't
656 -- in any case allow the pragma to affect types in internal units, and
657 -- there is thus no requirement to recompile the run-time with the setting.
659 procedure Check_Consistent_No_Component_Reordering is
660 OK : Boolean := True;
661 begin
662 -- Check that all entries have No_Component_Reordering set
664 for A1 in ALIs.First .. ALIs.Last loop
665 if not Is_Internal_File_Name (ALIs.Table (A1).Sfile)
666 and then not ALIs.Table (A1).No_Component_Reordering
667 then
668 OK := False;
669 exit;
670 end if;
671 end loop;
673 -- All do, return
675 if OK then
676 return;
677 end if;
679 -- Here we have an inconsistency
681 Consistency_Error_Msg
682 ("some but not all files compiled with No_Component_Reordering");
684 Write_Eol;
685 Write_Str ("files compiled with No_Component_Reordering");
686 Write_Eol;
688 for A1 in ALIs.First .. ALIs.Last loop
689 if not Is_Internal_File_Name (ALIs.Table (A1).Sfile)
690 and then ALIs.Table (A1).No_Component_Reordering
691 then
692 Write_Str (" ");
693 Write_Name (ALIs.Table (A1).Sfile);
694 Write_Eol;
695 end if;
696 end loop;
698 Write_Eol;
699 Write_Str ("files compiled without No_Component_Reordering");
700 Write_Eol;
702 for A1 in ALIs.First .. ALIs.Last loop
703 if not Is_Internal_File_Name (ALIs.Table (A1).Sfile)
704 and then not ALIs.Table (A1).No_Component_Reordering
705 then
706 Write_Str (" ");
707 Write_Name (ALIs.Table (A1).Sfile);
708 Write_Eol;
709 end if;
710 end loop;
711 end Check_Consistent_No_Component_Reordering;
713 ----------------------------------------
714 -- Check_Consistent_Normalize_Scalars --
715 ----------------------------------------
717 -- The rule is that if any unit is compiled with Normalize_Scalars,
718 -- then all other units in the partition must also be compiled with
719 -- Normalize_Scalars in effect.
721 -- There is some issue as to whether this consistency check is desirable,
722 -- it is certainly required at the moment by the RM. We should keep a watch
723 -- on the ARG and HRG deliberations here. GNAT no longer depends on this
724 -- consistency (it used to do so, but that is no longer the case, since
725 -- pragma Initialize_Scalars pragma does not require consistency.)
727 procedure Check_Consistent_Normalize_Scalars is
728 begin
729 if Normalize_Scalars_Specified and No_Normalize_Scalars_Specified then
730 Consistency_Error_Msg
731 ("some but not all files compiled with Normalize_Scalars");
733 Write_Eol;
734 Write_Str ("files compiled with Normalize_Scalars");
735 Write_Eol;
737 for A1 in ALIs.First .. ALIs.Last loop
738 if ALIs.Table (A1).Normalize_Scalars then
739 Write_Str (" ");
740 Write_Name (ALIs.Table (A1).Sfile);
741 Write_Eol;
742 end if;
743 end loop;
745 Write_Eol;
746 Write_Str ("files compiled without Normalize_Scalars");
747 Write_Eol;
749 for A1 in ALIs.First .. ALIs.Last loop
750 if not ALIs.Table (A1).Normalize_Scalars then
751 Write_Str (" ");
752 Write_Name (ALIs.Table (A1).Sfile);
753 Write_Eol;
754 end if;
755 end loop;
756 end if;
757 end Check_Consistent_Normalize_Scalars;
759 -----------------------------------------
760 -- Check_Consistent_Optimize_Alignment --
761 -----------------------------------------
763 -- The rule is that all units which depend on the global default setting
764 -- of Optimize_Alignment must be compiled with the same setting for this
765 -- default. Units which specify an explicit local value for this setting
766 -- are exempt from the consistency rule (this includes all internal units).
768 procedure Check_Consistent_Optimize_Alignment is
769 OA_Setting : Character := ' ';
770 -- Reset when we find a unit that depends on the default and does
771 -- not have a local specification of the Optimize_Alignment setting.
773 OA_Unit : Unit_Id := No_Unit_Id;
774 -- Id of unit from which OA_Setting was set
776 C : Character;
778 begin
779 for U in First_Unit_Entry .. Units.Last loop
780 C := Units.Table (U).Optimize_Alignment;
782 if C /= 'L' then
783 if OA_Setting = ' ' then
784 OA_Setting := C;
785 OA_Unit := U;
787 elsif OA_Setting = C then
788 null;
790 else
791 pragma Assert (Present (OA_Unit));
792 Error_Msg_Unit_1 := Units.Table (OA_Unit).Uname;
793 Error_Msg_Unit_2 := Units.Table (U).Uname;
795 Consistency_Error_Msg
796 ("$ and $ compiled with different "
797 & "default Optimize_Alignment settings");
798 return;
799 end if;
800 end if;
801 end loop;
802 end Check_Consistent_Optimize_Alignment;
804 ---------------------------------------------------
805 -- Check_Consistent_Partition_Elaboration_Policy --
806 ---------------------------------------------------
808 -- The rule is that all files for which the partition elaboration policy is
809 -- significant must be compiled with the same setting.
811 procedure Check_Consistent_Partition_Elaboration_Policy is
812 begin
813 -- First search for a unit specifying a policy and then
814 -- check all remaining units against it.
816 Find_Policy : for A1 in ALIs.First .. ALIs.Last loop
817 if ALIs.Table (A1).Partition_Elaboration_Policy /= ' ' then
818 Check_Policy : declare
819 Policy : constant Character :=
820 ALIs.Table (A1).Partition_Elaboration_Policy;
822 begin
823 for A2 in A1 + 1 .. ALIs.Last loop
824 if ALIs.Table (A2).Partition_Elaboration_Policy /= ' '
825 and then
826 ALIs.Table (A2).Partition_Elaboration_Policy /= Policy
827 then
828 Error_Msg_File_1 := ALIs.Table (A1).Sfile;
829 Error_Msg_File_2 := ALIs.Table (A2).Sfile;
831 Consistency_Error_Msg
832 ("{ and { compiled with different partition "
833 & "elaboration policies");
834 exit Find_Policy;
835 end if;
836 end loop;
837 end Check_Policy;
839 -- A No_Task_Hierarchy restriction must be specified for the
840 -- Sequential policy (RM H.6(6/2)).
842 if Partition_Elaboration_Policy_Specified = 'S'
843 and then not Cumulative_Restrictions.Set (No_Task_Hierarchy)
844 then
845 Error_Msg_File_1 := ALIs.Table (A1).Sfile;
846 Error_Msg
847 ("{ has sequential partition elaboration policy, but no");
848 Error_Msg
849 ("pragma Restrictions (No_Task_Hierarchy) was specified");
850 end if;
852 exit Find_Policy;
853 end if;
854 end loop Find_Policy;
855 end Check_Consistent_Partition_Elaboration_Policy;
857 -------------------------------------
858 -- Check_Consistent_Queuing_Policy --
859 -------------------------------------
861 -- The rule is that all files for which the queuing policy is
862 -- significant must be compiled with the same setting.
864 procedure Check_Consistent_Queuing_Policy is
865 begin
866 -- First search for a unit specifying a policy and then
867 -- check all remaining units against it.
869 Find_Policy : for A1 in ALIs.First .. ALIs.Last loop
870 if ALIs.Table (A1).Queuing_Policy /= ' ' then
871 Check_Policy : declare
872 Policy : constant Character := ALIs.Table (A1).Queuing_Policy;
873 begin
874 for A2 in A1 + 1 .. ALIs.Last loop
875 if ALIs.Table (A2).Queuing_Policy /= ' '
876 and then
877 ALIs.Table (A2).Queuing_Policy /= Policy
878 then
879 Error_Msg_File_1 := ALIs.Table (A1).Sfile;
880 Error_Msg_File_2 := ALIs.Table (A2).Sfile;
882 Consistency_Error_Msg
883 ("{ and { compiled with different queuing policies");
884 exit Find_Policy;
885 end if;
886 end loop;
887 end Check_Policy;
889 exit Find_Policy;
890 end if;
891 end loop Find_Policy;
892 end Check_Consistent_Queuing_Policy;
894 -----------------------------------
895 -- Check_Consistent_Restrictions --
896 -----------------------------------
898 -- The rule is that if a restriction is specified in any unit, then all
899 -- units must obey the restriction. The check applies only to restrictions
900 -- which require partition wide consistency, and not to internal units.
902 procedure Check_Consistent_Restrictions is
903 Restriction_File_Output : Boolean;
904 -- Shows if we have output header messages for restriction violation
906 procedure Print_Restriction_File (R : All_Restrictions);
907 -- Print header line for R if not printed yet
909 ----------------------------
910 -- Print_Restriction_File --
911 ----------------------------
913 procedure Print_Restriction_File (R : All_Restrictions) is
914 begin
915 if not Restriction_File_Output then
916 Restriction_File_Output := True;
918 -- Find an ali file specifying the restriction
920 for A in ALIs.First .. ALIs.Last loop
921 if ALIs.Table (A).Restrictions.Set (R)
922 and then (R in All_Boolean_Restrictions
923 or else ALIs.Table (A).Restrictions.Value (R) =
924 Cumulative_Restrictions.Value (R))
925 then
926 -- We have found that ALI file A specifies the restriction
927 -- that is being violated (the minimum value is specified
928 -- in the case of a parameter restriction).
930 declare
931 M1 : constant String := "{ has restriction ";
932 S : constant String := Restriction_Id'Image (R);
933 M2 : String (1 .. 2000); -- big enough
934 P : Integer;
936 begin
937 Name_Buffer (1 .. S'Length) := S;
938 Name_Len := S'Length;
939 Set_Casing (Mixed_Case);
941 M2 (M1'Range) := M1;
942 P := M1'Length + 1;
943 M2 (P .. P + S'Length - 1) := Name_Buffer (1 .. S'Length);
944 P := P + S'Length;
946 if R in All_Parameter_Restrictions then
947 M2 (P .. P + 4) := " => #";
948 Error_Msg_Nat_1 :=
949 Int (Cumulative_Restrictions.Value (R));
950 P := P + 5;
951 end if;
953 Error_Msg_File_1 := ALIs.Table (A).Sfile;
954 Consistency_Error_Msg (M2 (1 .. P - 1));
955 Consistency_Error_Msg
956 ("but the following files violate this restriction:");
957 return;
958 end;
959 end if;
960 end loop;
961 end if;
962 end Print_Restriction_File;
964 -- Start of processing for Check_Consistent_Restrictions
966 begin
967 -- We used to have a special test here:
969 -- A special test, if we have a main program, then if it has an
970 -- allocator in the body, this is considered to be a violation of
971 -- the restriction No_Allocators_After_Elaboration. We just mark
972 -- this restriction and then the normal circuit will flag it.
974 -- But we don't do that any more, because in the final version of Ada
975 -- 2012, it is statically illegal to have an allocator in a library-
976 -- level subprogram, so we don't need this bind time test any more.
977 -- If we have a main program with parameters (which GNAT allows), then
978 -- allocators in that will be caught by the run-time check.
980 -- Loop through all restriction violations
982 for R in All_Restrictions loop
984 -- Check for violation of this restriction
986 if Cumulative_Restrictions.Set (R)
987 and then Cumulative_Restrictions.Violated (R)
988 and then (R in Partition_Boolean_Restrictions
989 or else (R in All_Parameter_Restrictions
990 and then
991 Cumulative_Restrictions.Count (R) >
992 Cumulative_Restrictions.Value (R)))
993 then
994 Restriction_File_Output := False;
996 -- Loop through files looking for violators
998 for A2 in ALIs.First .. ALIs.Last loop
999 declare
1000 T : ALIs_Record renames ALIs.Table (A2);
1002 begin
1003 if T.Restrictions.Violated (R) then
1005 -- We exclude predefined files from the list of
1006 -- violators. This should be rethought. It is not
1007 -- clear that this is the right thing to do, that
1008 -- is particularly the case for restricted runtimes.
1010 if not Is_Internal_File_Name (T.Sfile) then
1012 -- Case of Boolean restriction, just print file name
1014 if R in All_Boolean_Restrictions then
1015 Print_Restriction_File (R);
1016 Error_Msg_File_1 := T.Sfile;
1017 Consistency_Error_Msg (" {");
1019 -- Case of Parameter restriction where violation
1020 -- count exceeds restriction value, print file
1021 -- name and count, adding "at least" if the
1022 -- exact count is not known.
1024 elsif R in Checked_Add_Parameter_Restrictions
1025 or else T.Restrictions.Count (R) >
1026 Cumulative_Restrictions.Value (R)
1027 then
1028 Print_Restriction_File (R);
1029 Error_Msg_File_1 := T.Sfile;
1030 Error_Msg_Nat_1 := Int (T.Restrictions.Count (R));
1032 if T.Restrictions.Unknown (R) then
1033 Consistency_Error_Msg
1034 (" { (count = at least #)");
1035 else
1036 Consistency_Error_Msg
1037 (" { (count = #)");
1038 end if;
1039 end if;
1040 end if;
1041 end if;
1042 end;
1043 end loop;
1044 end if;
1045 end loop;
1047 -- Now deal with No_Dependence indications. Note that we put the loop
1048 -- through entries in the no dependency table first, since this loop
1049 -- is most often empty (no such pragma Restrictions in use).
1051 for ND in No_Deps.First .. No_Deps.Last loop
1052 declare
1053 ND_Unit : constant Name_Id := No_Deps.Table (ND).No_Dep_Unit;
1054 begin
1055 for J in ALIs.First .. ALIs.Last loop
1056 declare
1057 A : ALIs_Record renames ALIs.Table (J);
1058 begin
1059 for K in A.First_Unit .. A.Last_Unit loop
1060 declare
1061 U : Unit_Record renames Units.Table (K);
1062 begin
1063 -- Exclude runtime units from this check since the
1064 -- user does not care how a runtime unit is
1065 -- implemented.
1067 if not Is_Internal_File_Name (U.Sfile) then
1068 for L in U.First_With .. U.Last_With loop
1069 if Same_Unit (Withs.Table (L).Uname, ND_Unit)
1070 then
1071 Error_Msg_File_1 := U.Sfile;
1072 Error_Msg_Name_1 := ND_Unit;
1073 Consistency_Error_Msg
1074 ("file { violates restriction " &
1075 "No_Dependence => %");
1076 end if;
1077 end loop;
1078 end if;
1079 end;
1080 end loop;
1081 end;
1082 end loop;
1083 end;
1084 end loop;
1085 end Check_Consistent_Restrictions;
1087 ------------------------------------------------------------
1088 -- Check_Consistent_Restriction_No_Default_Initialization --
1089 ------------------------------------------------------------
1091 -- The Restriction (No_Default_Initialization) has special consistency
1092 -- rules. The rule is that no unit compiled without this restriction
1093 -- that violates the restriction can WITH a unit that is compiled with
1094 -- the restriction.
1096 procedure Check_Consistent_Restriction_No_Default_Initialization is
1097 begin
1098 -- Nothing to do if no one set this restriction
1100 if not Cumulative_Restrictions.Set (No_Default_Initialization) then
1101 return;
1102 end if;
1104 -- Nothing to do if no one violates the restriction
1106 if not Cumulative_Restrictions.Violated (No_Default_Initialization) then
1107 return;
1108 end if;
1110 -- Otherwise we go into a full scan to find possible problems
1112 for U in Units.First .. Units.Last loop
1113 declare
1114 UTE : Unit_Record renames Units.Table (U);
1115 ATE : ALIs_Record renames ALIs.Table (UTE.My_ALI);
1117 begin
1118 if ATE.Restrictions.Violated (No_Default_Initialization) then
1119 for W in UTE.First_With .. UTE.Last_With loop
1120 declare
1121 AFN : constant File_Name_Type := Withs.Table (W).Afile;
1123 begin
1124 -- The file name may not be present for withs of certain
1125 -- generic run-time files. The test can be safely left
1126 -- out in such cases anyway.
1128 if AFN /= No_File then
1129 declare
1130 WAI : constant ALI_Id :=
1131 ALI_Id (Get_Name_Table_Int (AFN));
1132 WTE : ALIs_Record renames ALIs.Table (WAI);
1134 begin
1135 if WTE.Restrictions.Set
1136 (No_Default_Initialization)
1137 then
1138 Error_Msg_Unit_1 := UTE.Uname;
1139 Consistency_Error_Msg
1140 ("unit $ compiled without restriction "
1141 & "No_Default_Initialization");
1142 Error_Msg_Unit_1 := Withs.Table (W).Uname;
1143 Consistency_Error_Msg
1144 ("withs unit $, compiled with restriction "
1145 & "No_Default_Initialization");
1146 end if;
1147 end;
1148 end if;
1149 end;
1150 end loop;
1151 end if;
1152 end;
1153 end loop;
1154 end Check_Consistent_Restriction_No_Default_Initialization;
1156 ----------------------------------
1157 -- Check_Consistent_SSO_Default --
1158 ----------------------------------
1160 -- This routine checks for a consistent SSO default setting. Note that
1161 -- internal units are excluded from this check, since we don't in any
1162 -- case allow the pragma to affect types in internal units, and there
1163 -- is thus no requirement to recompile the run-time with the default set.
1165 procedure Check_Consistent_SSO_Default is
1166 Default : Character;
1168 begin
1169 Default := ALIs.Table (ALIs.First).SSO_Default;
1171 -- The default must be set from a non-internal unit
1173 pragma Assert
1174 (not Is_Internal_File_Name (ALIs.Table (ALIs.First).Sfile));
1176 -- Check all entries match the default above from the first entry
1178 for A1 in ALIs.First + 1 .. ALIs.Last loop
1179 if not Is_Internal_File_Name (ALIs.Table (A1).Sfile)
1180 and then ALIs.Table (A1).SSO_Default /= Default
1181 then
1182 Default := '?';
1183 exit;
1184 end if;
1185 end loop;
1187 -- All match, return
1189 if Default /= '?' then
1190 return;
1191 end if;
1193 -- Here we have a mismatch
1195 Consistency_Error_Msg
1196 ("files not compiled with same Default_Scalar_Storage_Order");
1198 Write_Eol;
1199 Write_Str ("files compiled with High_Order_First");
1200 Write_Eol;
1202 for A1 in ALIs.First .. ALIs.Last loop
1203 if ALIs.Table (A1).SSO_Default = 'H' then
1204 Write_Str (" ");
1205 Write_Name (ALIs.Table (A1).Sfile);
1206 Write_Eol;
1207 end if;
1208 end loop;
1210 Write_Eol;
1211 Write_Str ("files compiled with Low_Order_First");
1212 Write_Eol;
1214 for A1 in ALIs.First .. ALIs.Last loop
1215 if ALIs.Table (A1).SSO_Default = 'L' then
1216 Write_Str (" ");
1217 Write_Name (ALIs.Table (A1).Sfile);
1218 Write_Eol;
1219 end if;
1220 end loop;
1222 Write_Eol;
1223 Write_Str ("files compiled with no Default_Scalar_Storage_Order");
1224 Write_Eol;
1226 for A1 in ALIs.First .. ALIs.Last loop
1227 if not Is_Internal_File_Name (ALIs.Table (A1).Sfile)
1228 and then ALIs.Table (A1).SSO_Default = ' '
1229 then
1230 Write_Str (" ");
1231 Write_Name (ALIs.Table (A1).Sfile);
1232 Write_Eol;
1233 end if;
1234 end loop;
1235 end Check_Consistent_SSO_Default;
1237 -----------------------------------------
1238 -- Check_Consistent_Exception_Handling --
1239 -----------------------------------------
1241 -- All units must have the same exception handling mechanism.
1243 procedure Check_Consistent_Exception_Handling is
1244 begin
1245 Check_Mechanism : for A1 in ALIs.First + 1 .. ALIs.Last loop
1246 if ALIs.Table (A1).Zero_Cost_Exceptions /=
1247 ALIs.Table (ALIs.First).Zero_Cost_Exceptions
1248 then
1249 Error_Msg_File_1 := ALIs.Table (A1).Sfile;
1250 Error_Msg_File_2 := ALIs.Table (ALIs.First).Sfile;
1252 Consistency_Error_Msg
1253 ("{ and { compiled with different exception handling "
1254 & "mechanisms");
1255 end if;
1256 end loop Check_Mechanism;
1257 end Check_Consistent_Exception_Handling;
1259 -------------------------------
1260 -- Check_Duplicated_Subunits --
1261 -------------------------------
1263 procedure Check_Duplicated_Subunits is
1264 begin
1265 for J in Sdep.First .. Sdep.Last loop
1266 if Sdep.Table (J).Subunit_Name /= No_Name then
1267 Get_Decoded_Name_String (Sdep.Table (J).Subunit_Name);
1268 Name_Len := Name_Len + 2;
1269 Name_Buffer (Name_Len - 1) := '%';
1271 -- See if there is a body or spec with the same name
1273 for K in Boolean loop
1274 if K then
1275 Name_Buffer (Name_Len) := 'b';
1276 else
1277 Name_Buffer (Name_Len) := 's';
1278 end if;
1280 declare
1281 Unit : constant Unit_Name_Type := Name_Find;
1282 Info : constant Int := Get_Name_Table_Int (Unit);
1284 begin
1285 if Info /= 0 then
1286 Set_Standard_Error;
1287 Write_Str ("error: subunit """);
1288 Write_Name_Decoded (Sdep.Table (J).Subunit_Name);
1289 Write_Str (""" in file """);
1290 Write_Name_Decoded (Sdep.Table (J).Sfile);
1291 Write_Char ('"');
1292 Write_Eol;
1293 Write_Str (" has same name as unit """);
1294 Write_Unit_Name (Units.Table (Unit_Id (Info)).Uname);
1295 Write_Str (""" found in file """);
1296 Write_Name_Decoded (Units.Table (Unit_Id (Info)).Sfile);
1297 Write_Char ('"');
1298 Write_Eol;
1299 Write_Str (" this is not allowed within a single "
1300 & "partition (RM 10.2(19))");
1301 Write_Eol;
1302 Osint.Exit_Program (Osint.E_Fatal);
1303 end if;
1304 end;
1305 end loop;
1306 end if;
1307 end loop;
1308 end Check_Duplicated_Subunits;
1310 --------------------
1311 -- Check_Versions --
1312 --------------------
1314 procedure Check_Versions is
1315 VL : constant Natural := ALIs.Table (ALIs.First).Ver_Len;
1317 begin
1318 for A in ALIs.First .. ALIs.Last loop
1319 if ALIs.Table (A).Ver_Len /= VL
1320 or else ALIs.Table (A).Ver (1 .. VL) /=
1321 ALIs.Table (ALIs.First).Ver (1 .. VL)
1322 then
1323 -- Version mismatch found; generate error message.
1325 declare
1326 use Gnatvsn;
1328 Prefix : constant String :=
1329 Verbose_Library_Version
1330 (1 .. Verbose_Library_Version'Length
1331 - Library_Version'Length);
1333 type ALI_Version is record
1334 Primary, Secondary : Int range -1 .. Int'Last;
1335 end record;
1337 No_Version : constant ALI_Version := (-1, -1);
1339 function Remove_Prefix (S : String) return String is
1340 (S (S'First + Prefix'Length .. S'Last));
1342 function Extract_Version (S : String) return ALI_Version;
1343 -- Attempts to extract and return a pair of nonnegative library
1344 -- version numbers from the given string; if unsuccessful,
1345 -- then returns No_Version.
1347 ---------------------
1348 -- Extract_Version --
1349 ---------------------
1351 function Extract_Version (S : String) return ALI_Version is
1352 pragma Assert (S'First = 1);
1354 function Int_Value (Img : String) return Int;
1355 -- Using Int'Value leads to complications in
1356 -- building the binder, so DIY.
1358 ---------------
1359 -- Int_Value --
1360 ---------------
1362 function Int_Value (Img : String) return Int is
1363 Result : Nat := 0;
1364 begin
1365 if Img'Length in 1 .. 9
1366 and then (for all C of Img => C in '0' .. '9')
1367 then
1368 for C of Img loop
1369 Result := (10 * Result) +
1370 (Character'Pos (C) - Character'Pos ('0'));
1371 end loop;
1372 return Result;
1373 else
1374 return -1;
1375 end if;
1376 end Int_Value;
1378 begin
1379 if S'Length > Prefix'Length
1380 and then S (1 .. Prefix'Length) = Prefix
1381 then
1382 declare
1383 Suffix : constant String := Remove_Prefix (S);
1384 Dot_Found : Boolean := False;
1385 Primary, Secondary : Int;
1386 begin
1387 for Dot_Index in Suffix'Range loop
1388 if Suffix (Dot_Index) = '.' then
1389 Dot_Found := True;
1390 Primary :=
1391 Int_Value (Suffix (Suffix'First
1392 .. Dot_Index - 1));
1393 Secondary :=
1394 Int_Value (Suffix (Dot_Index + 1
1395 .. Suffix'Last));
1396 exit;
1397 end if;
1398 end loop;
1400 if not Dot_Found then
1401 Primary := Int_Value (Suffix);
1402 Secondary := 0;
1403 end if;
1405 if (Primary /= -1) and (Secondary /= -1) then
1406 return (Primary => Primary,
1407 Secondary => Secondary);
1408 end if;
1409 end;
1410 end if;
1411 return No_Version;
1412 end Extract_Version;
1414 -- Local constants
1416 V1_Text : constant String :=
1417 ALIs.Table (A).Ver (1 .. ALIs.Table (A).Ver_Len);
1418 V2_Text : constant String :=
1419 ALIs.Table (ALIs.First).Ver (1 .. VL);
1420 V1 : constant ALI_Version := Extract_Version (V1_Text);
1421 V2 : constant ALI_Version := Extract_Version (V2_Text);
1423 Include_Version_Numbers_In_Message : constant Boolean :=
1424 (V1 /= V2) and (V1 /= No_Version) and (V2 /= No_Version);
1425 begin
1426 Error_Msg_File_1 := ALIs.Table (A).Sfile;
1427 Error_Msg_File_2 := ALIs.Table (ALIs.First).Sfile;
1429 if Include_Version_Numbers_In_Message then
1430 if V1.Secondary = V2.Secondary then
1431 -- Excluding equal secondary values from error
1432 -- message text matters for generating reproducible
1433 -- regression test outputs.
1435 Error_Msg_Nat_1 := V1.Primary;
1436 Error_Msg_Nat_2 := V2.Primary;
1437 Consistency_Error_Msg
1438 ("{ and { compiled with different GNAT versions"
1439 & ", v# and v#");
1440 else
1441 Consistency_Error_Msg
1442 ("{ and { compiled with different GNAT versions"
1443 & ", v"
1444 & Remove_Prefix (V1_Text)
1445 & " and v"
1446 & Remove_Prefix (V2_Text));
1447 end if;
1448 else
1449 Consistency_Error_Msg
1450 ("{ and { compiled with different GNAT versions");
1451 end if;
1452 end;
1453 end if;
1454 end loop;
1455 end Check_Versions;
1457 ---------------------------
1458 -- Consistency_Error_Msg --
1459 ---------------------------
1461 procedure Consistency_Error_Msg (Msg : String) is
1462 begin
1463 if Tolerate_Consistency_Errors then
1465 -- If consistency errors are tolerated,
1466 -- output the message as a warning.
1468 Error_Msg ('?' & Msg);
1470 -- Otherwise the consistency error is a true error
1472 else
1473 Error_Msg (Msg);
1474 end if;
1475 end Consistency_Error_Msg;
1477 ---------------
1478 -- Same_Unit --
1479 ---------------
1481 function Same_Unit (U1 : Unit_Name_Type; U2 : Name_Id) return Boolean is
1482 begin
1483 -- Note, the string U1 has a terminating %s or %b, U2 does not
1485 if Length_Of_Name (U1) - 2 = Length_Of_Name (U2) then
1486 Get_Name_String (U1);
1488 declare
1489 U1_Str : constant String := Name_Buffer (1 .. Name_Len - 2);
1490 begin
1491 Get_Name_String (U2);
1492 return U1_Str = Name_Buffer (1 .. Name_Len);
1493 end;
1495 else
1496 return False;
1497 end if;
1498 end Same_Unit;
1500 end Bcheck;