1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2007, 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 ------------------------------------------------------------------------------
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 Namet; use Namet;
35 with Output; use Output;
36 with Rident; use Rident;
37 with Types; use Types;
39 package body Bcheck is
41 -----------------------
42 -- Local Subprograms --
43 -----------------------
45 -- The following checking subprograms make up the parts of the
46 -- configuration consistency check.
48 procedure Check_Consistent_Dispatching_Policy;
49 procedure Check_Consistent_Dynamic_Elaboration_Checking;
50 procedure Check_Consistent_Floating_Point_Format;
51 procedure Check_Consistent_Interrupt_States;
52 procedure Check_Consistent_Locking_Policy;
53 procedure Check_Consistent_Normalize_Scalars;
54 procedure Check_Consistent_Optimize_Alignment;
55 procedure Check_Consistent_Queuing_Policy;
56 procedure Check_Consistent_Restrictions;
57 procedure Check_Consistent_Zero_Cost_Exception_Handling;
59 procedure Consistency_Error_Msg (Msg : String);
60 -- Produce an error or a warning message, depending on whether an
61 -- inconsistent configuration is permitted or not.
63 function Same_Unit (U1 : Unit_Name_Type; U2 : Name_Id) return Boolean;
64 -- Used to compare two unit names for No_Dependence checks. U1 is in
65 -- standard unit name format, and U2 is in literal form with periods.
67 -------------------------------------
68 -- Check_Configuration_Consistency --
69 -------------------------------------
71 procedure Check_Configuration_Consistency is
73 if Float_Format_Specified /= ' ' then
74 Check_Consistent_Floating_Point_Format;
77 if Queuing_Policy_Specified /= ' ' then
78 Check_Consistent_Queuing_Policy;
81 if Locking_Policy_Specified /= ' ' then
82 Check_Consistent_Locking_Policy;
85 if Zero_Cost_Exceptions_Specified then
86 Check_Consistent_Zero_Cost_Exception_Handling;
89 Check_Consistent_Normalize_Scalars;
90 Check_Consistent_Optimize_Alignment;
91 Check_Consistent_Dynamic_Elaboration_Checking;
92 Check_Consistent_Restrictions;
93 Check_Consistent_Interrupt_States;
94 Check_Consistent_Dispatching_Policy;
95 end Check_Configuration_Consistency;
97 -----------------------
98 -- Check_Consistency --
99 -----------------------
101 procedure Check_Consistency is
103 -- Source file Id for this Sdep entry
105 ALI_Path_Id : File_Name_Type;
108 -- First, we go through the source table to see if there are any cases
109 -- in which we should go after source files and compute checksums of
110 -- the source files. We need to do this for any file for which we have
111 -- mismatching time stamps and (so far) matching checksums.
113 for S in Source.First .. Source.Last loop
115 -- If all time stamps for a file match, then there is nothing to
116 -- do, since we will not be checking checksums in that case anyway
118 if Source.Table (S).All_Timestamps_Match then
121 -- If we did not find the source file, then we can't compute its
122 -- checksum anyway. Note that when we have a time stamp mismatch,
123 -- we try to find the source file unconditionally (i.e. if
124 -- Check_Source_Files is False).
126 elsif not Source.Table (S).Source_Found then
129 -- If we already have non-matching or missing checksums, then no
130 -- need to try going after source file, since we won't trust the
131 -- checksums in any case.
133 elsif not Source.Table (S).All_Checksums_Match then
136 -- Now we have the case where we have time stamp mismatches, and
137 -- the source file is around, but so far all checksums match. This
138 -- is the case where we need to compute the checksum from the source
139 -- file, since otherwise we would ignore the time stamp mismatches,
140 -- and that is wrong if the checksum of the source does not agree
141 -- with the checksums in the ALI files.
143 elsif Check_Source_Files then
144 if not Checksums_Match
145 (Source.Table (S).Checksum,
146 Get_File_Checksum (Source.Table (S).Sfile))
148 Source.Table (S).All_Checksums_Match := False;
153 -- Loop through ALI files
155 ALIs_Loop : for A in ALIs.First .. ALIs.Last loop
157 -- Loop through Sdep entries in one ALI file
160 ALIs.Table (A).First_Sdep .. ALIs.Table (A).Last_Sdep
162 if Sdep.Table (D).Dummy_Entry then
166 Src := Source_Id (Get_Name_Table_Info (Sdep.Table (D).Sfile));
168 -- If the time stamps match, or all checksums match, then we
169 -- are OK, otherwise we have a definite error.
171 if Sdep.Table (D).Stamp /= Source.Table (Src).Stamp
172 and then not Source.Table (Src).All_Checksums_Match
174 Error_Msg_File_1 := ALIs.Table (A).Sfile;
175 Error_Msg_File_2 := Sdep.Table (D).Sfile;
177 -- Two styles of message, depending on whether or not
178 -- the updated file is the one that must be recompiled
180 if Error_Msg_File_1 = Error_Msg_File_2 then
181 if Tolerate_Consistency_Errors then
183 ("?{ has been modified and should be recompiled");
186 ("{ has been modified and must be recompiled");
191 Osint.Find_File ((ALIs.Table (A).Afile), Osint.Library);
192 if Osint.Is_Readonly_Library (ALI_Path_Id) then
193 if Tolerate_Consistency_Errors then
194 Error_Msg ("?{ should be recompiled");
195 Error_Msg_File_1 := ALI_Path_Id;
196 Error_Msg ("?({ is obsolete and read-only)");
198 Error_Msg ("{ must be compiled");
199 Error_Msg_File_1 := ALI_Path_Id;
200 Error_Msg ("({ is obsolete and read-only)");
203 elsif Tolerate_Consistency_Errors then
205 ("?{ should be recompiled ({ has been modified)");
208 Error_Msg ("{ must be recompiled ({ has been modified)");
212 if (not Tolerate_Consistency_Errors) and Verbose_Mode then
213 Error_Msg_File_1 := Sdep.Table (D).Sfile;
215 ("{ time stamp " & String (Source.Table (Src).Stamp));
217 Error_Msg_File_1 := Sdep.Table (D).Sfile;
218 -- Something wrong here, should be different file ???
221 (" conflicts with { timestamp " &
222 String (Sdep.Table (D).Stamp));
225 -- Exit from the loop through Sdep entries once we find one
226 -- that does not match.
235 end Check_Consistency;
237 -----------------------------------------
238 -- Check_Consistent_Dispatching_Policy --
239 -----------------------------------------
241 -- The rule is that all files for which the dispatching policy is
242 -- significant must meet the following rules:
244 -- 1. All files for which a task dispatching policy is significant must
245 -- be compiled with the same setting.
247 -- 2. If a partition contains one or more Priority_Specific_Dispatching
248 -- pragmas it cannot contain a Task_Dispatching_Policy pragma.
250 -- 3. No overlap is allowed in the priority ranges specified in
251 -- Priority_Specific_Dispatching pragmas within the same partition.
253 -- 4. If a partition contains one or more Priority_Specific_Dispatching
254 -- pragmas then the Ceiling_Locking policy is the only one allowed for
257 procedure Check_Consistent_Dispatching_Policy is
259 -- Maximum priority value for which a Priority_Specific_Dispatching
260 -- pragma has been specified.
262 TDP_Pragma_Afile : ALI_Id := No_ALI_Id;
263 -- ALI file where a Task_Dispatching_Policy pragma appears
266 -- Consistency checks in units specifying a Task_Dispatching_Policy
268 if Task_Dispatching_Policy_Specified /= ' ' then
269 Find_Policy : for A1 in ALIs.First .. ALIs.Last loop
270 if ALIs.Table (A1).Task_Dispatching_Policy /= ' ' then
272 -- Store the place where the first task dispatching pragma
273 -- appears. We may need this value for issuing consistency
274 -- errors if Priority_Specific_Dispatching pragmas are used.
276 TDP_Pragma_Afile := A1;
278 Check_Policy : declare
279 Policy : constant Character :=
280 ALIs.Table (A1).Task_Dispatching_Policy;
283 for A2 in A1 + 1 .. ALIs.Last loop
284 if ALIs.Table (A2).Task_Dispatching_Policy /= ' '
286 ALIs.Table (A2).Task_Dispatching_Policy /= Policy
288 Error_Msg_File_1 := ALIs.Table (A1).Sfile;
289 Error_Msg_File_2 := ALIs.Table (A2).Sfile;
291 Consistency_Error_Msg
292 ("{ and { compiled with different task" &
293 " dispatching policies");
301 end loop Find_Policy;
304 -- If no Priority_Specific_Dispatching entries, nothing else to do
306 if Specific_Dispatching.Last >= Specific_Dispatching.First then
308 -- Find out the maximum priority value for which one of the
309 -- Priority_Specific_Dispatching pragmas applies.
312 for J in Specific_Dispatching.First .. Specific_Dispatching.Last loop
313 if Specific_Dispatching.Table (J).Last_Priority > Max_Prio then
314 Max_Prio := Specific_Dispatching.Table (J).Last_Priority;
318 -- Now establish tables to be used for consistency checking
321 -- The following record type is used to record locations of the
322 -- Priority_Specific_Dispatching pragmas applying to the Priority.
324 type Specific_Dispatching_Entry is record
325 Dispatching_Policy : Character := ' ';
326 -- First character (upper case) of corresponding policy name
328 Afile : ALI_Id := No_ALI_Id;
329 -- ALI file that generated Priority Specific Dispatching
330 -- entry for consistency message.
333 -- Line numbers from Priority_Specific_Dispatching pragma
336 PSD_Table : array (0 .. Max_Prio) of Specific_Dispatching_Entry :=
337 (others => Specific_Dispatching_Entry'
338 (Dispatching_Policy => ' ',
341 -- Array containing an entry per priority containing the location
342 -- where there is a Priority_Specific_Dispatching pragma that
343 -- applies to the priority.
346 for F in ALIs.First .. ALIs.Last loop
347 for K in ALIs.Table (F).First_Specific_Dispatching ..
348 ALIs.Table (F).Last_Specific_Dispatching
351 DTK : Specific_Dispatching_Record
352 renames Specific_Dispatching.Table (K);
354 -- Check whether pragma Task_Dispatching_Policy and
355 -- pragma Priority_Specific_Dispatching are used in the
358 if Task_Dispatching_Policy_Specified /= ' ' then
359 Error_Msg_File_1 := ALIs.Table (F).Sfile;
361 ALIs.Table (TDP_Pragma_Afile).Sfile;
363 Error_Msg_Nat_1 := DTK.PSD_Pragma_Line;
365 Consistency_Error_Msg
366 ("Priority_Specific_Dispatching at {:#" &
367 " incompatible with Task_Dispatching_Policy at {");
370 -- Ceiling_Locking must also be specified for a partition
371 -- with at least one Priority_Specific_Dispatching
374 if Locking_Policy_Specified /= ' '
375 and then Locking_Policy_Specified /= 'C'
377 for A in ALIs.First .. ALIs.Last loop
378 if ALIs.Table (A).Locking_Policy /= ' '
379 and then ALIs.Table (A).Locking_Policy /= 'C'
381 Error_Msg_File_1 := ALIs.Table (F).Sfile;
382 Error_Msg_File_2 := ALIs.Table (A).Sfile;
384 Error_Msg_Nat_1 := DTK.PSD_Pragma_Line;
386 Consistency_Error_Msg
387 ("Priority_Specific_Dispatching at {:#" &
388 " incompatible with Locking_Policy at {");
393 -- Check overlapping priority ranges
395 Find_Overlapping : for Prio in
396 DTK.First_Priority .. DTK.Last_Priority
398 if PSD_Table (Prio).Afile = No_ALI_Id then
400 (Dispatching_Policy => DTK.Dispatching_Policy,
401 Afile => F, Loc => DTK.PSD_Pragma_Line);
403 elsif PSD_Table (Prio).Dispatching_Policy /=
404 DTK.Dispatching_Policy
408 ALIs.Table (PSD_Table (Prio).Afile).Sfile;
409 Error_Msg_File_2 := ALIs.Table (F).Sfile;
410 Error_Msg_Nat_1 := PSD_Table (Prio).Loc;
411 Error_Msg_Nat_2 := DTK.PSD_Pragma_Line;
413 Consistency_Error_Msg
414 ("overlapping priority ranges at {:# and {:#");
416 exit Find_Overlapping;
418 end loop Find_Overlapping;
424 end Check_Consistent_Dispatching_Policy;
426 ---------------------------------------------------
427 -- Check_Consistent_Dynamic_Elaboration_Checking --
428 ---------------------------------------------------
430 -- The rule here is that if a unit has dynamic elaboration checks,
431 -- then any unit it withs must meeting one of the following criteria:
433 -- 1. There is a pragma Elaborate_All for the with'ed unit
434 -- 2. The with'ed unit was compiled with dynamic elaboration checks
435 -- 3. The with'ed unit has pragma Preelaborate or Pure
436 -- 4. It is an internal GNAT unit (including children of GNAT)
438 procedure Check_Consistent_Dynamic_Elaboration_Checking is
440 if Dynamic_Elaboration_Checks_Specified then
441 for U in First_Unit_Entry .. Units.Last loop
443 UR : Unit_Record renames Units.Table (U);
446 if UR.Dynamic_Elab then
447 for W in UR.First_With .. UR.Last_With loop
449 WR : With_Record renames Withs.Table (W);
452 if Get_Name_Table_Info (WR.Uname) /= 0 then
454 WU : Unit_Record renames
457 (Get_Name_Table_Info (WR.Uname)));
460 -- Case 1. Elaborate_All for with'ed unit
462 if WR.Elaborate_All then
465 -- Case 2. With'ed unit has dynamic elab checks
467 elsif WU.Dynamic_Elab then
470 -- Case 3. With'ed unit is Preelaborate or Pure
472 elsif WU.Preelab or WU.Pure then
475 -- Case 4. With'ed unit is internal file
477 elsif Is_Internal_File_Name (WU.Sfile) then
480 -- Issue warning, not one of the safe cases
483 Error_Msg_File_1 := UR.Sfile;
485 ("?{ has dynamic elaboration checks " &
488 Error_Msg_File_1 := WU.Sfile;
490 ("? { which has static elaboration " &
493 Warnings_Detected := Warnings_Detected - 1;
503 end Check_Consistent_Dynamic_Elaboration_Checking;
505 --------------------------------------------
506 -- Check_Consistent_Floating_Point_Format --
507 --------------------------------------------
509 -- The rule is that all files must be compiled with the same setting
510 -- for the floating-point format.
512 procedure Check_Consistent_Floating_Point_Format is
514 -- First search for a unit specifying a floating-point format and then
515 -- check all remaining units against it.
517 Find_Format : for A1 in ALIs.First .. ALIs.Last loop
518 if ALIs.Table (A1).Float_Format /= ' ' then
519 Check_Format : declare
520 Format : constant Character := ALIs.Table (A1).Float_Format;
522 for A2 in A1 + 1 .. ALIs.Last loop
523 if ALIs.Table (A2).Float_Format /= Format then
524 Error_Msg_File_1 := ALIs.Table (A1).Sfile;
525 Error_Msg_File_2 := ALIs.Table (A2).Sfile;
527 Consistency_Error_Msg
528 ("{ and { compiled with different " &
529 "floating-point representations");
537 end loop Find_Format;
538 end Check_Consistent_Floating_Point_Format;
540 ---------------------------------------
541 -- Check_Consistent_Interrupt_States --
542 ---------------------------------------
544 -- The rule is that if the state of a given interrupt is specified
545 -- in more than one unit, it must be specified with a consistent state.
547 procedure Check_Consistent_Interrupt_States is
551 -- If no Interrupt_State entries, nothing to do
553 if Interrupt_States.Last < Interrupt_States.First then
557 -- First find out the maximum interrupt value
560 for J in Interrupt_States.First .. Interrupt_States.Last loop
561 if Interrupt_States.Table (J).Interrupt_Id > Max_Intrup then
562 Max_Intrup := Interrupt_States.Table (J).Interrupt_Id;
566 -- Now establish tables to be used for consistency checking
569 Istate : array (0 .. Max_Intrup) of Character := (others => 'n');
570 -- Interrupt state entries, 'u'/'s'/'r' or 'n' to indicate an
571 -- entry that has not been set.
573 Afile : array (0 .. Max_Intrup) of ALI_Id;
574 -- ALI file that generated Istate entry for consistency message
576 Loc : array (0 .. Max_Intrup) of Nat;
577 -- Line numbers from IS pragma generating Istate entry
580 -- Interrupt number from entry being tested
583 -- Interrupt state from entry being tested
586 -- Line number from entry being tested
589 for F in ALIs.First .. ALIs.Last loop
590 for K in ALIs.Table (F).First_Interrupt_State ..
591 ALIs.Table (F).Last_Interrupt_State
593 Inum := Interrupt_States.Table (K).Interrupt_Id;
594 Stat := Interrupt_States.Table (K).Interrupt_State;
595 Lnum := Interrupt_States.Table (K).IS_Pragma_Line;
597 if Istate (Inum) = 'n' then
598 Istate (Inum) := Stat;
602 elsif Istate (Inum) /= Stat then
603 Error_Msg_File_1 := ALIs.Table (Afile (Inum)).Sfile;
604 Error_Msg_File_2 := ALIs.Table (F).Sfile;
605 Error_Msg_Nat_1 := Loc (Inum);
606 Error_Msg_Nat_2 := Lnum;
608 Consistency_Error_Msg
609 ("inconsistent interrupt states at {:# and {:#");
614 end Check_Consistent_Interrupt_States;
616 -------------------------------------
617 -- Check_Consistent_Locking_Policy --
618 -------------------------------------
620 -- The rule is that all files for which the locking policy is
621 -- significant must be compiled with the same setting.
623 procedure Check_Consistent_Locking_Policy is
625 -- First search for a unit specifying a policy and then
626 -- check all remaining units against it.
628 Find_Policy : for A1 in ALIs.First .. ALIs.Last loop
629 if ALIs.Table (A1).Locking_Policy /= ' ' then
630 Check_Policy : declare
631 Policy : constant Character := ALIs.Table (A1).Locking_Policy;
634 for A2 in A1 + 1 .. ALIs.Last loop
635 if ALIs.Table (A2).Locking_Policy /= ' ' and
636 ALIs.Table (A2).Locking_Policy /= Policy
638 Error_Msg_File_1 := ALIs.Table (A1).Sfile;
639 Error_Msg_File_2 := ALIs.Table (A2).Sfile;
641 Consistency_Error_Msg
642 ("{ and { compiled with different locking policies");
650 end loop Find_Policy;
651 end Check_Consistent_Locking_Policy;
653 ----------------------------------------
654 -- Check_Consistent_Normalize_Scalars --
655 ----------------------------------------
657 -- The rule is that if any unit is compiled with Normalized_Scalars,
658 -- then all other units in the partition must also be compiled with
659 -- Normalized_Scalars in effect.
661 -- There is some issue as to whether this consistency check is desirable,
662 -- it is certainly required at the moment by the RM. We should keep a watch
663 -- on the ARG and HRG deliberations here. GNAT no longer depends on this
664 -- consistency (it used to do so, but that is no longer the case, since
665 -- pragma Initialize_Scalars pragma does not require consistency.)
667 procedure Check_Consistent_Normalize_Scalars is
669 if Normalize_Scalars_Specified and No_Normalize_Scalars_Specified then
670 Consistency_Error_Msg
671 ("some but not all files compiled with Normalize_Scalars");
674 Write_Str ("files compiled with Normalize_Scalars");
677 for A1 in ALIs.First .. ALIs.Last loop
678 if ALIs.Table (A1).Normalize_Scalars then
680 Write_Name (ALIs.Table (A1).Sfile);
686 Write_Str ("files compiled without Normalize_Scalars");
689 for A1 in ALIs.First .. ALIs.Last loop
690 if not ALIs.Table (A1).Normalize_Scalars then
692 Write_Name (ALIs.Table (A1).Sfile);
697 end Check_Consistent_Normalize_Scalars;
699 -----------------------------------------
700 -- Check_Consistent_Optimize_Alignment --
701 -----------------------------------------
703 -- The rule is that all units other than internal units must be compiled
704 -- with the same setting for Optimize_Alignment. We can exclude internal
705 -- units since they are forced to compile with Optimize_Alignment (Off).
707 procedure Check_Consistent_Optimize_Alignment is
708 OA_Setting : Character := ' ';
709 -- Reset when we find a non-internal unit
712 -- Id of unit from which OA_Setting was set
715 for A in ALIs.First .. ALIs.Last loop
716 if not Is_Internal_File_Name (ALIs.Table (A).Afile) then
717 if OA_Setting = ' ' then
718 OA_Setting := ALIs.Table (A).Optimize_Alignment_Setting;
721 elsif OA_Setting = ALIs.Table (A).Optimize_Alignment_Setting then
725 Error_Msg_File_1 := ALIs.Table (OA_Unit).Sfile;
726 Error_Msg_File_2 := ALIs.Table (A).Sfile;
728 Consistency_Error_Msg
729 ("{ and { compiled with different "
730 & "Optimize_Alignment settings");
735 end Check_Consistent_Optimize_Alignment;
737 -------------------------------------
738 -- Check_Consistent_Queuing_Policy --
739 -------------------------------------
741 -- The rule is that all files for which the queuing policy is
742 -- significant must be compiled with the same setting.
744 procedure Check_Consistent_Queuing_Policy is
746 -- First search for a unit specifying a policy and then
747 -- check all remaining units against it.
749 Find_Policy : for A1 in ALIs.First .. ALIs.Last loop
750 if ALIs.Table (A1).Queuing_Policy /= ' ' then
751 Check_Policy : declare
752 Policy : constant Character := ALIs.Table (A1).Queuing_Policy;
754 for A2 in A1 + 1 .. ALIs.Last loop
755 if ALIs.Table (A2).Queuing_Policy /= ' '
757 ALIs.Table (A2).Queuing_Policy /= Policy
759 Error_Msg_File_1 := ALIs.Table (A1).Sfile;
760 Error_Msg_File_2 := ALIs.Table (A2).Sfile;
762 Consistency_Error_Msg
763 ("{ and { compiled with different queuing policies");
771 end loop Find_Policy;
772 end Check_Consistent_Queuing_Policy;
774 -----------------------------------
775 -- Check_Consistent_Restrictions --
776 -----------------------------------
778 -- The rule is that if a restriction is specified in any unit,
779 -- then all units must obey the restriction. The check applies
780 -- only to restrictions which require partition wide consistency,
781 -- and not to internal units.
783 procedure Check_Consistent_Restrictions is
784 Restriction_File_Output : Boolean;
785 -- Shows if we have output header messages for restriction violation
787 procedure Print_Restriction_File (R : All_Restrictions);
788 -- Print header line for R if not printed yet
790 ----------------------------
791 -- Print_Restriction_File --
792 ----------------------------
794 procedure Print_Restriction_File (R : All_Restrictions) is
796 if not Restriction_File_Output then
797 Restriction_File_Output := True;
799 -- Find an ali file specifying the restriction
801 for A in ALIs.First .. ALIs.Last loop
802 if ALIs.Table (A).Restrictions.Set (R)
803 and then (R in All_Boolean_Restrictions
804 or else ALIs.Table (A).Restrictions.Value (R) =
805 Cumulative_Restrictions.Value (R))
807 -- We have found that ALI file A specifies the restriction
808 -- that is being violated (the minimum value is specified
809 -- in the case of a parameter restriction).
812 M1 : constant String := "{ has restriction ";
813 S : constant String := Restriction_Id'Image (R);
814 M2 : String (1 .. 200); -- big enough!
818 Name_Buffer (1 .. S'Length) := S;
819 Name_Len := S'Length;
820 Set_Casing (Mixed_Case);
824 M2 (P .. P + S'Length - 1) := Name_Buffer (1 .. S'Length);
827 if R in All_Parameter_Restrictions then
828 M2 (P .. P + 4) := " => #";
830 Int (Cumulative_Restrictions.Value (R));
834 Error_Msg_File_1 := ALIs.Table (A).Sfile;
835 Consistency_Error_Msg (M2 (1 .. P - 1));
836 Consistency_Error_Msg
837 ("but the following files violate this restriction:");
843 end Print_Restriction_File;
845 -- Start of processing for Check_Consistent_Restrictions
848 -- Loop through all restriction violations
850 for R in All_Restrictions loop
852 -- Check for violation of this restriction
854 if Cumulative_Restrictions.Set (R)
855 and then Cumulative_Restrictions.Violated (R)
856 and then (R in Partition_Boolean_Restrictions
857 or else (R in All_Parameter_Restrictions
859 Cumulative_Restrictions.Count (R) >
860 Cumulative_Restrictions.Value (R)))
862 Restriction_File_Output := False;
864 -- Loop through files looking for violators
866 for A2 in ALIs.First .. ALIs.Last loop
868 T : ALIs_Record renames ALIs.Table (A2);
871 if T.Restrictions.Violated (R) then
873 -- We exclude predefined files from the list of
874 -- violators. This should be rethought. It is not
875 -- clear that this is the right thing to do, that
876 -- is particularly the case for restricted runtimes.
878 if not Is_Internal_File_Name (T.Sfile) then
880 -- Case of Boolean restriction, just print file name
882 if R in All_Boolean_Restrictions then
883 Print_Restriction_File (R);
884 Error_Msg_File_1 := T.Sfile;
885 Consistency_Error_Msg (" {");
887 -- Case of Parameter restriction where violation
888 -- count exceeds restriction value, print file
889 -- name and count, adding "at least" if the
890 -- exact count is not known.
892 elsif R in Checked_Add_Parameter_Restrictions
893 or else T.Restrictions.Count (R) >
894 Cumulative_Restrictions.Value (R)
896 Print_Restriction_File (R);
897 Error_Msg_File_1 := T.Sfile;
898 Error_Msg_Nat_1 := Int (T.Restrictions.Count (R));
900 if T.Restrictions.Unknown (R) then
901 Consistency_Error_Msg
902 (" { (count = at least #)");
904 Consistency_Error_Msg
915 -- Now deal with No_Dependence indications. Note that we put the loop
916 -- through entries in the no dependency table first, since this loop
917 -- is most often empty (no such pragma Restrictions in use).
919 for ND in No_Deps.First .. No_Deps.Last loop
921 ND_Unit : constant Name_Id :=
922 No_Deps.Table (ND).No_Dep_Unit;
925 for J in ALIs.First .. ALIs.Last loop
927 A : ALIs_Record renames ALIs.Table (J);
930 for K in A.First_Unit .. A.Last_Unit loop
932 U : Unit_Record renames Units.Table (K);
934 for L in U.First_With .. U.Last_With loop
936 (Withs.Table (L).Uname, ND_Unit)
938 Error_Msg_File_1 := U.Sfile;
939 Error_Msg_Name_1 := ND_Unit;
940 Consistency_Error_Msg
941 ("file { violates restriction " &
942 "No_Dependence => %");
951 end Check_Consistent_Restrictions;
953 ---------------------------------------------------
954 -- Check_Consistent_Zero_Cost_Exception_Handling --
955 ---------------------------------------------------
957 -- Check consistent zero cost exception handling. The rule is that
958 -- all units must have the same exception handling mechanism.
960 procedure Check_Consistent_Zero_Cost_Exception_Handling is
962 Check_Mechanism : for A1 in ALIs.First + 1 .. ALIs.Last loop
963 if ALIs.Table (A1).Zero_Cost_Exceptions /=
964 ALIs.Table (ALIs.First).Zero_Cost_Exceptions
966 Error_Msg_File_1 := ALIs.Table (A1).Sfile;
967 Error_Msg_File_2 := ALIs.Table (ALIs.First).Sfile;
969 Consistency_Error_Msg ("{ and { compiled with different "
970 & "exception handling mechanisms");
972 end loop Check_Mechanism;
973 end Check_Consistent_Zero_Cost_Exception_Handling;
975 -------------------------------
976 -- Check_Duplicated_Subunits --
977 -------------------------------
979 procedure Check_Duplicated_Subunits is
981 for J in Sdep.First .. Sdep.Last loop
982 if Sdep.Table (J).Subunit_Name /= No_Name then
983 Get_Decoded_Name_String (Sdep.Table (J).Subunit_Name);
984 Name_Len := Name_Len + 2;
985 Name_Buffer (Name_Len - 1) := '%';
987 -- See if there is a body or spec with the same name
989 for K in Boolean loop
991 Name_Buffer (Name_Len) := 'b';
993 Name_Buffer (Name_Len) := 's';
997 Unit : constant Unit_Name_Type := Name_Find;
998 Info : constant Int := Get_Name_Table_Info (Unit);
1003 Write_Str ("error: subunit """);
1004 Write_Name_Decoded (Sdep.Table (J).Subunit_Name);
1005 Write_Str (""" in file """);
1006 Write_Name_Decoded (Sdep.Table (J).Sfile);
1009 Write_Str (" has same name as unit """);
1010 Write_Unit_Name (Units.Table (Unit_Id (Info)).Uname);
1011 Write_Str (""" found in file """);
1012 Write_Name_Decoded (Units.Table (Unit_Id (Info)).Sfile);
1015 Write_Str (" this is not allowed within a single "
1016 & "partition (RM 10.2(19))");
1018 Osint.Exit_Program (Osint.E_Fatal);
1024 end Check_Duplicated_Subunits;
1026 --------------------
1027 -- Check_Versions --
1028 --------------------
1030 procedure Check_Versions is
1031 VL : constant Natural := ALIs.Table (ALIs.First).Ver_Len;
1034 for A in ALIs.First .. ALIs.Last loop
1035 if ALIs.Table (A).Ver_Len /= VL
1036 or else ALIs.Table (A).Ver (1 .. VL) /=
1037 ALIs.Table (ALIs.First).Ver (1 .. VL)
1039 Error_Msg_File_1 := ALIs.Table (A).Sfile;
1040 Error_Msg_File_2 := ALIs.Table (ALIs.First).Sfile;
1042 Consistency_Error_Msg
1043 ("{ and { compiled with different GNAT versions");
1048 ---------------------------
1049 -- Consistency_Error_Msg --
1050 ---------------------------
1052 procedure Consistency_Error_Msg (Msg : String) is
1054 if Tolerate_Consistency_Errors then
1056 -- If consistency errors are tolerated,
1057 -- output the message as a warning.
1060 Warning_Msg : String (1 .. Msg'Length + 1);
1063 Warning_Msg (1) := '?';
1064 Warning_Msg (2 .. Warning_Msg'Last) := Msg;
1066 Error_Msg (Warning_Msg);
1069 -- Otherwise the consistency error is a true error
1074 end Consistency_Error_Msg;
1080 function Same_Unit (U1 : Unit_Name_Type; U2 : Name_Id) return Boolean is
1082 -- Note, the string U1 has a terminating %s or %b, U2 does not
1084 if Length_Of_Name (U1) - 2 = Length_Of_Name (U2) then
1085 Get_Name_String (U1);
1088 U1_Str : constant String := Name_Buffer (1 .. Name_Len - 2);
1090 Get_Name_String (U2);
1091 return U1_Str = Name_Buffer (1 .. Name_Len);