gcc:
[official-gcc.git] / gcc / ada / errout.ads
blobf4644c2cc6fc964bf3f17cfa39de88c340921124
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- E R R O U T --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 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. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
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.
32 with Err_Vars;
33 with Erroutc;
34 with Table;
35 with Types; use Types;
36 with Uintp; use Uintp;
38 with System;
40 package Errout is
42 Serious_Errors_Detected : Nat renames Err_Vars.Serious_Errors_Detected;
43 -- This is a count of errors that are serious enough to stop expansion,
44 -- and hence to prevent generation of an object file even if the switch
45 -- -gnatQ is set.
47 Total_Errors_Detected : Nat renames Err_Vars.Total_Errors_Detected;
48 -- Number of errors detected so far. Includes count of serious errors and
49 -- non-serious errors, so this value is always greater than or equal to
50 -- the Serious_Errors_Detected value.
52 Warnings_Detected : Nat renames Err_Vars.Warnings_Detected;
53 -- Number of warnings detected
55 Configurable_Run_Time_Violations : Nat := 0;
56 -- Count of configurable run time violations so far. This is used to
57 -- suppress certain cascaded error messages when we know that we may not
58 -- have fully expanded some items, due to high integrity violations (i.e.
59 -- the use of constructs not permitted by the library in use, or improper
60 -- constructs in No_Run_Time mode).
62 type Compiler_State_Type is (Parsing, Analyzing);
63 Compiler_State : Compiler_State_Type;
64 -- Indicates current state of compilation. This is put in the Errout spec
65 -- because it affects the action of the error message handling. In
66 -- particular, an attempt is made by Errout to suppress cascaded error
67 -- messages in Parsing mode, but not in the other modes.
69 Current_Error_Source_File : Source_File_Index
70 renames Err_Vars.Current_Error_Source_File;
71 -- Id of current messages. Used to post file name when unit changes. This
72 -- is initialized to Main_Source_File at the start of a compilation, which
73 -- means that no file names will be output unless there are errors in
74 -- units other than the main unit. However, if the main unit has a pragma
75 -- Source_Reference line, then this is initialized to No_Source_File, to
76 -- force an initial reference to the real source file name.
78 Raise_Exception_On_Error : Nat renames Err_Vars.Raise_Exception_On_Error;
79 -- If this value is non-zero, then any attempt to generate an error
80 -- message raises the exception Error_Msg_Exception, and the error message
81 -- is not output. This is used for defending against junk resulting from
82 -- illegalities, and also for substitution of more appropriate error
83 -- messages from higher semantic levels. It is a counter so that the
84 -- increment/decrement protocol nests neatly.
86 Error_Msg_Exception : exception renames Err_Vars.Error_Msg_Exception;
87 -- Exception raised if Raise_Exception_On_Error is true
89 -----------------------------------
90 -- Suppression of Error Messages --
91 -----------------------------------
93 -- In an effort to reduce the impact of redundant error messages, the
94 -- error output routines in this package normally suppress certain
95 -- classes of messages as follows:
97 -- 1. Identical messages placed at the same point in the text. Such
98 -- duplicate error message result for example from rescanning
99 -- sections of the text that contain lexical errors. Only one of
100 -- such a set of duplicate messages is output, and the rest are
101 -- suppressed.
103 -- 2. If more than one parser message is generated for a single source
104 -- line, then only the first message is output, the remaining
105 -- messages on the same line are suppressed.
107 -- 3. If a message is posted on a node for which a message has been
108 -- previously posted, then only the first message is retained. The
109 -- Error_Posted flag is used to detect such multiple postings. Note
110 -- that this only applies to semantic messages, since otherwise
111 -- for parser messages, this would be a special case of case 2.
113 -- 4. If a message is posted on a node whose Etype or Entity
114 -- fields reference entities on which an error message has
115 -- already been placed, as indicated by the Error_Posted flag
116 -- being set on these entities, then the message is suppressed.
118 -- 5. If a message attempts to insert an Error node, or a direct
119 -- reference to the Any_Type node, then the message is suppressed.
121 -- 6. Note that cases 2-5 only apply to error messages, not warning
122 -- messages. Warning messages are only suppressed for case 1.
124 -- This normal suppression action may be overridden in cases 2-5 (but not
125 -- in case 1) by setting All_Errors mode, or by setting the special
126 -- unconditional message insertion character (!) at the end of the message
127 -- text as described below.
129 ---------------------------------------------------------
130 -- Error Message Text and Message Insertion Characters --
131 ---------------------------------------------------------
133 -- Error message text strings are composed of lower case letters, digits
134 -- and the special characters space, comma, period, colon and semicolon,
135 -- apostrophe and parentheses. Special insertion characters can also
136 -- appear which cause the error message circuit to modify the given
137 -- string as follows:
139 -- Insertion character % (Percent: insert name from Names table)
140 -- The character % is replaced by the text for the name specified by
141 -- the Name_Id value stored in Error_Msg_Name_1. A blank precedes the
142 -- name if it is preceded by a non-blank character other than left
143 -- parenthesis. The name is enclosed in quotes unless manual quotation
144 -- mode is set. If the Name_Id is set to No_Name, then no insertion
145 -- occurs; if the Name_Id is set to Error_Name, then the string
146 -- <error> is inserted. A second and third % may appear in a single
147 -- message, similarly replaced by the names which are specified by the
148 -- Name_Id values stored in Error_Msg_Name_2 and Error_Msg_Name_3. The
149 -- names are decoded and cased according to the current identifier
150 -- casing mode.
152 -- Insertion character $ (Dollar: insert unit name from Names table)
153 -- The character $ is treated similarly to %, except that the name is
154 -- obtained from the Unit_Name_Type value in Error_Msg_Unit_1 and
155 -- Error_Msg_Unit_2, as provided by Get_Unit_Name_String in package
156 -- Uname. Note that this name includes the postfix (spec) or (body)
157 -- strings. If this postfix is not required, use the normal %
158 -- insertion for the unit name.
160 -- Insertion character { (Left brace: insert literally from names table)
161 -- The character { is treated similarly to %, except that the name is
162 -- output literally as stored in the names table without adjusting the
163 -- casing. This can be used for file names and in other situations
164 -- where the name string is to be output unchanged.
166 -- Insertion character * (Asterisk, insert reserved word name)
167 -- The insertion character * is treated exactly like % except that the
168 -- resulting name is cased according to the default conventions for
169 -- reserved words (see package Scans).
171 -- Insertion character & (Ampersand: insert name from node)
172 -- The insertion character & is treated similarly to %, except that
173 -- the name is taken from the Chars field of the given node, and may
174 -- refer to a child unit name, or a selected component. The casing is,
175 -- if possible, taken from the original source reference, which is
176 -- obtained from the Sloc field of the given node or nodes. If no Sloc
177 -- is available (happens e.g. for nodes in package Standard), then the
178 -- default case (see Scans spec) is used. The nodes to be used are
179 -- stored in Error_Msg_Node_1, Error_Msg_Node_2. No insertion occurs
180 -- for the Empty node, and the Error node results in the insertion of
181 -- the characters <error>. In addition, if the special global variable
182 -- Error_Msg_Qual_Level is non-zero, then the reference will include
183 -- up to the given number of levels of qualification, using the scope
184 -- chain.
186 -- Insertion character # (Pound: insert line number reference)
187 -- The character # is replaced by the string indicating the source
188 -- position stored in Error_Msg_Sloc. There are three cases:
190 -- for package Standard: in package Standard
191 -- for locations in current file: at line nnn:ccc
192 -- for locations in other files: at filename:nnn:ccc
194 -- By convention, the # insertion character is only used at the end of
195 -- an error message, so the above strings only appear as the last
196 -- characters of an error message.
198 -- Insertion character } (Right brace: insert type reference)
199 -- The character } is replaced by a string describing the type
200 -- referenced by the entity whose Id is stored in Error_Msg_Node_1.
201 -- the string gives the name or description of the type, and also
202 -- where appropriate the location of its declaration. Special cases
203 -- like "some integer type" are handled appropriately. Only one } is
204 -- allowed in a message, since there is not enough room for two (the
205 -- insertion can be quite long, including a file name) In addition, if
206 -- the special global variable Error_Msg_Qual_Level is non-zero, then
207 -- the reference will include up to the given number of levels of
208 -- qualification, using the scope chain.
210 -- Insertion character @ (At: insert column number reference)
211 -- The character @ is replaced by null if the RM_Column_Check mode is
212 -- off (False). If the switch is on (True), then @ is replaced by the
213 -- text string " in column nnn" where nnn is the decimal
214 -- representation of the column number stored in Error_Msg_Col plus
215 -- one (the plus one is because the number is stored 0-origin and
216 -- displayed 1-origin).
218 -- Insertion character ^ (Carret: insert integer value)
219 -- The character ^ is replaced by the decimal conversion of the Uint
220 -- value stored in Error_Msg_Uint_1, with a possible leading minus.
221 -- A second ^ may occur in the message, in which case it is replaced
222 -- by the decimal conversion of the Uint value in Error_Msg_Uint_2.
224 -- Insertion character > (Right bracket, run time name)
225 -- The character > is replaced by a string of the form (name) if
226 -- Targparm scanned out a Run_Time_Name (see package Targparm for
227 -- details). The name is enclosed in parentheses and output in mixed
228 -- case mode (upper case after any space in the name). If no run time
229 -- name is defined, this insertion character has no effect.
231 -- Insertion character ! (Exclamation: unconditional message)
232 -- The character ! appearing as the last character of a message makes
233 -- the message unconditional which means that it is output even if it
234 -- would normally be suppressed. See section above for a description
235 -- of the cases in which messages are normally suppressed. Note that
236 -- warnings are never suppressed, so the use of the ! character in a
237 -- warning message is never useful.
239 -- Note: the presence of ! is ignored in continuation messages (i.e.
240 -- messages starting with the \ insertion character). The effect of the
241 -- use of ! in a parent message automatically applies to all of its
242 -- continuation messages (since we clearly don't want any case in which
243 -- continuations are separated from the parent message. It is allowable
244 -- to put ! in continuation messages, and the usual style is to include
245 -- it, since it makes it clear that the continuation is part of an
246 -- unconditional message.
248 -- Insertion character ? (Question: warning message)
249 -- The character ? appearing anywhere in a message makes the message
250 -- warning instead of a normal error message, and the text of the
251 -- message will be preceded by "Warning:" instead of "Error:" in the
252 -- normal case. The handling of warnings if further controlled by the
253 -- Warning_Mode option (-w switch), see package Opt for further
254 -- details, and also by the current setting from pragma Warnings. This
255 -- pragma applies only to warnings issued from the semantic phase (not
256 -- the parser), but currently all relevant warnings are posted by the
257 -- semantic phase anyway. Messages starting with (style) are also
258 -- treated as warning messages.
260 -- Note: the presence of ? is ignored in continuation messages (i.e.
261 -- messages starting with the \ insertion character). The warning
262 -- status of continuations is determined only by the parent message
263 -- which is being continued. It is allowable to put ? in continuation
264 -- messages, and the usual style is to include it, since it makes it
265 -- clear that the continuation is part of a warning message.
267 -- Insertion character < (Less Than: conditional warning message)
268 -- The character < appearing anywhere in a message is used for a
269 -- conditional error message. If Error_Msg_Warn is True, then the
270 -- effect is the same as ? described above. If Error_Msg_Warn is
271 -- False, then there is no effect.
273 -- Insertion character A-Z (Upper case letter: Ada reserved word)
274 -- If two or more upper case letters appear in the message, they are
275 -- taken as an Ada reserved word, and are converted to the default
276 -- case for reserved words (see Scans package spec). Surrounding
277 -- quotes are added unless manual quotation mode is currently set.
279 -- Insertion character ` (Backquote: set manual quotation mode)
280 -- The backquote character always appears in pairs. Each backquote of
281 -- the pair is replaced by a double quote character. In addition, any
282 -- reserved keywords, or name insertions between these backquotes are
283 -- not surrounded by the usual automatic double quotes. See the
284 -- section below on manual quotation mode for further details.
286 -- Insertion character ' (Quote: literal character)
287 -- Precedes a character which is placed literally into the message.
288 -- Used to insert characters into messages that are one of the
289 -- insertion characters defined here. Also useful in inserting
290 -- sequences of upper case letters (e.g. RM) which are not to be
291 -- treated as keywords.
293 -- Insertion character \ (Backslash: continuation message)
294 -- Indicates that the message is a continuation of a message
295 -- previously posted. This is used to ensure that such groups of
296 -- messages are treated as a unit. The \ character must be the first
297 -- character of the message text.
299 -- Insertion character \\ (Two backslashes, continuation with new line)
300 -- This differs from \ only in -gnatjnn mode (Error_Message_Line_Length
301 -- set non-zero). This sequence forces a new line to start even when
302 -- continuations are being gathered into a single message.
304 -- Insertion character | (Vertical bar: non-serious error)
305 -- By default, error messages (other than warning messages) are
306 -- considered to be fatal error messages which prevent expansion or
307 -- generation of code in the presence of the -gnatQ switch. If the
308 -- insertion character | appears, the message is considered to be
309 -- non-serious, and does not cause Serious_Errors_Detected to be
310 -- incremented (so expansion is not prevented by such a msg).
312 -- Insertion character ~ (Tilde: insert string)
313 -- Indicates that Error_Msg_String (1 .. Error_Msg_Strlen) is to be
314 -- inserted to replace the ~ character. The string is inserted in the
315 -- literal form it appears, without any action on special characters.
317 ----------------------------------------
318 -- Specialization of Messages for VMS --
319 ----------------------------------------
321 -- Some messages mention gcc-style switch names. When using an OpenVMS
322 -- host, such switch names must be converted to their corresponding VMS
323 -- qualifer. The following table controls this translation. In each case
324 -- the original message must contain the string "-xxx switch", where xxx
325 -- is the Gname? entry from below, and this string will be replaced by
326 -- "/yyy qualifier", where yyy is the corresponding Vname? entry.
328 Gname1 : aliased constant String := "fno-strict-aliasing";
329 Vname1 : aliased constant String := "OPTIMIZE=NO_STRICT_ALIASING";
331 Gname2 : aliased constant String := "gnatX";
332 Vname2 : aliased constant String := "EXTENSIONS_ALLOWED";
334 Gname3 : aliased constant String := "gnatW";
335 Vname3 : aliased constant String := "WIDE_CHARACTER_ENCODING";
337 Gname4 : aliased constant String := "gnatf";
338 Vname4 : aliased constant String := "REPORT_ERRORS=FULL";
340 Gname5 : aliased constant String := "gnat05";
341 Vname5 : aliased constant String := "05";
343 type Cstring_Ptr is access constant String;
345 Gnames : array (Nat range <>) of Cstring_Ptr :=
346 (Gname1'Access,
347 Gname2'Access,
348 Gname3'Access,
349 Gname4'Access,
350 Gname5'Access);
352 Vnames : array (Nat range <>) of Cstring_Ptr :=
353 (Vname1'Access,
354 Vname2'Access,
355 Vname3'Access,
356 Vname4'Access,
357 Vname5'Access);
359 -----------------------------------------------------
360 -- Global Values Used for Error Message Insertions --
361 -----------------------------------------------------
363 -- The following global variables are essentially additional parameters
364 -- passed to the error message routine for insertion sequences described
365 -- above. The reason these are passed globally is that the insertion
366 -- mechanism is essentially an untyped one in which the appropriate
367 -- variables are set depending on the specific insertion characters used.
369 -- Note that is mandatory that the caller ensure that global variables
370 -- are set before the Error_Msg call, otherwise the result is undefined.
372 Error_Msg_Col : Column_Number renames Err_Vars.Error_Msg_Col;
373 -- Column for @ insertion character in message
375 Error_Msg_Uint_1 : Uint renames Err_Vars.Error_Msg_Uint_1;
376 Error_Msg_Uint_2 : Uint renames Err_Vars.Error_Msg_Uint_2;
377 -- Uint values for ^ insertion characters in message
379 Error_Msg_Sloc : Source_Ptr renames Err_Vars.Error_Msg_Sloc;
380 -- Source location for # insertion character in message
382 Error_Msg_Name_1 : Name_Id renames Err_Vars.Error_Msg_Name_1;
383 Error_Msg_Name_2 : Name_Id renames Err_Vars.Error_Msg_Name_2;
384 Error_Msg_Name_3 : Name_Id renames Err_Vars.Error_Msg_Name_3;
385 -- Name_Id values for % insertion characters in message
387 Error_Msg_Unit_1 : Name_Id renames Err_Vars.Error_Msg_Unit_1;
388 Error_Msg_Unit_2 : Name_Id renames Err_Vars.Error_Msg_Unit_2;
389 -- Name_Id values for $ insertion characters in message
391 Error_Msg_Node_1 : Node_Id renames Err_Vars.Error_Msg_Node_1;
392 Error_Msg_Node_2 : Node_Id renames Err_Vars.Error_Msg_Node_2;
393 -- Node_Id values for & insertion characters in message
395 Error_Msg_Qual_Level : Int renames Err_Vars.Error_Msg_Qual_Level;
396 -- Number of levels of qualification required for type name (see the
397 -- description of the } insertion character. Note that this value does
398 -- note get reset by any Error_Msg call, so the caller is responsible
399 -- for resetting it.
401 Error_Msg_Warn : Boolean renames Err_Vars.Error_Msg_Warn;
402 -- Used if current message contains a < insertion character to indicate
403 -- if the current message is a warning message.
405 Error_Msg_String : String renames Err_Vars.Error_Msg_String;
406 Error_Msg_Strlen : Natural renames Err_Vars.Error_Msg_Strlen;
407 -- Used if current message contains a ~ insertion character to indicate
408 -- insertion of the string Error_Msg_String (1 .. Error_Msg_Strlen).
410 -----------------------------------------------------
411 -- Format of Messages and Manual Quotation Control --
412 -----------------------------------------------------
414 -- Messages are generally all in lower case, except for inserted names
415 -- and appear in one of the following three forms:
417 -- error: text
418 -- warning: text
420 -- The prefixes error and warning are supplied automatically (depending
421 -- on the use of the ? insertion character), and the call to the error
422 -- message routine supplies the text. The "error: " prefix is omitted
423 -- in brief error message formats.
425 -- Reserved Ada keywords in the message are in the default keyword case
426 -- (determined from the given source program), surrounded by quotation
427 -- marks. This is achieved by spelling the reserved word in upper case
428 -- letters, which is recognized as a request for insertion of quotation
429 -- marks by the error text processor. Thus for example:
431 -- Error_Msg_AP ("IS expected");
433 -- would result in the output of one of the following:
435 -- error: "is" expected
436 -- error: "IS" expected
437 -- error: "Is" expected
439 -- the choice between these being made by looking at the casing convention
440 -- used for keywords (actually the first compilation unit keyword) in the
441 -- source file.
443 -- In the case of names, the default mode for the error text processor
444 -- is to surround the name by quotation marks automatically. The case
445 -- used for the identifier names is taken from the source program where
446 -- possible, and otherwise is the default casing convention taken from
447 -- the source file usage.
449 -- In some cases, better control over the placement of quote marks is
450 -- required. This is achieved using manual quotation mode. In this mode,
451 -- one or more insertion sequences is surrounded by backquote characters.
452 -- The backquote characters are output as double quote marks, and normal
453 -- automatic insertion of quotes is suppressed between the double quotes.
454 -- For example:
456 -- Error_Msg_AP ("`END &;` expected");
458 -- generates a message like
460 -- error: "end Open_Scope;" expected
462 -- where the node specifying the name Open_Scope has been stored in
463 -- Error_Msg_Node_1 prior to the call. The great majority of error
464 -- messages operates in normal quotation mode.
466 -- Note: the normal automatic insertion of spaces before insertion
467 -- sequences (such as those that come from & and %) is suppressed in
468 -- manual quotation mode, so blanks, if needed as in the above example,
469 -- must be explicitly present.
471 ----------------------------
472 -- Message ID Definitions --
473 ----------------------------
475 subtype Error_Msg_Id is Erroutc.Error_Msg_Id;
476 function "=" (Left, Right : Error_Msg_Id) return Boolean
477 renames Erroutc."=";
478 -- A type used to represent specific error messages. Used by the clients
479 -- of this package only in the context of the Get_Error_Id and
480 -- Change_Error_Text subprograms.
482 No_Error_Msg : constant Error_Msg_Id := Erroutc.No_Error_Msg;
483 -- A constant which is different from any value returned by Get_Error_Id.
484 -- Typically used by a client to indicate absense of a saved Id value.
486 function Get_Msg_Id return Error_Msg_Id renames Erroutc.Get_Msg_Id;
487 -- Returns the Id of the message most recently posted using one of the
488 -- Error_Msg routines.
490 function Get_Location (E : Error_Msg_Id) return Source_Ptr
491 renames Erroutc.Get_Location;
492 -- Returns the flag location of the error message with the given id E
494 ------------------------
495 -- List Pragmas Table --
496 ------------------------
498 -- When a pragma Page or pragma List is encountered by the parser, an
499 -- entry is made in the following table. This table is then used to
500 -- control the full listing if one is being generated. Note that the
501 -- reason we do the processing in the parser is so that we get proper
502 -- listing control even in syntax check only mode.
504 type List_Pragma_Type is (List_On, List_Off, Page);
506 type List_Pragma_Record is record
507 Ptyp : List_Pragma_Type;
508 Ploc : Source_Ptr;
509 end record;
511 -- Note: Ploc points to the terminating semicolon in the List_Off and Page
512 -- cases, and to the pragma keyword for List_On. In the case of a pragma
513 -- List_Off, a List_On entry is also made in the table, pointing to the
514 -- pragma keyword. This ensures that, as required, a List (Off) pragma is
515 -- listed even in list off mode.
517 package List_Pragmas is new Table.Table (
518 Table_Component_Type => List_Pragma_Record,
519 Table_Index_Type => Int,
520 Table_Low_Bound => 1,
521 Table_Initial => 50,
522 Table_Increment => 200,
523 Table_Name => "List_Pragmas");
525 ---------------------------
526 -- Ignore_Errors Feature --
527 ---------------------------
529 -- In certain cases, notably for optional subunits, the compiler operates
530 -- in a mode where errors are to be ignored, and the whole unit is to be
531 -- considered as not present. To implement this we provide the following
532 -- flag to enable special handling, where error messages are suppressed,
533 -- but the Fatal_Error flag will still be set in the normal manner.
535 Ignore_Errors_Enable : Nat := 0;
536 -- Triggering switch. If non-zero, then ignore errors mode is activated.
537 -- This is a counter to allow convenient nesting of enable/disable.
539 ------------------------------
540 -- Error Output Subprograms --
541 ------------------------------
543 procedure Initialize;
544 -- Initializes for output of error messages. Must be called for each
545 -- source file before using any of the other routines in the package.
547 procedure Finalize;
548 -- Finalize processing of error messages for one file and output message
549 -- indicating the number of detected errors.
551 procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr);
552 -- Output a message at specified location. Can be called from the parser
553 -- or the semantic analyzer.
555 procedure Error_Msg_S (Msg : String);
556 -- Output a message at current scan pointer location. This routine can be
557 -- called only from the parser, since it references Scan_Ptr.
559 procedure Error_Msg_AP (Msg : String);
560 -- Output a message just after the previous token. This routine can be
561 -- called only from the parser, since it references Prev_Token_Ptr.
563 procedure Error_Msg_BC (Msg : String);
564 -- Output a message just before the current token. Note that the important
565 -- difference between this and the previous routine is that the BC case
566 -- posts a flag on the current line, whereas AP can post a flag at the
567 -- end of the preceding line. This routine can be called only from the
568 -- parser, since it references Token_Ptr.
570 procedure Error_Msg_SC (Msg : String);
571 -- Output a message at the start of the current token, unless we are at
572 -- the end of file, in which case we always output the message after the
573 -- last real token in the file. This routine can be called only from the
574 -- parser, since it references Token_Ptr.
576 procedure Error_Msg_SP (Msg : String);
577 -- Output a message at the start of the previous token. This routine can
578 -- be called only from the parser, since it references Prev_Token_Ptr.
580 procedure Error_Msg_N (Msg : String; N : Node_Or_Entity_Id);
581 -- Output a message at the Sloc of the given node. This routine can be
582 -- called from the parser or the semantic analyzer, although the call from
583 -- the latter is much more common (and is the most usual way of generating
584 -- error messages from the analyzer). The message text may contain a
585 -- single & insertion, which will reference the given node. The message is
586 -- suppressed if the node N already has a message posted, or if it is a
587 -- warning and warnings and N is an entity node for which warnings are
588 -- suppressed.
590 procedure Error_Msg_F (Msg : String; N : Node_Id);
591 -- Similar to Error_Msg_N except that the message is placed on the
592 -- first node of the construct N (First_Node (N)).
594 procedure Error_Msg_NE
595 (Msg : String;
596 N : Node_Or_Entity_Id;
597 E : Node_Or_Entity_Id);
598 -- Output a message at the Sloc of the given node N, with an insertion of
599 -- the name from the given entity node E. This is used by the semantic
600 -- routines, where this is a common error message situation. The Msg text
601 -- will contain a & or } as usual to mark the insertion point. This
602 -- routine can be called from the parser or the analyzer.
604 procedure Error_Msg_FE
605 (Msg : String;
606 N : Node_Id;
607 E : Node_Or_Entity_Id);
608 -- Same as Error_Msg_NE, except that the message is placed on the first
609 -- node of the construct N (First_Node (N)).
611 procedure Error_Msg_NEL
612 (Msg : String;
613 N : Node_Or_Entity_Id;
614 E : Node_Or_Entity_Id;
615 Flag_Location : Source_Ptr);
616 -- Exactly the same as Error_Msg_NE, except that the flag is placed at
617 -- the specified Flag_Location instead of at Sloc (N).
619 procedure Error_Msg_NW
620 (Eflag : Boolean;
621 Msg : String;
622 N : Node_Or_Entity_Id);
623 -- This routine is used for posting a message conditionally. The message
624 -- is posted (with the same effect as Error_Msg_N (Msg, N) if and only
625 -- if Eflag is True and if the node N is within the main extended source
626 -- unit and comes from source. Typically this is a warning mode flag.
628 procedure Change_Error_Text (Error_Id : Error_Msg_Id; New_Msg : String);
629 -- The error message text of the message identified by Id is replaced by
630 -- the given text. This text may contain insertion characters in the
631 -- usual manner, and need not be the same length as the original text.
633 function First_Node (C : Node_Id) return Node_Id;
634 -- Given a construct C, finds the first node in the construct, i.e. the
635 -- one with the lowest Sloc value. This is useful in placing error msgs.
637 function First_Sloc (N : Node_Id) return Source_Ptr;
638 -- Given the node for an expression, return a source pointer value that
639 -- points to the start of the first token in the expression. In the case
640 -- where the expression is parenthesized, an attempt is made to include
641 -- the parentheses (i.e. to return the location of the initial paren).
643 procedure Purge_Messages (From : Source_Ptr; To : Source_Ptr)
644 renames Erroutc.Purge_Messages;
645 -- All error messages whose location is in the range From .. To (not
646 -- including the end points) will be deleted from the error listing.
648 procedure Remove_Warning_Messages (N : Node_Id);
649 -- Remove any warning messages corresponding to the Sloc of N or any
650 -- of its descendent nodes. No effect if no such warnings.
652 procedure Remove_Warning_Messages (L : List_Id);
653 -- Remove warnings on all elements of a list
655 procedure Set_Ignore_Errors (To : Boolean);
656 -- Following a call to this procedure with To=True, all error calls are
657 -- ignored. A call with To=False restores the default treatment in which
658 -- error calls are treated as usual (and as described in this spec).
660 procedure Set_Warnings_Mode_Off (Loc : Source_Ptr)
661 renames Erroutc.Set_Warnings_Mode_Off;
662 -- Called in response to a pragma Warnings (Off) to record the source
663 -- location from which warnings are to be turned off.
665 procedure Set_Warnings_Mode_On (Loc : Source_Ptr)
666 renames Erroutc.Set_Warnings_Mode_On;
667 -- Called in response to a pragma Warnings (On) to record the source
668 -- location from which warnings are to be turned back on.
670 procedure Set_Specific_Warning_Off (Loc : Source_Ptr; Msg : String)
671 renames Erroutc.Set_Specific_Warning_Off;
672 -- This is called in response to the two argument form of pragma Warnings
673 -- where the first argument is OFF, and the second argument is the prefix
674 -- of a specific warning to be suppressed. The first argument is the start
675 -- of the suppression range, and the second argument is the string from
676 -- the pragma.
678 procedure Set_Specific_Warning_On
679 (Loc : Source_Ptr;
680 Msg : String;
681 Err : out Boolean)
682 renames Erroutc.Set_Specific_Warning_On;
683 -- This is called in response to the two argument form of pragma Warnings
684 -- where the first argument is ON, and the second argument is the prefix
685 -- of a specific warning to be suppressed. The first argument is the end
686 -- of the suppression range, and the second argument is the string from
687 -- the pragma. Err is set to True on return to report the error of no
688 -- matching Warnings Off pragma preceding this one.
690 function Compilation_Errors return Boolean
691 renames Erroutc.Compilation_Errors;
692 -- Returns true if errors have been detected, or warnings in -gnatwe
693 -- (treat warnings as errors) mode.
695 procedure Error_Msg_CRT (Feature : String; N : Node_Id);
696 -- Posts a non-fatal message on node N saying that the feature identified
697 -- by the Feature argument is not supported in either configurable
698 -- run-time mode or no run-time mode (as appropriate). In the former case,
699 -- the name of the library is output if available.
701 procedure dmsg (Id : Error_Msg_Id) renames Erroutc.dmsg;
702 -- Debugging routine to dump an error message
704 ------------------------------------
705 -- Utility Interface for Back End --
706 ------------------------------------
708 -- The following subprograms can be used by the back end for the purposes
709 -- of concocting error messages that are not output via Errout, e.g. the
710 -- messages generated by the gcc back end.
712 procedure Set_Identifier_Casing
713 (Identifier_Name : System.Address;
714 File_Name : System.Address);
715 -- The identifier is a null terminated string that represents the name of
716 -- an identifier appearing in the source program. File_Name is a null
717 -- terminated string giving the corresponding file name for the identifier
718 -- as obtained from the front end by the use of Full_Debug_Name to the
719 -- source file referenced by the corresponding source location value. On
720 -- return, the name is in Name_Buffer, null terminated with Name_Len set.
721 -- This name is the identifier name as passed, cased according to the
722 -- default identifier casing for the given file.
724 end Errout;