annotate gcc/ada/erroutc.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- E R R O U T C --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- This packages contains global variables and routines common to error
kono
parents:
diff changeset
27 -- reporting packages, including Errout and Prj.Err.
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 with Table;
kono
parents:
diff changeset
30 with Types; use Types;
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 package Erroutc is
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 Class_Flag : Boolean := False;
kono
parents:
diff changeset
35 -- This flag is set True when outputting a reference to a class-wide
kono
parents:
diff changeset
36 -- type, and is used by Add_Class to insert 'Class at the proper point
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 Continuation : Boolean := False;
kono
parents:
diff changeset
39 -- Indicates if current message is a continuation. Initialized from the
kono
parents:
diff changeset
40 -- Msg_Cont parameter in Error_Msg_Internal and then set True if a \
kono
parents:
diff changeset
41 -- insertion character is encountered.
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 Continuation_New_Line : Boolean := False;
kono
parents:
diff changeset
44 -- Indicates if current message was a continuation line marked with \\ to
kono
parents:
diff changeset
45 -- force a new line. Set True if \\ encountered.
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 Flag_Source : Source_File_Index;
kono
parents:
diff changeset
48 -- Source file index for source file where error is being posted
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 Has_Double_Exclam : Boolean := False;
kono
parents:
diff changeset
51 -- Set true to indicate that the current message contains the insertion
kono
parents:
diff changeset
52 -- sequence !! (force warnings even in non-main unit source files).
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 Is_Serious_Error : Boolean := False;
kono
parents:
diff changeset
55 -- Set True for a serious error (i.e. any message that is not a warning
kono
parents:
diff changeset
56 -- or style message, and that does not contain a | insertion character).
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 Is_Unconditional_Msg : Boolean := False;
kono
parents:
diff changeset
59 -- Set True to indicate that the current message contains the insertion
kono
parents:
diff changeset
60 -- character ! and is thus to be treated as an unconditional message.
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 Is_Warning_Msg : Boolean := False;
kono
parents:
diff changeset
63 -- Set True to indicate if current message is warning message (contains ?
kono
parents:
diff changeset
64 -- or contains < and Error_Msg_Warn is True.
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 Is_Info_Msg : Boolean := False;
kono
parents:
diff changeset
67 -- Set True to indicate that the current message starts with the characters
kono
parents:
diff changeset
68 -- "info: " and is to be treated as an information message. This string
kono
parents:
diff changeset
69 -- will be prepended to the message and all its continuations.
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 Is_Check_Msg : Boolean := False;
kono
parents:
diff changeset
72 -- Set True to indicate that the current message starts with one of
kono
parents:
diff changeset
73 -- "high: ", "medium: ", "low: " and is to be treated as a check message.
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 Warning_Msg_Char : Character;
kono
parents:
diff changeset
76 -- Warning character, valid only if Is_Warning_Msg is True
kono
parents:
diff changeset
77 -- ' ' -- ? or < appeared on its own in message
kono
parents:
diff changeset
78 -- '?' -- ?? or << appeared in message
kono
parents:
diff changeset
79 -- 'x' -- ?x? or <x< appeared in message (x = a .. z)
kono
parents:
diff changeset
80 -- 'X' -- ?X? or <X< appeared in message (X = A .. Z)
kono
parents:
diff changeset
81 -- '*' -- ?*? or <*< appeared in message
kono
parents:
diff changeset
82 -- '$' -- ?$? or <$< appeared in message
kono
parents:
diff changeset
83 -- In the case of the < sequences, this is set only if the message is
kono
parents:
diff changeset
84 -- actually a warning, i.e. if Error_Msg_Warn is True
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 Is_Style_Msg : Boolean := False;
kono
parents:
diff changeset
87 -- Set True to indicate if the current message is a style message
kono
parents:
diff changeset
88 -- (i.e. a message whose text starts with the characters "(style)").
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 Kill_Message : Boolean := False;
kono
parents:
diff changeset
91 -- A flag used to kill weird messages (e.g. those containing uninterpreted
kono
parents:
diff changeset
92 -- implicit type references) if we have already seen at least one message
kono
parents:
diff changeset
93 -- already. The idea is that we hope the weird message is a junk cascaded
kono
parents:
diff changeset
94 -- message that should be suppressed.
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 Last_Killed : Boolean := False;
kono
parents:
diff changeset
97 -- Set True if the most recently posted non-continuation message was
kono
parents:
diff changeset
98 -- killed. This is used to determine the processing of any continuation
kono
parents:
diff changeset
99 -- messages that follow.
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 List_Pragmas_Index : Int := 0;
kono
parents:
diff changeset
102 -- Index into List_Pragmas table
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 List_Pragmas_Mode : Boolean := False;
kono
parents:
diff changeset
105 -- Starts True, gets set False by pragma List (Off), True by List (On)
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 Manual_Quote_Mode : Boolean := False;
kono
parents:
diff changeset
108 -- Set True in manual quotation mode
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 Max_Msg_Length : constant := 1024 + 2 * Int (Column_Number'Last);
kono
parents:
diff changeset
111 -- Maximum length of error message. The addition of 2 * Column_Number'Last
kono
parents:
diff changeset
112 -- ensures that two insertion tokens of maximum length can be accommodated.
kono
parents:
diff changeset
113 -- The value of 1024 is an arbitrary value that should be more than long
kono
parents:
diff changeset
114 -- enough to accommodate any reasonable message (and for that matter, some
kono
parents:
diff changeset
115 -- pretty unreasonable messages).
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 Msg_Buffer : String (1 .. Max_Msg_Length);
kono
parents:
diff changeset
118 -- Buffer used to prepare error messages
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 Msglen : Integer := 0;
kono
parents:
diff changeset
121 -- Number of characters currently stored in the message buffer
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 Suppress_Message : Boolean;
kono
parents:
diff changeset
124 -- A flag used to suppress certain obviously redundant messages (i.e.
kono
parents:
diff changeset
125 -- those referring to a node whose type is Any_Type). This suppression
kono
parents:
diff changeset
126 -- is effective only if All_Errors_Mode is off.
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 Suppress_Instance_Location : Boolean := False;
kono
parents:
diff changeset
129 -- Normally, if a # location in a message references a location within
kono
parents:
diff changeset
130 -- a generic template, then a note is added giving the location of the
kono
parents:
diff changeset
131 -- instantiation. If this variable is set True, then this note is not
kono
parents:
diff changeset
132 -- output. This is used for internal processing for the case of an
kono
parents:
diff changeset
133 -- illegal instantiation. See Error_Msg routine for further details.
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 type Subprogram_Name_Type is access function (N : Node_Id) return String;
kono
parents:
diff changeset
136 Subprogram_Name_Ptr : Subprogram_Name_Type;
kono
parents:
diff changeset
137 -- Indirect call to Sem_Util.Subprogram_Name to break circular
kono
parents:
diff changeset
138 -- dependency with the static elaboration model.
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 ----------------------------
kono
parents:
diff changeset
141 -- Message ID Definitions --
kono
parents:
diff changeset
142 ----------------------------
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 type Error_Msg_Id is new Int;
kono
parents:
diff changeset
145 -- A type used to represent specific error messages. Used by the clients
kono
parents:
diff changeset
146 -- of this package only in the context of the Get_Error_Id and
kono
parents:
diff changeset
147 -- Change_Error_Text subprograms.
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 No_Error_Msg : constant Error_Msg_Id := 0;
kono
parents:
diff changeset
150 -- A constant which is different from any value returned by Get_Error_Id.
kono
parents:
diff changeset
151 -- Typically used by a client to indicate absence of a saved Id value.
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 Cur_Msg : Error_Msg_Id := No_Error_Msg;
kono
parents:
diff changeset
154 -- Id of most recently posted error message
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 function Get_Msg_Id return Error_Msg_Id;
kono
parents:
diff changeset
157 -- Returns the Id of the message most recently posted using one of the
kono
parents:
diff changeset
158 -- Error_Msg routines.
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 function Get_Location (E : Error_Msg_Id) return Source_Ptr;
kono
parents:
diff changeset
161 -- Returns the flag location of the error message with the given id E
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 -----------------------------------
kono
parents:
diff changeset
164 -- Error Message Data Structures --
kono
parents:
diff changeset
165 -----------------------------------
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 -- The error messages are stored as a linked list of error message objects
kono
parents:
diff changeset
168 -- sorted into ascending order by the source location (Sloc). Each object
kono
parents:
diff changeset
169 -- records the text of the message and its source location.
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 -- The following record type and table are used to represent error
kono
parents:
diff changeset
172 -- messages, with one entry in the table being allocated for each message.
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 type Error_Msg_Object is record
kono
parents:
diff changeset
175 Text : String_Ptr;
kono
parents:
diff changeset
176 -- Text of error message, fully expanded with all insertions
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 Next : Error_Msg_Id;
kono
parents:
diff changeset
179 -- Pointer to next message in error chain. A value of No_Error_Msg
kono
parents:
diff changeset
180 -- indicates the end of the chain.
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 Prev : Error_Msg_Id;
kono
parents:
diff changeset
183 -- Pointer to previous message in error chain. Only set during the
kono
parents:
diff changeset
184 -- Finalize procedure. A value of No_Error_Msg indicates the first
kono
parents:
diff changeset
185 -- message in the chain.
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 Sfile : Source_File_Index;
kono
parents:
diff changeset
188 -- Source table index of source file. In the case of an error that
kono
parents:
diff changeset
189 -- refers to a template, always references the original template
kono
parents:
diff changeset
190 -- not an instantiation copy.
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 Sptr : Source_Ptr;
kono
parents:
diff changeset
193 -- Flag pointer. In the case of an error that refers to a template,
kono
parents:
diff changeset
194 -- always references the original template, not an instantiation copy.
kono
parents:
diff changeset
195 -- This value is the actual place in the source that the error message
kono
parents:
diff changeset
196 -- will be posted. Note that an error placed on an instantiation will
kono
parents:
diff changeset
197 -- have Sptr pointing to the instantiation point.
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 Optr : Source_Ptr;
kono
parents:
diff changeset
200 -- Flag location used in the call to post the error. This is the same as
kono
parents:
diff changeset
201 -- Sptr, except when an error is posted on a particular instantiation of
kono
parents:
diff changeset
202 -- a generic. In such a case, Sptr will point to the original source
kono
parents:
diff changeset
203 -- location of the instantiation itself, but Optr will point to the
kono
parents:
diff changeset
204 -- template location (more accurately to the template copy in the
kono
parents:
diff changeset
205 -- instantiation copy corresponding to the instantiation referenced by
kono
parents:
diff changeset
206 -- Sptr).
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 Line : Physical_Line_Number;
kono
parents:
diff changeset
209 -- Line number for error message
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 Col : Column_Number;
kono
parents:
diff changeset
212 -- Column number for error message
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 Warn : Boolean;
kono
parents:
diff changeset
215 -- True if warning message
kono
parents:
diff changeset
216
kono
parents:
diff changeset
217 Info : Boolean;
kono
parents:
diff changeset
218 -- True if info message
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 Check : Boolean;
kono
parents:
diff changeset
221 -- True if check message
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 Warn_Err : Boolean;
kono
parents:
diff changeset
224 -- True if this is a warning message which is to be treated as an error
kono
parents:
diff changeset
225 -- as a result of a match with a Warning_As_Error pragma.
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 Warn_Chr : Character;
kono
parents:
diff changeset
228 -- Warning character (note: set even if Warning_Doc_Switch is False)
kono
parents:
diff changeset
229 -- ' ' -- ? or < appeared on its own in message
kono
parents:
diff changeset
230 -- '?' -- ?? or << appeared in message
kono
parents:
diff changeset
231 -- 'x' -- ?x? or <x< appeared in message (x = a .. z)
kono
parents:
diff changeset
232 -- 'X' -- ?X? or <X< appeared in message (X = A .. Z)
kono
parents:
diff changeset
233 -- '*' -- ?*? or <*< appeared in message
kono
parents:
diff changeset
234 -- '$' -- ?$? or <$< appeared in message
kono
parents:
diff changeset
235 -- In the case of the < sequences, this is set only if the message is
kono
parents:
diff changeset
236 -- actually a warning, i.e. if Error_Msg_Warn is True
kono
parents:
diff changeset
237
kono
parents:
diff changeset
238 Style : Boolean;
kono
parents:
diff changeset
239 -- True if style message (starts with "(style)")
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 Serious : Boolean;
kono
parents:
diff changeset
242 -- True if serious error message (not a warning and no | character)
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 Uncond : Boolean;
kono
parents:
diff changeset
245 -- True if unconditional message (i.e. insertion character ! appeared)
kono
parents:
diff changeset
246
kono
parents:
diff changeset
247 Msg_Cont : Boolean;
kono
parents:
diff changeset
248 -- This is used for logical messages that are composed of multiple
kono
parents:
diff changeset
249 -- individual messages. For messages that are not part of such a
kono
parents:
diff changeset
250 -- group, or that are the first message in such a group. Msg_Cont
kono
parents:
diff changeset
251 -- is set to False. For subsequent messages in a group, Msg_Cont
kono
parents:
diff changeset
252 -- is set to True. This is used to make sure that such a group of
kono
parents:
diff changeset
253 -- messages is either suppressed or retained as a group (e.g. in
kono
parents:
diff changeset
254 -- the circuit that deletes identical messages).
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 Deleted : Boolean;
kono
parents:
diff changeset
257 -- If this flag is set, the message is not printed. This is used
kono
parents:
diff changeset
258 -- in the circuit for deleting duplicate/redundant error messages.
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260 Node : Node_Id;
kono
parents:
diff changeset
261 -- If set, points to the node relevant for this message which will be
kono
parents:
diff changeset
262 -- used to compute the enclosing subprogram name if
kono
parents:
diff changeset
263 -- Opt.Include_Subprogram_In_Messages is set.
kono
parents:
diff changeset
264 end record;
kono
parents:
diff changeset
265
kono
parents:
diff changeset
266 package Errors is new Table.Table (
kono
parents:
diff changeset
267 Table_Component_Type => Error_Msg_Object,
kono
parents:
diff changeset
268 Table_Index_Type => Error_Msg_Id,
kono
parents:
diff changeset
269 Table_Low_Bound => 1,
kono
parents:
diff changeset
270 Table_Initial => 200,
kono
parents:
diff changeset
271 Table_Increment => 200,
kono
parents:
diff changeset
272 Table_Name => "Error");
kono
parents:
diff changeset
273
kono
parents:
diff changeset
274 First_Error_Msg : Error_Msg_Id;
kono
parents:
diff changeset
275 -- The list of error messages, i.e. the first entry on the list of error
kono
parents:
diff changeset
276 -- messages. This is not the same as the physically first entry in the
kono
parents:
diff changeset
277 -- error message table, since messages are not always inserted in sequence.
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 Last_Error_Msg : Error_Msg_Id;
kono
parents:
diff changeset
280 -- The last entry on the list of error messages. Note: this is not the same
kono
parents:
diff changeset
281 -- as the physically last entry in the error message table, since messages
kono
parents:
diff changeset
282 -- are not always inserted in sequence.
kono
parents:
diff changeset
283
kono
parents:
diff changeset
284 --------------------------
kono
parents:
diff changeset
285 -- Warning Mode Control --
kono
parents:
diff changeset
286 --------------------------
kono
parents:
diff changeset
287
kono
parents:
diff changeset
288 -- Pragma Warnings allows warnings to be turned off for a specified region
kono
parents:
diff changeset
289 -- of code, and the following tables are the data structures used to keep
kono
parents:
diff changeset
290 -- track of these regions.
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 -- The first table is used for the basic command line control, and for the
kono
parents:
diff changeset
293 -- forms of Warning with a single ON or OFF parameter.
kono
parents:
diff changeset
294
kono
parents:
diff changeset
295 -- It contains pairs of source locations, the first being the start
kono
parents:
diff changeset
296 -- location for a warnings off region, and the second being the end
kono
parents:
diff changeset
297 -- location. When a pragma Warnings (Off) is encountered, a new entry is
kono
parents:
diff changeset
298 -- established extending from the location of the pragma to the end of the
kono
parents:
diff changeset
299 -- current source file. A subsequent pragma Warnings (On) adjusts the end
kono
parents:
diff changeset
300 -- point of this entry appropriately.
kono
parents:
diff changeset
301
kono
parents:
diff changeset
302 -- If all warnings are suppressed by command switch, then there is a dummy
kono
parents:
diff changeset
303 -- entry (put there by Errout.Initialize) at the start of the table which
kono
parents:
diff changeset
304 -- covers all possible Source_Ptr values. Note that the source pointer
kono
parents:
diff changeset
305 -- values in this table always reference the original template, not an
kono
parents:
diff changeset
306 -- instantiation copy, in the generic case.
kono
parents:
diff changeset
307
kono
parents:
diff changeset
308 -- Reason is the reason from the pragma Warnings (Off,..) or the null
kono
parents:
diff changeset
309 -- string if no reason parameter is given.
kono
parents:
diff changeset
310
kono
parents:
diff changeset
311 type Warnings_Entry is record
kono
parents:
diff changeset
312 Start : Source_Ptr;
kono
parents:
diff changeset
313 Stop : Source_Ptr;
kono
parents:
diff changeset
314 Reason : String_Id;
kono
parents:
diff changeset
315 end record;
kono
parents:
diff changeset
316
kono
parents:
diff changeset
317 package Warnings is new Table.Table (
kono
parents:
diff changeset
318 Table_Component_Type => Warnings_Entry,
kono
parents:
diff changeset
319 Table_Index_Type => Natural,
kono
parents:
diff changeset
320 Table_Low_Bound => 1,
kono
parents:
diff changeset
321 Table_Initial => 100,
kono
parents:
diff changeset
322 Table_Increment => 200,
kono
parents:
diff changeset
323 Table_Name => "Warnings");
kono
parents:
diff changeset
324
kono
parents:
diff changeset
325 -- The second table is used for the specific forms of the pragma, where
kono
parents:
diff changeset
326 -- the first argument is ON or OFF, and the second parameter is a string
kono
parents:
diff changeset
327 -- which is the pattern to match for suppressing a warning.
kono
parents:
diff changeset
328
kono
parents:
diff changeset
329 type Specific_Warning_Entry is record
kono
parents:
diff changeset
330 Start : Source_Ptr;
kono
parents:
diff changeset
331 Stop : Source_Ptr;
kono
parents:
diff changeset
332 -- Starting and ending source pointers for the range. These are always
kono
parents:
diff changeset
333 -- from the same source file.
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 Reason : String_Id;
kono
parents:
diff changeset
336 -- Reason string from pragma Warnings, or null string if none
kono
parents:
diff changeset
337
kono
parents:
diff changeset
338 Msg : String_Ptr;
kono
parents:
diff changeset
339 -- Message from pragma Warnings (Off, string)
kono
parents:
diff changeset
340
kono
parents:
diff changeset
341 Open : Boolean;
kono
parents:
diff changeset
342 -- Set to True if OFF has been encountered with no matching ON
kono
parents:
diff changeset
343
kono
parents:
diff changeset
344 Used : Boolean;
kono
parents:
diff changeset
345 -- Set to True if entry has been used to suppress a warning
kono
parents:
diff changeset
346
kono
parents:
diff changeset
347 Config : Boolean;
kono
parents:
diff changeset
348 -- True if pragma is configuration pragma (in which case no matching Off
kono
parents:
diff changeset
349 -- pragma is required, and it is not required that a specific warning be
kono
parents:
diff changeset
350 -- suppressed).
kono
parents:
diff changeset
351 end record;
kono
parents:
diff changeset
352
kono
parents:
diff changeset
353 package Specific_Warnings is new Table.Table (
kono
parents:
diff changeset
354 Table_Component_Type => Specific_Warning_Entry,
kono
parents:
diff changeset
355 Table_Index_Type => Natural,
kono
parents:
diff changeset
356 Table_Low_Bound => 1,
kono
parents:
diff changeset
357 Table_Initial => 100,
kono
parents:
diff changeset
358 Table_Increment => 200,
kono
parents:
diff changeset
359 Table_Name => "Specific_Warnings");
kono
parents:
diff changeset
360
kono
parents:
diff changeset
361 -- Note on handling configuration case versus specific case. A complication
kono
parents:
diff changeset
362 -- arises from this example:
kono
parents:
diff changeset
363
kono
parents:
diff changeset
364 -- pragma Warnings (Off, "not referenced*");
kono
parents:
diff changeset
365 -- procedure Mumble (X : Integer) is
kono
parents:
diff changeset
366 -- pragma Warnings (On, "not referenced*");
kono
parents:
diff changeset
367 -- begin
kono
parents:
diff changeset
368 -- null;
kono
parents:
diff changeset
369 -- end Mumble;
kono
parents:
diff changeset
370
kono
parents:
diff changeset
371 -- The trouble is that the first pragma is technically a configuration
kono
parents:
diff changeset
372 -- pragma, and yet it is clearly being used in the context of thinking of
kono
parents:
diff changeset
373 -- it as a specific case. To deal with this, what we do is that the On
kono
parents:
diff changeset
374 -- entry can match a configuration pragma from the same file, and if we
kono
parents:
diff changeset
375 -- find such an On entry, we cancel the indication of it being the
kono
parents:
diff changeset
376 -- configuration case. This seems to handle all cases we run into ok.
kono
parents:
diff changeset
377
kono
parents:
diff changeset
378 -----------------
kono
parents:
diff changeset
379 -- Subprograms --
kono
parents:
diff changeset
380 -----------------
kono
parents:
diff changeset
381
kono
parents:
diff changeset
382 procedure Add_Class;
kono
parents:
diff changeset
383 -- Add 'Class to buffer for class wide type case (Class_Flag set)
kono
parents:
diff changeset
384
kono
parents:
diff changeset
385 function Buffer_Ends_With (C : Character) return Boolean;
kono
parents:
diff changeset
386 -- Tests if message buffer ends with given character
kono
parents:
diff changeset
387
kono
parents:
diff changeset
388 function Buffer_Ends_With (S : String) return Boolean;
kono
parents:
diff changeset
389 -- Tests if message buffer ends with given string preceded by a space
kono
parents:
diff changeset
390
kono
parents:
diff changeset
391 procedure Buffer_Remove (C : Character);
kono
parents:
diff changeset
392 -- Remove given character fron end of buffer if it is present
kono
parents:
diff changeset
393
kono
parents:
diff changeset
394 procedure Buffer_Remove (S : String);
kono
parents:
diff changeset
395 -- Removes given string from end of buffer if it is present at end of
kono
parents:
diff changeset
396 -- buffer, and preceded by a space.
kono
parents:
diff changeset
397
kono
parents:
diff changeset
398 function Compilation_Errors return Boolean;
kono
parents:
diff changeset
399 -- Returns true if errors have been detected, or warnings in -gnatwe
kono
parents:
diff changeset
400 -- (treat warnings as errors) mode.
kono
parents:
diff changeset
401
kono
parents:
diff changeset
402 procedure dmsg (Id : Error_Msg_Id);
kono
parents:
diff changeset
403 -- Debugging routine to dump an error message
kono
parents:
diff changeset
404
kono
parents:
diff changeset
405 procedure Debug_Output (N : Node_Id);
kono
parents:
diff changeset
406 -- Called from Error_Msg_N and Error_Msg_NE to generate line of debug
kono
parents:
diff changeset
407 -- output giving node number (of node N) if the debug X switch is set.
kono
parents:
diff changeset
408
kono
parents:
diff changeset
409 procedure Check_Duplicate_Message (M1, M2 : Error_Msg_Id);
kono
parents:
diff changeset
410 -- This function is passed the Id values of two error messages. If either
kono
parents:
diff changeset
411 -- M1 or M2 is a continuation message, or is already deleted, the call is
kono
parents:
diff changeset
412 -- ignored. Otherwise a check is made to see if M1 and M2 are duplicated or
kono
parents:
diff changeset
413 -- redundant. If so, the message to be deleted and all its continuations
kono
parents:
diff changeset
414 -- are marked with the Deleted flag set to True.
kono
parents:
diff changeset
415
kono
parents:
diff changeset
416 function Get_Warning_Tag (Id : Error_Msg_Id) return String;
kono
parents:
diff changeset
417 -- Given an error message ID, return tag showing warning message class, or
kono
parents:
diff changeset
418 -- the null string if this option is not enabled or this is not a warning.
kono
parents:
diff changeset
419
kono
parents:
diff changeset
420 procedure Output_Error_Msgs (E : in out Error_Msg_Id);
kono
parents:
diff changeset
421 -- Output source line, error flag, and text of stored error message and all
kono
parents:
diff changeset
422 -- subsequent messages for the same line and unit. On return E is set to be
kono
parents:
diff changeset
423 -- one higher than the last message output.
kono
parents:
diff changeset
424
kono
parents:
diff changeset
425 procedure Output_Line_Number (L : Logical_Line_Number);
kono
parents:
diff changeset
426 -- Output a line number as six digits (with leading zeroes suppressed),
kono
parents:
diff changeset
427 -- followed by a period and a blank (note that this is 8 characters which
kono
parents:
diff changeset
428 -- means that tabs in the source line will not get messed up). Line numbers
kono
parents:
diff changeset
429 -- that match or are less than the last Source_Reference pragma are listed
kono
parents:
diff changeset
430 -- as all blanks, avoiding output of junk line numbers.
kono
parents:
diff changeset
431
kono
parents:
diff changeset
432 procedure Output_Msg_Text (E : Error_Msg_Id);
kono
parents:
diff changeset
433 -- Outputs characters of text in the text of the error message E. Note that
kono
parents:
diff changeset
434 -- no end of line is output, the caller is responsible for adding the end
kono
parents:
diff changeset
435 -- of line. If Error_Msg_Line_Length is non-zero, this is the routine that
kono
parents:
diff changeset
436 -- splits the line generating multiple lines of output, and in this case
kono
parents:
diff changeset
437 -- the last line has no terminating end of line character.
kono
parents:
diff changeset
438
kono
parents:
diff changeset
439 procedure Prescan_Message (Msg : String);
kono
parents:
diff changeset
440 -- Scans message text and sets the following variables:
kono
parents:
diff changeset
441 --
kono
parents:
diff changeset
442 -- Is_Warning_Msg is set True if Msg is a warning message (contains a
kono
parents:
diff changeset
443 -- question mark character), and False otherwise.
kono
parents:
diff changeset
444 --
kono
parents:
diff changeset
445 -- Is_Style_Msg is set True if Msg is a style message (starts with
kono
parents:
diff changeset
446 -- "(style)") and False otherwise.
kono
parents:
diff changeset
447 --
kono
parents:
diff changeset
448 -- Is_Info_Msg is set True if Msg is an information message (starts
kono
parents:
diff changeset
449 -- with "info: ". Such messages must contain a ? sequence since they
kono
parents:
diff changeset
450 -- are also considered to be warning messages, and get a tag.
kono
parents:
diff changeset
451 --
kono
parents:
diff changeset
452 -- Is_Serious_Error is set to True unless the message is a warning or
kono
parents:
diff changeset
453 -- style message or contains the character | (non-serious error).
kono
parents:
diff changeset
454 --
kono
parents:
diff changeset
455 -- Is_Unconditional_Msg is set True if the message contains the character
kono
parents:
diff changeset
456 -- ! and is otherwise set False.
kono
parents:
diff changeset
457 --
kono
parents:
diff changeset
458 -- Has_Double_Exclam is set True if the message contains the sequence !!
kono
parents:
diff changeset
459 -- and is otherwise set False.
kono
parents:
diff changeset
460 --
kono
parents:
diff changeset
461 -- We need to know right away these aspects of a message, since we will
kono
parents:
diff changeset
462 -- test these values before doing the full error scan.
kono
parents:
diff changeset
463 --
kono
parents:
diff changeset
464 -- Note that the call has no effect for continuation messages (those whose
kono
parents:
diff changeset
465 -- first character is '\'), and all variables are left unchanged.
kono
parents:
diff changeset
466
kono
parents:
diff changeset
467 procedure Purge_Messages (From : Source_Ptr; To : Source_Ptr);
kono
parents:
diff changeset
468 -- All error messages whose location is in the range From .. To (not
kono
parents:
diff changeset
469 -- including the end points) will be deleted from the error listing.
kono
parents:
diff changeset
470
kono
parents:
diff changeset
471 function Same_Error (M1, M2 : Error_Msg_Id) return Boolean;
kono
parents:
diff changeset
472 -- See if two messages have the same text. Returns true if the text of the
kono
parents:
diff changeset
473 -- two messages is identical, or if one of them is the same as the other
kono
parents:
diff changeset
474 -- with an appended "instance at xxx" tag.
kono
parents:
diff changeset
475
kono
parents:
diff changeset
476 procedure Set_Msg_Blank;
kono
parents:
diff changeset
477 -- Sets a single blank in the message if the preceding character is a
kono
parents:
diff changeset
478 -- non-blank character other than a left parenthesis or minus. Has no
kono
parents:
diff changeset
479 -- effect if manual quote mode is turned on.
kono
parents:
diff changeset
480
kono
parents:
diff changeset
481 procedure Set_Msg_Blank_Conditional;
kono
parents:
diff changeset
482 -- Sets a single blank in the message if the preceding character is a
kono
parents:
diff changeset
483 -- non-blank character other than a left parenthesis or quote. Has no
kono
parents:
diff changeset
484 -- effect if manual quote mode is turned on.
kono
parents:
diff changeset
485
kono
parents:
diff changeset
486 procedure Set_Msg_Char (C : Character);
kono
parents:
diff changeset
487 -- Add a single character to the current message. This routine does not
kono
parents:
diff changeset
488 -- check for special insertion characters (they are just treated as text
kono
parents:
diff changeset
489 -- characters if they occur).
kono
parents:
diff changeset
490
kono
parents:
diff changeset
491 procedure Set_Msg_Insertion_File_Name;
kono
parents:
diff changeset
492 -- Handle file name insertion (left brace insertion character)
kono
parents:
diff changeset
493
kono
parents:
diff changeset
494 procedure Set_Msg_Insertion_Line_Number (Loc, Flag : Source_Ptr);
kono
parents:
diff changeset
495 -- Handle line number insertion (# insertion character). Loc is the
kono
parents:
diff changeset
496 -- location to be referenced, and Flag is the location at which the
kono
parents:
diff changeset
497 -- flag is posted (used to determine whether to add "in file xxx")
kono
parents:
diff changeset
498
kono
parents:
diff changeset
499 procedure Set_Msg_Insertion_Name_Literal;
kono
parents:
diff changeset
500
kono
parents:
diff changeset
501 procedure Set_Msg_Insertion_Name;
kono
parents:
diff changeset
502 -- Handle name insertion (% insertion character)
kono
parents:
diff changeset
503
kono
parents:
diff changeset
504 procedure Set_Msg_Insertion_Reserved_Name;
kono
parents:
diff changeset
505 -- Handle insertion of reserved word name (* insertion character)
kono
parents:
diff changeset
506
kono
parents:
diff changeset
507 procedure Set_Msg_Insertion_Reserved_Word
kono
parents:
diff changeset
508 (Text : String;
kono
parents:
diff changeset
509 J : in out Integer);
kono
parents:
diff changeset
510 -- Handle reserved word insertion (upper case letters). The Text argument
kono
parents:
diff changeset
511 -- is the current error message input text, and J is an index which on
kono
parents:
diff changeset
512 -- entry points to the first character of the reserved word, and on exit
kono
parents:
diff changeset
513 -- points past the last character of the reserved word. Note that RM and
kono
parents:
diff changeset
514 -- SPARK are treated specially and not considered to be keywords.
kono
parents:
diff changeset
515
kono
parents:
diff changeset
516 procedure Set_Msg_Insertion_Run_Time_Name;
kono
parents:
diff changeset
517 -- If package System contains a definition for Run_Time_Name (see package
kono
parents:
diff changeset
518 -- Targparm for details), then this procedure will insert a message of
kono
parents:
diff changeset
519 -- the form (name) into the current error message, with name set in mixed
kono
parents:
diff changeset
520 -- case (upper case after any spaces). If no run time name is defined,
kono
parents:
diff changeset
521 -- then this routine has no effect).
kono
parents:
diff changeset
522
kono
parents:
diff changeset
523 procedure Set_Msg_Insertion_Uint;
kono
parents:
diff changeset
524 -- Handle Uint insertion (^ insertion character)
kono
parents:
diff changeset
525
kono
parents:
diff changeset
526 procedure Set_Msg_Int (Line : Int);
kono
parents:
diff changeset
527 -- Set the decimal representation of the argument in the error message
kono
parents:
diff changeset
528 -- buffer with no leading zeroes output.
kono
parents:
diff changeset
529
kono
parents:
diff changeset
530 procedure Set_Msg_Name_Buffer;
kono
parents:
diff changeset
531 -- Output name from Name_Buffer, with surrounding quotes unless manual
kono
parents:
diff changeset
532 -- quotation mode is in effect.
kono
parents:
diff changeset
533
kono
parents:
diff changeset
534 procedure Set_Msg_Quote;
kono
parents:
diff changeset
535 -- Set quote if in normal quote mode, nothing if in manual quote mode
kono
parents:
diff changeset
536
kono
parents:
diff changeset
537 procedure Set_Msg_Str (Text : String);
kono
parents:
diff changeset
538 -- Add a sequence of characters to the current message. This routine does
kono
parents:
diff changeset
539 -- not check for special insertion characters (they are just treated as
kono
parents:
diff changeset
540 -- text characters if they occur). It does perform the transformation of
kono
parents:
diff changeset
541 -- the special strings _xxx (xxx = Pre/Post/Type_Invariant) to xxx'Class.
kono
parents:
diff changeset
542
kono
parents:
diff changeset
543 procedure Set_Next_Non_Deleted_Msg (E : in out Error_Msg_Id);
kono
parents:
diff changeset
544 -- Given a message id, move to next message id, but skip any deleted
kono
parents:
diff changeset
545 -- messages, so that this results in E on output being the first non-
kono
parents:
diff changeset
546 -- deleted message following the input value of E, or No_Error_Msg if
kono
parents:
diff changeset
547 -- the input value of E was either already No_Error_Msg, or was the
kono
parents:
diff changeset
548 -- last non-deleted message.
kono
parents:
diff changeset
549
kono
parents:
diff changeset
550 procedure Set_Specific_Warning_Off
kono
parents:
diff changeset
551 (Loc : Source_Ptr;
kono
parents:
diff changeset
552 Msg : String;
kono
parents:
diff changeset
553 Reason : String_Id;
kono
parents:
diff changeset
554 Config : Boolean;
kono
parents:
diff changeset
555 Used : Boolean := False);
kono
parents:
diff changeset
556 -- This is called in response to the two argument form of pragma Warnings
kono
parents:
diff changeset
557 -- where the first argument is OFF, and the second argument is a string
kono
parents:
diff changeset
558 -- which identifies a specific warning to be suppressed. The first argument
kono
parents:
diff changeset
559 -- is the start of the suppression range, and the second argument is the
kono
parents:
diff changeset
560 -- string from the pragma. Loc is the location of the pragma (which is the
kono
parents:
diff changeset
561 -- start of the range to suppress). Reason is the reason string from the
kono
parents:
diff changeset
562 -- pragma, or the null string if no reason is given. Config is True for the
kono
parents:
diff changeset
563 -- configuration pragma case (where there is no requirement for a matching
kono
parents:
diff changeset
564 -- OFF pragma). Used is set True to disable the check that the warning
kono
parents:
diff changeset
565 -- actually has the effect of suppressing a warning.
kono
parents:
diff changeset
566
kono
parents:
diff changeset
567 procedure Set_Specific_Warning_On
kono
parents:
diff changeset
568 (Loc : Source_Ptr;
kono
parents:
diff changeset
569 Msg : String;
kono
parents:
diff changeset
570 Err : out Boolean);
kono
parents:
diff changeset
571 -- This is called in response to the two argument form of pragma Warnings
kono
parents:
diff changeset
572 -- where the first argument is ON, and the second argument is a string
kono
parents:
diff changeset
573 -- which identifies a specific warning to be suppressed. The first argument
kono
parents:
diff changeset
574 -- is the end of the suppression range, and the second argument is the
kono
parents:
diff changeset
575 -- string from the pragma. Err is set to True on return to report the error
kono
parents:
diff changeset
576 -- of no matching Warnings Off pragma preceding this one.
kono
parents:
diff changeset
577
kono
parents:
diff changeset
578 procedure Set_Warnings_Mode_Off (Loc : Source_Ptr; Reason : String_Id);
kono
parents:
diff changeset
579 -- Called in response to a pragma Warnings (Off) to record the source
kono
parents:
diff changeset
580 -- location from which warnings are to be turned off. Reason is the
kono
parents:
diff changeset
581 -- Reason from the pragma, or the null string if none is given.
kono
parents:
diff changeset
582
kono
parents:
diff changeset
583 procedure Set_Warnings_Mode_On (Loc : Source_Ptr);
kono
parents:
diff changeset
584 -- Called in response to a pragma Warnings (On) to record the source
kono
parents:
diff changeset
585 -- location from which warnings are to be turned back on.
kono
parents:
diff changeset
586
kono
parents:
diff changeset
587 function Warnings_Suppressed (Loc : Source_Ptr) return String_Id;
kono
parents:
diff changeset
588 -- Determines if given location is covered by a warnings off suppression
kono
parents:
diff changeset
589 -- range in the warnings table (or is suppressed by compilation option,
kono
parents:
diff changeset
590 -- which generates a warning range for the whole source file). This routine
kono
parents:
diff changeset
591 -- only deals with the general ON/OFF case, not specific warnings. The
kono
parents:
diff changeset
592 -- returned result is No_String if warnings are not suppressed. If warnings
kono
parents:
diff changeset
593 -- are suppressed for the given location, then corresponding Reason
kono
parents:
diff changeset
594 -- parameter from the pragma is returned (or the null string if no Reason
kono
parents:
diff changeset
595 -- parameter was present).
kono
parents:
diff changeset
596
kono
parents:
diff changeset
597 function Warning_Specifically_Suppressed
kono
parents:
diff changeset
598 (Loc : Source_Ptr;
kono
parents:
diff changeset
599 Msg : String_Ptr;
kono
parents:
diff changeset
600 Tag : String := "") return String_Id;
kono
parents:
diff changeset
601 -- Determines if given message to be posted at given location is suppressed
kono
parents:
diff changeset
602 -- by specific ON/OFF Warnings pragmas specifying this particular message.
kono
parents:
diff changeset
603 -- If the warning is not suppressed then No_String is returned, otherwise
kono
parents:
diff changeset
604 -- the corresponding warning string is returned (or the null string if no
kono
parents:
diff changeset
605 -- Warning argument was present in the pragma). Tag is the error message
kono
parents:
diff changeset
606 -- tag for the message in question or the null string if there is no tag.
kono
parents:
diff changeset
607 --
kono
parents:
diff changeset
608 -- Note: we have a null default for Tag to deal with calls from an old
kono
parents:
diff changeset
609 -- branch of gnat2why, which does not know about tags in the calls but
kono
parents:
diff changeset
610 -- which uses the latest version of erroutc.
kono
parents:
diff changeset
611
kono
parents:
diff changeset
612 function Warning_Treated_As_Error (Msg : String) return Boolean;
kono
parents:
diff changeset
613 -- Returns True if the warning message Msg matches any of the strings
kono
parents:
diff changeset
614 -- given by Warning_As_Error pragmas, as stored in the Warnings_As_Errors
kono
parents:
diff changeset
615 -- table by Set_Warning_As_Error.
kono
parents:
diff changeset
616
kono
parents:
diff changeset
617 type Error_Msg_Proc is
kono
parents:
diff changeset
618 access procedure (Msg : String; Flag_Location : Source_Ptr);
kono
parents:
diff changeset
619 procedure Validate_Specific_Warnings (Eproc : Error_Msg_Proc);
kono
parents:
diff changeset
620 -- Checks that specific warnings are consistent (for non-configuration
kono
parents:
diff changeset
621 -- case, properly closed, and used). The argument is a pointer to the
kono
parents:
diff changeset
622 -- Error_Msg procedure to be called if any inconsistencies are detected.
kono
parents:
diff changeset
623
kono
parents:
diff changeset
624 end Erroutc;