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 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 with Butil; use Butil;
29 with Output; use Output;
31 package body Binderr is
37 procedure Error_Msg (Msg : String) is
39 if Msg (Msg'First) = '?' then
40 if Warning_Mode = Suppress then
44 if Warning_Mode = Treat_As_Error then
45 Errors_Detected := Errors_Detected + 1;
47 Warnings_Detected := Warnings_Detected + 1;
51 Errors_Detected := Errors_Detected + 1;
54 if Brief_Output or else (not Verbose_Mode) then
56 Error_Msg_Output (Msg, Info => False);
61 if Errors_Detected + Warnings_Detected = 0 then
65 Error_Msg_Output (Msg, Info => False);
68 if Warnings_Detected + Errors_Detected > Maximum_Errors then
69 raise Unrecoverable_Error;
78 procedure Error_Msg_Info (Msg : String) is
80 if Brief_Output or else (not Verbose_Mode) then
82 Error_Msg_Output (Msg, Info => True);
87 Error_Msg_Output (Msg, Info => True);
92 ----------------------
93 -- Error_Msg_Output --
94 ----------------------
96 procedure Error_Msg_Output (Msg : String; Info : Boolean) is
97 Use_Second_File : Boolean := False;
98 Use_Second_Unit : Boolean := False;
99 Use_Second_Nat : Boolean := False;
100 Warning : Boolean := False;
103 if Warnings_Detected + Errors_Detected > Maximum_Errors then
104 Write_Str ("error: maximum errors exceeded");
109 -- First, check for warnings
111 for J in Msg'Range loop
112 if Msg (J) = '?' then
119 Write_Str ("warning: ");
121 if not Info_Prefix_Suppress then
122 Write_Str ("info: ");
125 Write_Str ("error: ");
128 for J in Msg'Range loop
129 if Msg (J) = '%' then
130 Get_Name_String (Error_Msg_Name_1);
132 Write_Str (Name_Buffer (1 .. Name_Len));
135 elsif Msg (J) = '{' then
136 if Use_Second_File then
137 Get_Name_String (Error_Msg_File_2);
139 Use_Second_File := True;
140 Get_Name_String (Error_Msg_File_1);
144 Write_Str (Name_Buffer (1 .. Name_Len));
147 elsif Msg (J) = '$' then
150 if Use_Second_Unit then
151 Write_Unit_Name (Error_Msg_Unit_2);
153 Use_Second_Unit := True;
154 Write_Unit_Name (Error_Msg_Unit_1);
159 elsif Msg (J) = '#' then
160 if Use_Second_Nat then
161 Write_Int (Error_Msg_Nat_2);
163 Use_Second_Nat := True;
164 Write_Int (Error_Msg_Nat_1);
167 elsif Msg (J) /= '?' then
168 Write_Char (Msg (J));
173 end Error_Msg_Output;
175 ----------------------
176 -- Finalize_Binderr --
177 ----------------------
179 procedure Finalize_Binderr is
181 -- Message giving number of errors detected (verbose mode only)
186 if Errors_Detected = 0 then
187 Write_Str ("No errors");
189 elsif Errors_Detected = 1 then
190 Write_Str ("1 error");
193 Write_Int (Errors_Detected);
194 Write_Str (" errors");
197 if Warnings_Detected = 1 then
198 Write_Str (", 1 warning");
200 elsif Warnings_Detected > 1 then
202 Write_Int (Warnings_Detected);
203 Write_Str (" warnings");
208 end Finalize_Binderr;
210 ------------------------
211 -- Initialize_Binderr --
212 ------------------------
214 procedure Initialize_Binderr is
216 Errors_Detected := 0;
217 Warnings_Detected := 0;
218 end Initialize_Binderr;