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 -- This package contains the routines to output error messages. They are
28 -- basically system independent, however in some environments, e.g. when the
29 -- parser is embedded into an editor, it may be appropriate to replace the
30 -- implementation of this package.
34 with Namet; use Namet;
36 with Types; use Types;
37 with Uintp; use Uintp;
43 Serious_Errors_Detected : Nat renames Err_Vars.Serious_Errors_Detected;
44 -- This is a count of errors that are serious enough to stop expansion,
45 -- and hence to prevent generation of an object file even if the switch
48 Total_Errors_Detected : Nat renames Err_Vars.Total_Errors_Detected;
49 -- Number of errors detected so far. Includes count of serious errors and
50 -- non-serious errors, so this value is always greater than or equal to
51 -- the Serious_Errors_Detected value.
53 Warnings_Detected : Nat renames Err_Vars.Warnings_Detected;
54 -- Number of warnings detected
56 Configurable_Run_Time_Violations : Nat := 0;
57 -- Count of configurable run time violations so far. This is used to
58 -- suppress certain cascaded error messages when we know that we may not
59 -- have fully expanded some items, due to high integrity violations (i.e.
60 -- the use of constructs not permitted by the library in use, or improper
61 -- constructs in No_Run_Time mode).
63 type Compiler_State_Type is (Parsing, Analyzing);
64 Compiler_State : Compiler_State_Type;
65 -- Indicates current state of compilation. This is put in the Errout spec
66 -- because it affects the action of the error message handling. In
67 -- particular, an attempt is made by Errout to suppress cascaded error
68 -- messages in Parsing mode, but not in the other modes.
70 Current_Error_Source_File : Source_File_Index
71 renames Err_Vars.Current_Error_Source_File;
72 -- Id of current messages. Used to post file name when unit changes. This
73 -- is initialized to Main_Source_File at the start of a compilation, which
74 -- means that no file names will be output unless there are errors in
75 -- units other than the main unit. However, if the main unit has a pragma
76 -- Source_Reference line, then this is initialized to No_Source_File, to
77 -- force an initial reference to the real source file name.
79 Raise_Exception_On_Error : Nat renames Err_Vars.Raise_Exception_On_Error;
80 -- If this value is non-zero, then any attempt to generate an error
81 -- message raises the exception Error_Msg_Exception, and the error message
82 -- is not output. This is used for defending against junk resulting from
83 -- illegalities, and also for substitution of more appropriate error
84 -- messages from higher semantic levels. It is a counter so that the
85 -- increment/decrement protocol nests neatly.
87 Error_Msg_Exception : exception renames Err_Vars.Error_Msg_Exception;
88 -- Exception raised if Raise_Exception_On_Error is true
90 -----------------------------------
91 -- Suppression of Error Messages --
92 -----------------------------------
94 -- In an effort to reduce the impact of redundant error messages, the
95 -- error output routines in this package normally suppress certain
96 -- classes of messages as follows:
98 -- 1. Identical messages placed at the same point in the text. Such
99 -- duplicate error message result for example from rescanning
100 -- sections of the text that contain lexical errors. Only one of
101 -- such a set of duplicate messages is output, and the rest are
104 -- 2. If more than one parser message is generated for a single source
105 -- line, then only the first message is output, the remaining
106 -- messages on the same line are suppressed.
108 -- 3. If a message is posted on a node for which a message has been
109 -- previously posted, then only the first message is retained. The
110 -- Error_Posted flag is used to detect such multiple postings. Note
111 -- that this only applies to semantic messages, since otherwise
112 -- for parser messages, this would be a special case of case 2.
114 -- 4. If a message is posted on a node whose Etype or Entity
115 -- fields reference entities on which an error message has
116 -- already been placed, as indicated by the Error_Posted flag
117 -- being set on these entities, then the message is suppressed.
119 -- 5. If a message attempts to insert an Error node, or a direct
120 -- reference to the Any_Type node, then the message is suppressed.
122 -- 6. Note that cases 2-5 only apply to error messages, not warning
123 -- messages. Warning messages are only suppressed for case 1.
125 -- This normal suppression action may be overridden in cases 2-5 (but not
126 -- in case 1) by setting All_Errors mode, or by setting the special
127 -- unconditional message insertion character (!) at the end of the message
128 -- text as described below.
130 ---------------------------------------------------------
131 -- Error Message Text and Message Insertion Characters --
132 ---------------------------------------------------------
134 -- Error message text strings are composed of lower case letters, digits
135 -- and the special characters space, comma, period, colon and semicolon,
136 -- apostrophe and parentheses. Special insertion characters can also
137 -- appear which cause the error message circuit to modify the given
138 -- string as follows:
140 -- Insertion character % (Percent: insert name from Names table)
141 -- The character % is replaced by the text for the name specified by
142 -- the Name_Id value stored in Error_Msg_Name_1. A blank precedes the
143 -- name if it is preceded by a non-blank character other than left
144 -- parenthesis. The name is enclosed in quotes unless manual quotation
145 -- mode is set. If the Name_Id is set to No_Name, then no insertion
146 -- occurs; if the Name_Id is set to Error_Name, then the string
147 -- <error> is inserted. A second and third % may appear in a single
148 -- message, similarly replaced by the names which are specified by the
149 -- Name_Id values stored in Error_Msg_Name_2 and Error_Msg_Name_3. The
150 -- names are decoded and cased according to the current identifier
151 -- casing mode. Note: if a unit name ending with %b or %s is passed
152 -- for this kind of insertion, this suffix is simply stripped. Use a
153 -- unit name insertion ($) to process the suffix.
155 -- Insertion character %% (Double percent: insert literal name)
156 -- The character sequence %% acts as described above for %, except
157 -- that the name is simply obtained with Get_Name_String and is not
158 -- decoded or cased, it is inserted literally from the names table.
159 -- A trailing %b or %s is not treated specially.
161 -- Insertion character $ (Dollar: insert unit name from Names table)
162 -- The character $ is treated similarly to %, except that the name is
163 -- obtained from the Unit_Name_Type value in Error_Msg_Unit_1 and
164 -- Error_Msg_Unit_2, as provided by Get_Unit_Name_String in package
165 -- Uname. Note that this name includes the postfix (spec) or (body)
166 -- strings. If this postfix is not required, use the normal %
167 -- insertion for the unit name.
169 -- Insertion character { (Left brace: insert file name from names table)
170 -- The character { is treated similarly to %, except that the input
171 -- value is a File_Name_Type value stored in Error_Msg_File_1 or
172 -- Error_Msg_File_2 or Error_Msg_File_3. The value is output literally,
173 -- enclosed in quotes as for %, but the case is not modified, the
174 -- insertion is the exact string stored in the names table without
175 -- adjusting the casing.
177 -- Insertion character * (Asterisk, insert reserved word name)
178 -- The insertion character * is treated exactly like % except that the
179 -- resulting name is cased according to the default conventions for
180 -- reserved words (see package Scans).
182 -- Insertion character & (Ampersand: insert name from node)
183 -- The insertion character & is treated similarly to %, except that
184 -- the name is taken from the Chars field of the given node, and may
185 -- refer to a child unit name, or a selected component. The casing is,
186 -- if possible, taken from the original source reference, which is
187 -- obtained from the Sloc field of the given node or nodes. If no Sloc
188 -- is available (happens e.g. for nodes in package Standard), then the
189 -- default case (see Scans spec) is used. The nodes to be used are
190 -- stored in Error_Msg_Node_1, Error_Msg_Node_2. No insertion occurs
191 -- for the Empty node, and the Error node results in the insertion of
192 -- the characters <error>. In addition, if the special global variable
193 -- Error_Msg_Qual_Level is non-zero, then the reference will include
194 -- up to the given number of levels of qualification, using the scope
197 -- Insertion character # (Pound: insert line number reference)
198 -- The character # is replaced by the string indicating the source
199 -- position stored in Error_Msg_Sloc. There are three cases:
201 -- for package Standard: in package Standard
202 -- for locations in current file: at line nnn:ccc
203 -- for locations in other files: at filename:nnn:ccc
205 -- By convention, the # insertion character is only used at the end of
206 -- an error message, so the above strings only appear as the last
207 -- characters of an error message.
209 -- Insertion character } (Right brace: insert type reference)
210 -- The character } is replaced by a string describing the type
211 -- referenced by the entity whose Id is stored in Error_Msg_Node_1.
212 -- the string gives the name or description of the type, and also
213 -- where appropriate the location of its declaration. Special cases
214 -- like "some integer type" are handled appropriately. Only one } is
215 -- allowed in a message, since there is not enough room for two (the
216 -- insertion can be quite long, including a file name) In addition, if
217 -- the special global variable Error_Msg_Qual_Level is non-zero, then
218 -- the reference will include up to the given number of levels of
219 -- qualification, using the scope chain.
221 -- Insertion character @ (At: insert column number reference)
222 -- The character @ is replaced by null if the RM_Column_Check mode is
223 -- off (False). If the switch is on (True), then @ is replaced by the
224 -- text string " in column nnn" where nnn is the decimal
225 -- representation of the column number stored in Error_Msg_Col plus
226 -- one (the plus one is because the number is stored 0-origin and
227 -- displayed 1-origin).
229 -- Insertion character ^ (Carret: insert integer value)
230 -- The character ^ is replaced by the decimal conversion of the Uint
231 -- value stored in Error_Msg_Uint_1, with a possible leading minus.
232 -- A second ^ may occur in the message, in which case it is replaced
233 -- by the decimal conversion of the Uint value in Error_Msg_Uint_2.
235 -- Insertion character > (Right bracket, run time name)
236 -- The character > is replaced by a string of the form (name) if
237 -- Targparm scanned out a Run_Time_Name (see package Targparm for
238 -- details). The name is enclosed in parentheses and output in mixed
239 -- case mode (upper case after any space in the name). If no run time
240 -- name is defined, this insertion character has no effect.
242 -- Insertion character ! (Exclamation: unconditional message)
243 -- The character ! appearing as the last character of a message makes
244 -- the message unconditional which means that it is output even if it
245 -- would normally be suppressed. See section above for a description
246 -- of the cases in which messages are normally suppressed. Note that
247 -- warnings are never suppressed, so the use of the ! character in a
248 -- warning message is never useful.
250 -- Note: the presence of ! is ignored in continuation messages (i.e.
251 -- messages starting with the \ insertion character). The effect of the
252 -- use of ! in a parent message automatically applies to all of its
253 -- continuation messages (since we clearly don't want any case in which
254 -- continuations are separated from the parent message. It is allowable
255 -- to put ! in continuation messages, and the usual style is to include
256 -- it, since it makes it clear that the continuation is part of an
257 -- unconditional message.
259 -- Insertion character ? (Question: warning message)
260 -- The character ? appearing anywhere in a message makes the message
261 -- warning instead of a normal error message, and the text of the
262 -- message will be preceded by "Warning:" instead of "Error:" in the
263 -- normal case. The handling of warnings if further controlled by the
264 -- Warning_Mode option (-w switch), see package Opt for further
265 -- details, and also by the current setting from pragma Warnings. This
266 -- pragma applies only to warnings issued from the semantic phase (not
267 -- the parser), but currently all relevant warnings are posted by the
268 -- semantic phase anyway. Messages starting with (style) are also
269 -- treated as warning messages.
271 -- Note: the presence of ? is ignored in continuation messages (i.e.
272 -- messages starting with the \ insertion character). The warning
273 -- status of continuations is determined only by the parent message
274 -- which is being continued. It is allowable to put ? in continuation
275 -- messages, and the usual style is to include it, since it makes it
276 -- clear that the continuation is part of a warning message.
278 -- Insertion character < (Less Than: conditional warning message)
279 -- The character < appearing anywhere in a message is used for a
280 -- conditional error message. If Error_Msg_Warn is True, then the
281 -- effect is the same as ? described above. If Error_Msg_Warn is
282 -- False, then there is no effect.
284 -- Insertion character A-Z (Upper case letter: Ada reserved word)
285 -- If two or more upper case letters appear in the message, they are
286 -- taken as an Ada reserved word, and are converted to the default
287 -- case for reserved words (see Scans package spec). Surrounding
288 -- quotes are added unless manual quotation mode is currently set.
290 -- Insertion character ` (Backquote: set manual quotation mode)
291 -- The backquote character always appears in pairs. Each backquote of
292 -- the pair is replaced by a double quote character. In addition, any
293 -- reserved keywords, or name insertions between these backquotes are
294 -- not surrounded by the usual automatic double quotes. See the
295 -- section below on manual quotation mode for further details.
297 -- Insertion character ' (Quote: literal character)
298 -- Precedes a character which is placed literally into the message.
299 -- Used to insert characters into messages that are one of the
300 -- insertion characters defined here. Also useful in inserting
301 -- sequences of upper case letters (e.g. RM) which are not to be
302 -- treated as keywords.
304 -- Insertion character \ (Backslash: continuation message)
305 -- Indicates that the message is a continuation of a message
306 -- previously posted. This is used to ensure that such groups of
307 -- messages are treated as a unit. The \ character must be the first
308 -- character of the message text.
310 -- Insertion character \\ (Two backslashes, continuation with new line)
311 -- This differs from \ only in -gnatjnn mode (Error_Message_Line_Length
312 -- set non-zero). This sequence forces a new line to start even when
313 -- continuations are being gathered into a single message.
315 -- Insertion character | (Vertical bar: non-serious error)
316 -- By default, error messages (other than warning messages) are
317 -- considered to be fatal error messages which prevent expansion or
318 -- generation of code in the presence of the -gnatQ switch. If the
319 -- insertion character | appears, the message is considered to be
320 -- non-serious, and does not cause Serious_Errors_Detected to be
321 -- incremented (so expansion is not prevented by such a msg).
323 -- Insertion character ~ (Tilde: insert string)
324 -- Indicates that Error_Msg_String (1 .. Error_Msg_Strlen) is to be
325 -- inserted to replace the ~ character. The string is inserted in the
326 -- literal form it appears, without any action on special characters.
328 ----------------------------------------
329 -- Specialization of Messages for VMS --
330 ----------------------------------------
332 -- Some messages mention gcc-style switch names. When using an OpenVMS
333 -- host, such switch names must be converted to their corresponding VMS
334 -- qualifer. The following table controls this translation. In each case
335 -- the original message must contain the string "-xxx switch", where xxx
336 -- is the Gname? entry from below, and this string will be replaced by
337 -- "/yyy qualifier", where yyy is the corresponding Vname? entry.
339 Gname1 : aliased constant String := "fno-strict-aliasing";
340 Vname1 : aliased constant String := "OPTIMIZE=NO_STRICT_ALIASING";
342 Gname2 : aliased constant String := "gnatX";
343 Vname2 : aliased constant String := "EXTENSIONS_ALLOWED";
345 Gname3 : aliased constant String := "gnatW";
346 Vname3 : aliased constant String := "WIDE_CHARACTER_ENCODING";
348 Gname4 : aliased constant String := "gnatf";
349 Vname4 : aliased constant String := "REPORT_ERRORS=FULL";
351 Gname5 : aliased constant String := "gnat05";
352 Vname5 : aliased constant String := "05";
354 type Cstring_Ptr is access constant String;
356 Gnames : array (Nat range <>) of Cstring_Ptr :=
363 Vnames : array (Nat range <>) of Cstring_Ptr :=
370 -----------------------------------------------------
371 -- Global Values Used for Error Message Insertions --
372 -----------------------------------------------------
374 -- The following global variables are essentially additional parameters
375 -- passed to the error message routine for insertion sequences described
376 -- above. The reason these are passed globally is that the insertion
377 -- mechanism is essentially an untyped one in which the appropriate
378 -- variables are set depending on the specific insertion characters used.
380 -- Note that is mandatory that the caller ensure that global variables
381 -- are set before the Error_Msg call, otherwise the result is undefined.
383 Error_Msg_Col : Column_Number renames Err_Vars.Error_Msg_Col;
384 -- Column for @ insertion character in message
386 Error_Msg_Uint_1 : Uint renames Err_Vars.Error_Msg_Uint_1;
387 Error_Msg_Uint_2 : Uint renames Err_Vars.Error_Msg_Uint_2;
388 -- Uint values for ^ insertion characters in message
390 Error_Msg_Sloc : Source_Ptr renames Err_Vars.Error_Msg_Sloc;
391 -- Source location for # insertion character in message
393 Error_Msg_Name_1 : Name_Id renames Err_Vars.Error_Msg_Name_1;
394 Error_Msg_Name_2 : Name_Id renames Err_Vars.Error_Msg_Name_2;
395 Error_Msg_Name_3 : Name_Id renames Err_Vars.Error_Msg_Name_3;
396 -- Name_Id values for % insertion characters in message
398 Error_Msg_File_1 : File_Name_Type renames Err_Vars.Error_Msg_File_1;
399 Error_Msg_File_2 : File_Name_Type renames Err_Vars.Error_Msg_File_2;
400 Error_Msg_File_3 : File_Name_Type renames Err_Vars.Error_Msg_File_3;
401 -- File_Name_Type values for { insertion characters in message
403 Error_Msg_Unit_1 : Unit_Name_Type renames Err_Vars.Error_Msg_Unit_1;
404 Error_Msg_Unit_2 : Unit_Name_Type renames Err_Vars.Error_Msg_Unit_2;
405 -- Unit_Name_Type values for $ insertion characters in message
407 Error_Msg_Node_1 : Node_Id renames Err_Vars.Error_Msg_Node_1;
408 Error_Msg_Node_2 : Node_Id renames Err_Vars.Error_Msg_Node_2;
409 -- Node_Id values for & insertion characters in message
411 Error_Msg_Qual_Level : Int renames Err_Vars.Error_Msg_Qual_Level;
412 -- Number of levels of qualification required for type name (see the
413 -- description of the } insertion character. Note that this value does
414 -- note get reset by any Error_Msg call, so the caller is responsible
417 Error_Msg_Warn : Boolean renames Err_Vars.Error_Msg_Warn;
418 -- Used if current message contains a < insertion character to indicate
419 -- if the current message is a warning message.
421 Error_Msg_String : String renames Err_Vars.Error_Msg_String;
422 Error_Msg_Strlen : Natural renames Err_Vars.Error_Msg_Strlen;
423 -- Used if current message contains a ~ insertion character to indicate
424 -- insertion of the string Error_Msg_String (1 .. Error_Msg_Strlen).
426 -----------------------------------------------------
427 -- Format of Messages and Manual Quotation Control --
428 -----------------------------------------------------
430 -- Messages are generally all in lower case, except for inserted names
431 -- and appear in one of the following three forms:
436 -- The prefixes error and warning are supplied automatically (depending
437 -- on the use of the ? insertion character), and the call to the error
438 -- message routine supplies the text. The "error: " prefix is omitted
439 -- in brief error message formats.
441 -- Reserved Ada keywords in the message are in the default keyword case
442 -- (determined from the given source program), surrounded by quotation
443 -- marks. This is achieved by spelling the reserved word in upper case
444 -- letters, which is recognized as a request for insertion of quotation
445 -- marks by the error text processor. Thus for example:
447 -- Error_Msg_AP ("IS expected");
449 -- would result in the output of one of the following:
451 -- error: "is" expected
452 -- error: "IS" expected
453 -- error: "Is" expected
455 -- the choice between these being made by looking at the casing convention
456 -- used for keywords (actually the first compilation unit keyword) in the
459 -- In the case of names, the default mode for the error text processor
460 -- is to surround the name by quotation marks automatically. The case
461 -- used for the identifier names is taken from the source program where
462 -- possible, and otherwise is the default casing convention taken from
463 -- the source file usage.
465 -- In some cases, better control over the placement of quote marks is
466 -- required. This is achieved using manual quotation mode. In this mode,
467 -- one or more insertion sequences is surrounded by backquote characters.
468 -- The backquote characters are output as double quote marks, and normal
469 -- automatic insertion of quotes is suppressed between the double quotes.
472 -- Error_Msg_AP ("`END &;` expected");
474 -- generates a message like
476 -- error: "end Open_Scope;" expected
478 -- where the node specifying the name Open_Scope has been stored in
479 -- Error_Msg_Node_1 prior to the call. The great majority of error
480 -- messages operates in normal quotation mode.
482 -- Note: the normal automatic insertion of spaces before insertion
483 -- sequences (such as those that come from & and %) is suppressed in
484 -- manual quotation mode, so blanks, if needed as in the above example,
485 -- must be explicitly present.
487 ----------------------------
488 -- Message ID Definitions --
489 ----------------------------
491 subtype Error_Msg_Id is Erroutc.Error_Msg_Id;
492 function "=" (Left, Right : Error_Msg_Id) return Boolean
494 -- A type used to represent specific error messages. Used by the clients
495 -- of this package only in the context of the Get_Error_Id and
496 -- Change_Error_Text subprograms.
498 No_Error_Msg : constant Error_Msg_Id := Erroutc.No_Error_Msg;
499 -- A constant which is different from any value returned by Get_Error_Id.
500 -- Typically used by a client to indicate absense of a saved Id value.
502 function Get_Msg_Id return Error_Msg_Id renames Erroutc.Get_Msg_Id;
503 -- Returns the Id of the message most recently posted using one of the
504 -- Error_Msg routines.
506 function Get_Location (E : Error_Msg_Id) return Source_Ptr
507 renames Erroutc.Get_Location;
508 -- Returns the flag location of the error message with the given id E
510 ------------------------
511 -- List Pragmas Table --
512 ------------------------
514 -- When a pragma Page or pragma List is encountered by the parser, an
515 -- entry is made in the following table. This table is then used to
516 -- control the full listing if one is being generated. Note that the
517 -- reason we do the processing in the parser is so that we get proper
518 -- listing control even in syntax check only mode.
520 type List_Pragma_Type is (List_On, List_Off, Page);
522 type List_Pragma_Record is record
523 Ptyp : List_Pragma_Type;
527 -- Note: Ploc points to the terminating semicolon in the List_Off and Page
528 -- cases, and to the pragma keyword for List_On. In the case of a pragma
529 -- List_Off, a List_On entry is also made in the table, pointing to the
530 -- pragma keyword. This ensures that, as required, a List (Off) pragma is
531 -- listed even in list off mode.
533 package List_Pragmas is new Table.Table (
534 Table_Component_Type => List_Pragma_Record,
535 Table_Index_Type => Int,
536 Table_Low_Bound => 1,
538 Table_Increment => 200,
539 Table_Name => "List_Pragmas");
541 ---------------------------
542 -- Ignore_Errors Feature --
543 ---------------------------
545 -- In certain cases, notably for optional subunits, the compiler operates
546 -- in a mode where errors are to be ignored, and the whole unit is to be
547 -- considered as not present. To implement this we provide the following
548 -- flag to enable special handling, where error messages are suppressed,
549 -- but the Fatal_Error flag will still be set in the normal manner.
551 Ignore_Errors_Enable : Nat := 0;
552 -- Triggering switch. If non-zero, then ignore errors mode is activated.
553 -- This is a counter to allow convenient nesting of enable/disable.
555 ------------------------------
556 -- Error Output Subprograms --
557 ------------------------------
559 procedure Initialize;
560 -- Initializes for output of error messages. Must be called for each
561 -- source file before using any of the other routines in the package.
564 -- Finalize processing of error message list. Includes processing for
565 -- duplicated error messages, and other similar final adjustment of the
566 -- list of error messages. Note that this procedure must be called before
567 -- calling Compilation_Errors to determine if there were any errors. It
568 -- is perfectly fine to call Finalize more than once. Indeed this can
569 -- make good sense. For example, do some processing that may generate
570 -- messages. Call Finalize to eliminate duplicates and remove deleted
571 -- warnings. Test for compilation errors using Compilation_Errors, then
572 -- generate some more errors/warnings, call Finalize again to make sure
573 -- that all duplicates in these new messages are dealt with, then finally
574 -- call Output_Messages to output the final list of messages.
576 procedure Output_Messages;
577 -- Output list of messages, including messages giving number of detected
578 -- errors and warnings.
580 procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr);
581 -- Output a message at specified location. Can be called from the parser
582 -- or the semantic analyzer.
584 procedure Error_Msg_S (Msg : String);
585 -- Output a message at current scan pointer location. This routine can be
586 -- called only from the parser, since it references Scan_Ptr.
588 procedure Error_Msg_AP (Msg : String);
589 -- Output a message just after the previous token. This routine can be
590 -- called only from the parser, since it references Prev_Token_Ptr.
592 procedure Error_Msg_BC (Msg : String);
593 -- Output a message just before the current token. Note that the important
594 -- difference between this and the previous routine is that the BC case
595 -- posts a flag on the current line, whereas AP can post a flag at the
596 -- end of the preceding line. This routine can be called only from the
597 -- parser, since it references Token_Ptr.
599 procedure Error_Msg_SC (Msg : String);
600 -- Output a message at the start of the current token, unless we are at
601 -- the end of file, in which case we always output the message after the
602 -- last real token in the file. This routine can be called only from the
603 -- parser, since it references Token_Ptr.
605 procedure Error_Msg_SP (Msg : String);
606 -- Output a message at the start of the previous token. This routine can
607 -- be called only from the parser, since it references Prev_Token_Ptr.
609 procedure Error_Msg_N (Msg : String; N : Node_Or_Entity_Id);
610 -- Output a message at the Sloc of the given node. This routine can be
611 -- called from the parser or the semantic analyzer, although the call from
612 -- the latter is much more common (and is the most usual way of generating
613 -- error messages from the analyzer). The message text may contain a
614 -- single & insertion, which will reference the given node. The message is
615 -- suppressed if the node N already has a message posted, or if it is a
616 -- warning and warnings and N is an entity node for which warnings are
619 procedure Error_Msg_F (Msg : String; N : Node_Id);
620 -- Similar to Error_Msg_N except that the message is placed on the
621 -- first node of the construct N (First_Node (N)).
623 procedure Error_Msg_NE
625 N : Node_Or_Entity_Id;
626 E : Node_Or_Entity_Id);
627 -- Output a message at the Sloc of the given node N, with an insertion of
628 -- the name from the given entity node E. This is used by the semantic
629 -- routines, where this is a common error message situation. The Msg text
630 -- will contain a & or } as usual to mark the insertion point. This
631 -- routine can be called from the parser or the analyzer.
633 procedure Error_Msg_FE
636 E : Node_Or_Entity_Id);
637 -- Same as Error_Msg_NE, except that the message is placed on the first
638 -- node of the construct N (First_Node (N)).
640 procedure Error_Msg_NEL
642 N : Node_Or_Entity_Id;
643 E : Node_Or_Entity_Id;
644 Flag_Location : Source_Ptr);
645 -- Exactly the same as Error_Msg_NE, except that the flag is placed at
646 -- the specified Flag_Location instead of at Sloc (N).
648 procedure Error_Msg_NW
651 N : Node_Or_Entity_Id);
652 -- This routine is used for posting a message conditionally. The message
653 -- is posted (with the same effect as Error_Msg_N (Msg, N) if and only
654 -- if Eflag is True and if the node N is within the main extended source
655 -- unit and comes from source. Typically this is a warning mode flag.
657 procedure Change_Error_Text (Error_Id : Error_Msg_Id; New_Msg : String);
658 -- The error message text of the message identified by Id is replaced by
659 -- the given text. This text may contain insertion characters in the
660 -- usual manner, and need not be the same length as the original text.
662 function First_Node (C : Node_Id) return Node_Id;
663 -- Given a construct C, finds the first node in the construct, i.e. the
664 -- one with the lowest Sloc value. This is useful in placing error msgs.
666 function First_Sloc (N : Node_Id) return Source_Ptr;
667 -- Given the node for an expression, return a source pointer value that
668 -- points to the start of the first token in the expression. In the case
669 -- where the expression is parenthesized, an attempt is made to include
670 -- the parentheses (i.e. to return the location of the initial paren).
672 procedure Purge_Messages (From : Source_Ptr; To : Source_Ptr)
673 renames Erroutc.Purge_Messages;
674 -- All error messages whose location is in the range From .. To (not
675 -- including the end points) will be deleted from the error listing.
677 procedure Remove_Warning_Messages (N : Node_Id);
678 -- Remove any warning messages corresponding to the Sloc of N or any
679 -- of its descendent nodes. No effect if no such warnings.
681 procedure Remove_Warning_Messages (L : List_Id);
682 -- Remove warnings on all elements of a list
684 procedure Set_Ignore_Errors (To : Boolean);
685 -- Following a call to this procedure with To=True, all error calls are
686 -- ignored. A call with To=False restores the default treatment in which
687 -- error calls are treated as usual (and as described in this spec).
689 procedure Set_Warnings_Mode_Off (Loc : Source_Ptr)
690 renames Erroutc.Set_Warnings_Mode_Off;
691 -- Called in response to a pragma Warnings (Off) to record the source
692 -- location from which warnings are to be turned off.
694 procedure Set_Warnings_Mode_On (Loc : Source_Ptr)
695 renames Erroutc.Set_Warnings_Mode_On;
696 -- Called in response to a pragma Warnings (On) to record the source
697 -- location from which warnings are to be turned back on.
699 procedure Set_Specific_Warning_Off (Loc : Source_Ptr; Msg : String)
700 renames Erroutc.Set_Specific_Warning_Off;
701 -- This is called in response to the two argument form of pragma Warnings
702 -- where the first argument is OFF, and the second argument is the prefix
703 -- of a specific warning to be suppressed. The first argument is the start
704 -- of the suppression range, and the second argument is the string from
707 procedure Set_Specific_Warning_On
711 renames Erroutc.Set_Specific_Warning_On;
712 -- This is called in response to the two argument form of pragma Warnings
713 -- where the first argument is ON, and the second argument is the prefix
714 -- of a specific warning to be suppressed. The first argument is the end
715 -- of the suppression range, and the second argument is the string from
716 -- the pragma. Err is set to True on return to report the error of no
717 -- matching Warnings Off pragma preceding this one.
719 function Compilation_Errors return Boolean;
720 -- Returns true if errors have been detected, or warnings in -gnatwe
721 -- (treat warnings as errors) mode. Note that it is mandatory to call
722 -- Finalize before calling this routine.
724 procedure Error_Msg_CRT (Feature : String; N : Node_Id);
725 -- Posts a non-fatal message on node N saying that the feature identified
726 -- by the Feature argument is not supported in either configurable
727 -- run-time mode or no run-time mode (as appropriate). In the former case,
728 -- the name of the library is output if available.
730 procedure dmsg (Id : Error_Msg_Id) renames Erroutc.dmsg;
731 -- Debugging routine to dump an error message
733 ------------------------------------
734 -- Utility Interface for Back End --
735 ------------------------------------
737 -- The following subprograms can be used by the back end for the purposes
738 -- of concocting error messages that are not output via Errout, e.g. the
739 -- messages generated by the gcc back end.
741 procedure Set_Identifier_Casing
742 (Identifier_Name : System.Address;
743 File_Name : System.Address);
744 -- The identifier is a null terminated string that represents the name of
745 -- an identifier appearing in the source program. File_Name is a null
746 -- terminated string giving the corresponding file name for the identifier
747 -- as obtained from the front end by the use of Full_Debug_Name to the
748 -- source file referenced by the corresponding source location value. On
749 -- return, the name is in Name_Buffer, null terminated with Name_Len set.
750 -- This name is the identifier name as passed, cased according to the
751 -- default identifier casing for the given file.