| 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-2025, 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 3, or (at your option) any later ver- -- |
| 14 |
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
| 15 |
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
| 16 |
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- |
| 17 |
-- for more details. You should have received a copy of the GNU General -- |
| 18 |
-- Public License distributed with GNAT; see file COPYING3. If not, go to -- |
| 19 |
-- http://www.gnu.org/licenses for a complete copy of the license. -- |
| 20 |
-- -- |
| 21 |
-- GNAT was originally developed by the GNAT team at New York University. -- |
| 22 |
-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
| 23 |
-- -- |
| 24 |
------------------------------------------------------------------------------ |
| 25 |
|
| 26 |
-- This package contains the routines to output error messages. They are |
| 27 |
-- basically system independent, however in some environments, e.g. when the |
| 28 |
-- parser is embedded into an editor, it may be appropriate to replace the |
| 29 |
-- implementation of this package. |
| 30 |
|
| 31 |
with Err_Vars; |
| 32 |
with Erroutc; |
| 33 |
with Namet; use Namet; |
| 34 |
with Table; |
| 35 |
with Types; use Types; |
| 36 |
with Uintp; use Uintp; |
| 37 |
|
| 38 |
with System; |
| 39 |
|
| 40 |
package Errout is |
| 41 |
|
| 42 |
Current_Error_Source_File : Source_File_Index |
| 43 |
renames Err_Vars.Current_Error_Source_File; |
| 44 |
-- Id of current messages. Used to post file name when unit changes. This |
| 45 |
-- is initialized to Main_Source_File at the start of a compilation, which |
| 46 |
-- means that no file names will be output unless there are errors in |
| 47 |
-- units other than the main unit. However, if the main unit has a pragma |
| 48 |
-- Source_Reference line, then this is initialized to No_Source_File, to |
| 49 |
-- force an initial reference to the real source file name. |
| 50 |
|
| 51 |
----------------------------------- |
| 52 |
-- Suppression of Error Messages -- |
| 53 |
----------------------------------- |
| 54 |
|
| 55 |
-- In an effort to reduce the impact of redundant error messages, the |
| 56 |
-- error output routines in this package normally suppress certain |
| 57 |
-- classes of messages as follows: |
| 58 |
|
| 59 |
-- 1. Identical messages placed at the same point in the text. Such |
| 60 |
-- duplicate error message result for example from rescanning |
| 61 |
-- sections of the text that contain lexical errors. Only one of |
| 62 |
-- such a set of duplicate messages is output, and the rest are |
| 63 |
-- suppressed. |
| 64 |
|
| 65 |
-- 2. If more than one parser message is generated for a single source |
| 66 |
-- line, then only the first message is output, the remaining |
| 67 |
-- messages on the same line are suppressed. |
| 68 |
|
| 69 |
-- 3. If a message is posted on a node for which a message has been |
| 70 |
-- previously posted, then only the first message is retained. The |
| 71 |
-- Error_Posted flag is used to detect such multiple postings. Note |
| 72 |
-- that this only applies to semantic messages, since otherwise |
| 73 |
-- for parser messages, this would be a special case of case 2. |
| 74 |
|
| 75 |
-- 4. If a message is posted on a node whose Etype or Entity |
| 76 |
-- fields reference entities on which an error message has |
| 77 |
-- already been placed, as indicated by the Error_Posted flag |
| 78 |
-- being set on these entities, then the message is suppressed. |
| 79 |
|
| 80 |
-- 5. If a message attempts to insert an Error node, or a direct |
| 81 |
-- reference to the Any_Type node, then the message is suppressed. |
| 82 |
|
| 83 |
-- 6. Note that cases 2-5 only apply to error messages, not warning |
| 84 |
-- messages. Warning messages are only suppressed for case 1, and |
| 85 |
-- when they come from other than the main extended unit. |
| 86 |
|
| 87 |
-- 7. If an error or warning references an internal name, and we have |
| 88 |
-- already placed an error (not warning) message at that location, |
| 89 |
-- then we assume this is cascaded junk and delete the message. |
| 90 |
|
| 91 |
-- This normal suppression action may be overridden in cases 2-5 (but |
| 92 |
-- not in case 1 or 7) by setting All_Errors mode, or by setting the |
| 93 |
-- unconditional message insertion character (!) as described below. |
| 94 |
|
| 95 |
--------------------------------------------------------- |
| 96 |
-- Error Message Text and Message Insertion Characters -- |
| 97 |
--------------------------------------------------------- |
| 98 |
|
| 99 |
-- Error message text strings are composed of lower case letters, digits |
| 100 |
-- and the special characters space, comma, period, colon and semicolon, |
| 101 |
-- apostrophe and parentheses. Special insertion characters can also |
| 102 |
-- appear which cause the error message circuit to modify the given |
| 103 |
-- string as follows: |
| 104 |
|
| 105 |
-- Insertion character % (Percent: insert name from Names table) |
| 106 |
-- The character % is replaced by the text for the name specified by |
| 107 |
-- the Name_Id value stored in Error_Msg_Name_1. A blank precedes the |
| 108 |
-- name if it is preceded by a non-blank character other than left |
| 109 |
-- parenthesis. The name is enclosed in quotes unless manual quotation |
| 110 |
-- mode is set. If the Name_Id is set to No_Name, then no insertion |
| 111 |
-- occurs; if the Name_Id is set to Error_Name, then the string |
| 112 |
-- <error> is inserted. A second and third % may appear in a single |
| 113 |
-- message, similarly replaced by the names which are specified by the |
| 114 |
-- Name_Id values stored in Error_Msg_Name_2 and Error_Msg_Name_3. The |
| 115 |
-- names are decoded and cased according to the current identifier |
| 116 |
-- casing mode. Note: if a unit name ending with %b or %s is passed |
| 117 |
-- for this kind of insertion, this suffix is simply stripped. Use a |
| 118 |
-- unit name insertion ($) to process the suffix. |
| 119 |
-- |
| 120 |
-- Note: the special names _xxx (xxx = Pre/Post/Invariant) are changed |
| 121 |
-- to insert the string xxx'Class into the message. |
| 122 |
|
| 123 |
-- Insertion character %% (Double percent: insert literal name) |
| 124 |
-- The character sequence %% acts as described above for %, except |
| 125 |
-- that the name is simply obtained with Get_Name_String and is not |
| 126 |
-- decoded or cased, it is inserted literally from the names table. |
| 127 |
-- A trailing %b or %s is not treated specially. |
| 128 |
-- |
| 129 |
-- Note: the special names _xxx (xxx = Pre/Post/Invariant) are changed |
| 130 |
-- to insert the string xxx'Class into the message. |
| 131 |
|
| 132 |
-- Insertion character $ (Dollar: insert unit name from Names table) |
| 133 |
-- The character $ is treated similarly to %, except that the name is |
| 134 |
-- obtained from the Unit_Name_Type value in Error_Msg_Unit_1 and |
| 135 |
-- Error_Msg_Unit_2, as provided by Get_Unit_Name_String in package |
| 136 |
-- Uname. Note that this name includes the postfix (spec) or (body) |
| 137 |
-- strings. If this postfix is not required, use the normal % insertion |
| 138 |
-- for the unit name. |
| 139 |
|
| 140 |
-- Insertion character { (Left brace: insert file name from names table) |
| 141 |
-- The character { is treated similarly to %, except that the input |
| 142 |
-- value is a File_Name_Type value stored in Error_Msg_File_1 or |
| 143 |
-- Error_Msg_File_2 or Error_Msg_File_3. The value is output literally, |
| 144 |
-- enclosed in quotes as for %, but the case is not modified, the |
| 145 |
-- insertion is the exact string stored in the names table without |
| 146 |
-- adjusting the casing. |
| 147 |
|
| 148 |
-- Insertion character * (Asterisk: insert reserved word name) |
| 149 |
-- The insertion character * is treated exactly like % except that the |
| 150 |
-- resulting name is cased according to the default conventions for |
| 151 |
-- reserved words (see package Scans). |
| 152 |
|
| 153 |
-- Insertion character & (Ampersand: insert name from node) |
| 154 |
-- The insertion character & is treated similarly to %, except that |
| 155 |
-- the name is taken from the Chars field of the given node, and may |
| 156 |
-- refer to a child unit name, or a selected component. The casing is, |
| 157 |
-- if possible, taken from the original source reference, which is |
| 158 |
-- obtained from the Sloc field of the given node or nodes. If no Sloc |
| 159 |
-- is available (happens e.g. for nodes in package Standard), then the |
| 160 |
-- default case (see Scans spec) is used. The nodes to be used are |
| 161 |
-- stored in Error_Msg_Node_1, Error_Msg_Node_2, which must not be |
| 162 |
-- Empty. The Error node results in the insertion of "<error>". In |
| 163 |
-- addition, if the special global variable Error_Msg_Qual_Level is |
| 164 |
-- non-zero, then the reference will include up to the given number of |
| 165 |
-- levels of qualification, using the scope chain. |
| 166 |
-- |
| 167 |
-- Note: the special names _xxx (xxx = Pre/Post/Invariant) are changed |
| 168 |
-- to insert the string xxx'Class into the message. |
| 169 |
|
| 170 |
-- Insertion character # (Pound: insert line number reference) |
| 171 |
-- The character # is replaced by the string indicating the source |
| 172 |
-- position stored in Error_Msg_Sloc. There are three cases: |
| 173 |
-- |
| 174 |
-- for package Standard: in package Standard |
| 175 |
-- for locations in current file: at line nnn:ccc |
| 176 |
-- for locations in other files: at filename:nnn:ccc |
| 177 |
-- |
| 178 |
-- By convention, the # insertion character is only used at the end of |
| 179 |
-- an error message, so the above strings only appear as the last |
| 180 |
-- characters of an error message. The only exceptions to this rule |
| 181 |
-- are that an RM reference may follow in the form (RM .....) and a |
| 182 |
-- right parenthesis may immediately follow the #. In the case of |
| 183 |
-- continued messages, # can only appear at the end of a group of |
| 184 |
-- continuation messages, except that \\ messages which always start |
| 185 |
-- a new line end the sequence from the point of view of this rule. |
| 186 |
-- The idea is that for any use of -gnatj, it will still be the case |
| 187 |
-- that a location reference appears only at the end of a line. |
| 188 |
|
| 189 |
-- Note: the output of the string "at " is suppressed if the string |
| 190 |
-- " from" or " from " immediately precedes the insertion character #. |
| 191 |
-- Certain messages read better with from than at. |
| 192 |
|
| 193 |
-- Insertion character } (Right brace: insert type reference) |
| 194 |
-- The character } is replaced by a string describing the type |
| 195 |
-- referenced by the entity whose Id is stored in Error_Msg_Node_1. |
| 196 |
-- The string gives the name or description of the type, and also |
| 197 |
-- where appropriate the location of its declaration. Special cases |
| 198 |
-- like "some integer type" are handled appropriately. Only one } is |
| 199 |
-- allowed in a message, since there is not enough room for two (the |
| 200 |
-- insertion can be quite long, including a file name). In addition, if |
| 201 |
-- the special global variable Error_Msg_Qual_Level is non-zero, then |
| 202 |
-- the reference will include up to the given number of levels of |
| 203 |
-- qualification, using the scope chain. |
| 204 |
|
| 205 |
-- Insertion character @ (At: insert column number reference) |
| 206 |
-- The character @ is replaced by null if the RM_Column_Check mode is |
| 207 |
-- off (False). If the switch is on (True), then @ is replaced by the |
| 208 |
-- text string " in column nnn" where nnn is the decimal |
| 209 |
-- representation of the column number stored in Error_Msg_Col plus |
| 210 |
-- one (the plus one is because the number is stored 0-origin and |
| 211 |
-- displayed 1-origin). |
| 212 |
|
| 213 |
-- Insertion character ^ (Caret: insert integer value) |
| 214 |
-- The character ^ is replaced by the decimal conversion of the Uint |
| 215 |
-- value stored in Error_Msg_Uint_1, with a possible leading minus. |
| 216 |
-- A second ^ may occur in the message, in which case it is replaced |
| 217 |
-- by the decimal conversion of the Uint value in Error_Msg_Uint_2. |
| 218 |
|
| 219 |
-- Insertion character > (Greater Than: run time name) |
| 220 |
-- The character > is replaced by a string of the form (name) if |
| 221 |
-- Targparm scanned out a Run_Time_Name (see package Targparm for |
| 222 |
-- details). The name is enclosed in parentheses and output in mixed |
| 223 |
-- case mode (upper case after any space in the name). If no run time |
| 224 |
-- name is defined, this insertion character has no effect. |
| 225 |
|
| 226 |
-- Insertion character ! (Exclamation: unconditional message) |
| 227 |
-- The character ! appearing anywhere in the text of a message makes |
| 228 |
-- the message unconditional which means that it is output even if it |
| 229 |
-- would normally be suppressed. See section above for a description |
| 230 |
-- of the cases in which messages are normally suppressed. Note that |
| 231 |
-- in the case of warnings, the meaning is that the warning should not |
| 232 |
-- be removed in dead code (that's the only time that the use of ! |
| 233 |
-- has any effect for a warning). |
| 234 |
-- |
| 235 |
-- Note: the presence of ! is ignored in continuation messages (i.e. |
| 236 |
-- messages starting with the \ insertion character). The effect of the |
| 237 |
-- use of ! in a parent message automatically applies to all of its |
| 238 |
-- continuation messages (since we clearly don't want any case in which |
| 239 |
-- continuations are separated from the main message). It is allowable |
| 240 |
-- to put ! in continuation messages, and the usual style is to include |
| 241 |
-- it, since it makes it clear that the continuation is part of an |
| 242 |
-- unconditional message. |
| 243 |
|
| 244 |
-- Insertion character !! (Double exclamation: unconditional warning) |
| 245 |
-- Normally warning messages issued in other than the main unit are |
| 246 |
-- suppressed. If the message contains !! then this suppression is |
| 247 |
-- avoided. This is currently used by the Compile_Time_Warning pragma |
| 248 |
-- to ensure the message for a with'ed unit is output, and for warnings |
| 249 |
-- on ineffective back-end inlining, which is detected in units that |
| 250 |
-- contain subprograms to be inlined in the main program. |
| 251 |
|
| 252 |
-- Insertion character ? (Question: warning message -- OBSOLETE) |
| 253 |
-- The character ? appearing anywhere in a message makes the message |
| 254 |
-- warning instead of a normal error message, and the text of the |
| 255 |
-- message will be preceded by "warning:" in the normal case. The |
| 256 |
-- handling of warnings is further controlled by the Warning_Mode |
| 257 |
-- option (-w switch), see package Opt for further details, and also by |
| 258 |
-- the current setting from pragma Warnings. This pragma applies only |
| 259 |
-- to warnings issued from the semantic phase (not the parser), but |
| 260 |
-- currently all relevant warnings are posted by the semantic phase |
| 261 |
-- anyway. Messages starting with (style) are also treated as warning |
| 262 |
-- messages. |
| 263 |
-- |
| 264 |
-- Note: when a warning message is output, the text of the message is |
| 265 |
-- preceded by "warning: " in the normal case. An exception to this |
| 266 |
-- rule occurs when the text of the message starts with "info: " in |
| 267 |
-- which case this string is not prepended. This allows callers to |
| 268 |
-- label certain warnings as informational messages, rather than as |
| 269 |
-- warning messages requiring some action. |
| 270 |
-- |
| 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, but it is |
| 277 |
-- not necessary to go through any computational effort to include it. |
| 278 |
-- |
| 279 |
-- Note: this usage is obsolete; use ?? ?*? ?$? ?x? ?.x? ?_x? to |
| 280 |
-- specify the string to be added when Warning_Doc_Switch is set to |
| 281 |
-- True. If this switch is True, then for simple ? messages it has no |
| 282 |
-- effect. This simple form is to ease transition and may be removed |
| 283 |
-- later except for GNATprove-specific messages (info and warnings) |
| 284 |
-- which are not subject to the same GNAT warning switches. |
| 285 |
|
| 286 |
-- Insertion character ?? (Two question marks: default warning) |
| 287 |
-- Like ?, but if the flag Warning_Doc_Switch is True, adds the string |
| 288 |
-- "[enabled by default]" at the end of the warning message. For |
| 289 |
-- continuations, use this in each continuation message. |
| 290 |
|
| 291 |
-- Insertion character ?x? ?.x? ?_x? (warning with switch) |
| 292 |
-- "x" is a (lower-case) warning switch character. |
| 293 |
-- Like ??, but if the flag Warning_Doc_Switch is True, adds the string |
| 294 |
-- "[-gnatwx]", "[-gnatw.x]", "[-gnatw_x]", or "[-gnatyx]" (for style |
| 295 |
-- messages), at the end of the warning message. For continuations, use |
| 296 |
-- this on each continuation message. |
| 297 |
|
| 298 |
-- Insertion character ?*? (restriction warning) |
| 299 |
-- Like ?, but if the flag Warning_Doc_Switch is True, adds the string |
| 300 |
-- "[restriction warning]" at the end of the warning message. For |
| 301 |
-- continuations, use this on each continuation message. |
| 302 |
|
| 303 |
-- Insertion character ?$? (elaboration informational messages) |
| 304 |
-- Like ?, but if the flag Warning_Doc_Switch is True, adds the string |
| 305 |
-- "[-gnatel]" at the end of the info message. This is used for the |
| 306 |
-- messages generated by the switch -gnatel. For continuations, use |
| 307 |
-- this on each continuation message. |
| 308 |
|
| 309 |
-- Insertion character < (Less Than: conditional warning message) |
| 310 |
-- The character < appearing anywhere in a message is used for a |
| 311 |
-- conditional error message. If Error_Msg_Warn is True, then the |
| 312 |
-- effect is the same as ? described above, and in particular << <x< |
| 313 |
-- <$< <*< have the effect of ?? ?x? ?$? ?*? respectively. If |
| 314 |
-- Error_Msg_Warn is False, then the < << or <X< sequence is ignored |
| 315 |
-- and the message is treated as a error rather than a warning. |
| 316 |
|
| 317 |
-- Insertion character A-Z (Upper case letter: Ada reserved word) |
| 318 |
-- If two or more upper case letters appear in the message, they are |
| 319 |
-- taken as an Ada reserved word, and are converted to the default |
| 320 |
-- case for reserved words (see Scans package spec). Surrounding |
| 321 |
-- quotes are added unless manual quotation mode is currently set. |
| 322 |
-- RM and SPARK are special exceptions, they are never treated as |
| 323 |
-- keywords, and just appear verbatim, with no surrounding quotes. |
| 324 |
-- As a special case, 'R'M is used instead of RM (which is not treated |
| 325 |
-- as a keyword) to indicate when the reference to the RM is possibly |
| 326 |
-- not useful anymore, and could possibly be replaced by a comment |
| 327 |
-- in the source. |
| 328 |
|
| 329 |
-- Insertion character ` (Backquote: set manual quotation mode) |
| 330 |
-- The backquote character always appears in pairs. Each backquote of |
| 331 |
-- the pair is replaced by a double quote character. In addition, any |
| 332 |
-- reserved keywords, or name insertions between these backquotes are |
| 333 |
-- not surrounded by the usual automatic double quotes. See the |
| 334 |
-- section below on manual quotation mode for further details. |
| 335 |
|
| 336 |
-- Insertion character ' (Quote: literal character) |
| 337 |
-- Precedes a character which is placed literally into the message. |
| 338 |
-- Used to insert characters into messages that are one of the |
| 339 |
-- insertion characters defined here. Also used for insertion of |
| 340 |
-- upper case letter sequences not to be treated as keywords. |
| 341 |
|
| 342 |
-- Insertion character \ (Backslash: continuation message) |
| 343 |
-- Indicates that the message is a continuation of a message |
| 344 |
-- previously posted. This is used to ensure that such groups of |
| 345 |
-- messages are treated as a unit. The \ character must be the first |
| 346 |
-- character of the message text. |
| 347 |
|
| 348 |
-- Insertion character \\ (Two backslashes: continuation with new line) |
| 349 |
-- This differs from \ only in -gnatjnn mode (Error_Message_Line_Length |
| 350 |
-- set non-zero). This sequence forces a new line to start even when |
| 351 |
-- continuations are being gathered into a single message. |
| 352 |
|
| 353 |
-- Insertion character | (Vertical bar: non-serious error) |
| 354 |
-- By default, error messages (but not warning messages) are considered |
| 355 |
-- to be fatal error messages, which prevent expansion and generation |
| 356 |
-- of code. If the insertion character | appears, the message is |
| 357 |
-- considered to be nonserious, and Serious_Errors_Detected is not |
| 358 |
-- incremented, so expansion is not prevented by such a msg. This |
| 359 |
-- insertion character is ignored in continuation messages. |
| 360 |
|
| 361 |
-- Insertion character ~ (Tilde: insert string) |
| 362 |
-- Indicates that Error_Msg_String (1 .. Error_Msg_Strlen) is to be |
| 363 |
-- inserted to replace the ~ character. The string is inserted in the |
| 364 |
-- literal form it appears, without any action on special characters. |
| 365 |
|
| 366 |
-- Insertion character [ (Left bracket: will/would be raised at run time) |
| 367 |
-- This is used in messages about exceptions being raised at run-time. |
| 368 |
-- If the current message is a warning message, then if the code is |
| 369 |
-- executed, the exception will be raised, and [ inserts: |
| 370 |
-- |
| 371 |
-- will be raised at run time |
| 372 |
-- |
| 373 |
-- If the current message is an error message, then it is an error |
| 374 |
-- because the exception would have been raised and [ inserts: |
| 375 |
-- |
| 376 |
-- would have been raised at run time |
| 377 |
-- |
| 378 |
-- Typically the message contains a < insertion which means that the |
| 379 |
-- message is a warning or error depending on Error_Msg_Warn. This is |
| 380 |
-- most typically used in the context of messages which are normally |
| 381 |
-- warnings, but are errors in GNATprove mode, corresponding to the |
| 382 |
-- permission in the definition of SPARK that allows an implementation |
| 383 |
-- to reject a program as illegal if a situation arises in which the |
| 384 |
-- compiler can determine that it is certain that a run-time check |
| 385 |
-- would have fail if the statement was executed. |
| 386 |
|
| 387 |
-- Insertion character ] (Right bracket: may/might be raised at run time) |
| 388 |
-- This is like [ except that the insertion messages say may/might, |
| 389 |
-- instead of will/would. |
| 390 |
|
| 391 |
-- Insertion sequence [] (Left and right brackets: error code) |
| 392 |
-- The insertion sequence [] should be replaced by an error code, whose |
| 393 |
-- value is given by Error_Msg_Code. |
| 394 |
|
| 395 |
-- Insertion sequence "(style)" (style message) |
| 396 |
-- This appears only at the start of the message (and not any of its |
| 397 |
-- continuations, if any), and indicates that the message is a style |
| 398 |
-- message. Style messages are also considered to be warnings, but |
| 399 |
-- they do not get a tag. |
| 400 |
|
| 401 |
-- Insertion sequence "info: " (informational message) |
| 402 |
-- This appears only at the start of the message (and not any of its |
| 403 |
-- continuations, if any), and indicates that the message is an info |
| 404 |
-- message. The message will be output with this prefix, and if there |
| 405 |
-- are continuations that are not printed using the -gnatj switch they |
| 406 |
-- will also have this prefix. Informational messages are usually also |
| 407 |
-- warnings, but they don't have to be. |
| 408 |
|
| 409 |
-- Insertion sequence "low: " or "medium: " or "high: " (check message) |
| 410 |
-- This appears only at the start of the message (and not any of its |
| 411 |
-- continuations, if any), and indicates that the message is a check |
| 412 |
-- message. The message will be output with this prefix. Check |
| 413 |
-- messages are not fatal (so are like info messages in that respect) |
| 414 |
-- and are not controlled by pragma Warnings. |
| 415 |
|
| 416 |
----------------------------------------------------- |
| 417 |
-- Global Values Used for Error Message Insertions -- |
| 418 |
----------------------------------------------------- |
| 419 |
|
| 420 |
-- The following global variables are essentially additional parameters |
| 421 |
-- passed to the error message routine for insertion sequences described |
| 422 |
-- above. The reason these are passed globally is that the insertion |
| 423 |
-- mechanism is essentially an untyped one in which the appropriate |
| 424 |
-- variables are set depending on the specific insertion characters used. |
| 425 |
|
| 426 |
-- Note that is mandatory that the caller ensure that global variables |
| 427 |
-- are set before the Error_Msg call, otherwise the result is undefined. |
| 428 |
|
| 429 |
-- Also note that calls to Error_Msg and its variants destroy the value of |
| 430 |
-- these global variables, as a way to support the inclusion of multiple |
| 431 |
-- insertion characters of the same type. For example, support for |
| 432 |
-- multiple characters % for a name in the message (up to 3) is |
| 433 |
-- implemented by unconditionally shifting the value for Error_Msg_Nam_2 |
| 434 |
-- to Error_Msg_Nam_1 and from Error_Msg_Nam_3 to Error_Msg_Nam_2 after |
| 435 |
-- dealing with insertion character %. The caller should ensure that all |
| 436 |
-- global variables are restored if needed prior to calling Error_Msg. |
| 437 |
|
| 438 |
Error_Msg_Col : Column_Number renames Err_Vars.Error_Msg_Col; |
| 439 |
-- Column for @ insertion character in message |
| 440 |
|
| 441 |
Error_Msg_Uint_1 : Uint renames Err_Vars.Error_Msg_Uint_1; |
| 442 |
Error_Msg_Uint_2 : Uint renames Err_Vars.Error_Msg_Uint_2; |
| 443 |
-- Uint values for ^ insertion characters in message |
| 444 |
|
| 445 |
Error_Msg_Code_Digits : constant := Err_Vars.Error_Msg_Code_Digits; |
| 446 |
Error_Msg_Code : Nat renames Err_Vars.Error_Msg_Code; |
| 447 |
-- Nat value for [] insertion sequence in message, where a value of zero |
| 448 |
-- indicates the absence of an error code. |
| 449 |
|
| 450 |
Error_Msg_Sloc : Source_Ptr renames Err_Vars.Error_Msg_Sloc; |
| 451 |
-- Source location for # insertion character in message |
| 452 |
|
| 453 |
Error_Msg_Name_1 : Name_Id renames Err_Vars.Error_Msg_Name_1; |
| 454 |
Error_Msg_Name_2 : Name_Id renames Err_Vars.Error_Msg_Name_2; |
| 455 |
Error_Msg_Name_3 : Name_Id renames Err_Vars.Error_Msg_Name_3; |
| 456 |
Error_Msg_Name_4 : Name_Id renames Err_Vars.Error_Msg_Name_4; |
| 457 |
Error_Msg_Name_5 : Name_Id renames Err_Vars.Error_Msg_Name_5; |
| 458 |
Error_Msg_Name_6 : Name_Id renames Err_Vars.Error_Msg_Name_6; |
| 459 |
-- Name_Id values for % insertion characters in message |
| 460 |
|
| 461 |
Error_Msg_File_1 : File_Name_Type renames Err_Vars.Error_Msg_File_1; |
| 462 |
Error_Msg_File_2 : File_Name_Type renames Err_Vars.Error_Msg_File_2; |
| 463 |
Error_Msg_File_3 : File_Name_Type renames Err_Vars.Error_Msg_File_3; |
| 464 |
-- File_Name_Type values for { insertion characters in message |
| 465 |
|
| 466 |
Error_Msg_Unit_1 : Unit_Name_Type renames Err_Vars.Error_Msg_Unit_1; |
| 467 |
Error_Msg_Unit_2 : Unit_Name_Type renames Err_Vars.Error_Msg_Unit_2; |
| 468 |
-- Unit_Name_Type values for $ insertion characters in message |
| 469 |
|
| 470 |
Error_Msg_Node_1 : Node_Id renames Err_Vars.Error_Msg_Node_1; |
| 471 |
Error_Msg_Node_2 : Node_Id renames Err_Vars.Error_Msg_Node_2; |
| 472 |
Error_Msg_Node_3 : Node_Id renames Err_Vars.Error_Msg_Node_3; |
| 473 |
Error_Msg_Node_4 : Node_Id renames Err_Vars.Error_Msg_Node_4; |
| 474 |
Error_Msg_Node_5 : Node_Id renames Err_Vars.Error_Msg_Node_5; |
| 475 |
Error_Msg_Node_6 : Node_Id renames Err_Vars.Error_Msg_Node_6; |
| 476 |
-- Node_Id values for & insertion characters in message |
| 477 |
|
| 478 |
Error_Msg_Qual_Level : Nat renames Err_Vars.Error_Msg_Qual_Level; |
| 479 |
-- Number of levels of qualification required for type name (see the |
| 480 |
-- description of the } insertion character). Note that this value does |
| 481 |
-- not get reset by any Error_Msg call, so the caller is responsible |
| 482 |
-- for resetting it. |
| 483 |
|
| 484 |
Error_Msg_Warn : Boolean renames Err_Vars.Error_Msg_Warn; |
| 485 |
-- Used if current message contains a < insertion character to indicate |
| 486 |
-- if the current message is a warning message. Must be set appropriately |
| 487 |
-- before any call to Error_Msg_xxx with a < insertion character present. |
| 488 |
-- Setting is irrelevant if no < insertion character is present. |
| 489 |
|
| 490 |
Error_Msg_String : String renames Err_Vars.Error_Msg_String; |
| 491 |
Error_Msg_Strlen : Natural renames Err_Vars.Error_Msg_Strlen; |
| 492 |
-- Used if current message contains a ~ insertion character to indicate |
| 493 |
-- insertion of the string Error_Msg_String (1 .. Error_Msg_Strlen). |
| 494 |
|
| 495 |
----------------------------------------------------- |
| 496 |
-- Format of Messages and Manual Quotation Control -- |
| 497 |
----------------------------------------------------- |
| 498 |
|
| 499 |
-- Messages are generally all in lower case, except for inserted names |
| 500 |
-- and appear in one of the following three forms: |
| 501 |
|
| 502 |
-- error: text |
| 503 |
-- warning: text |
| 504 |
|
| 505 |
-- The prefixes error and warning are supplied automatically (depending |
| 506 |
-- on the use of the ? insertion character), and the call to the error |
| 507 |
-- message routine supplies the text. The "error: " prefix is omitted |
| 508 |
-- if -gnatd_U is among the options given to gnat. |
| 509 |
|
| 510 |
-- Reserved Ada keywords in the message are in the default keyword case |
| 511 |
-- (determined from the given source program), surrounded by quotation |
| 512 |
-- marks. This is achieved by spelling the reserved word in upper case |
| 513 |
-- letters, which is recognized as a request for insertion of quotation |
| 514 |
-- marks by the error text processor. Thus for example: |
| 515 |
|
| 516 |
-- Error_Msg_AP ("IS expected"); |
| 517 |
|
| 518 |
-- would result in the output of one of the following: |
| 519 |
|
| 520 |
-- error: "is" expected |
| 521 |
-- error: "IS" expected |
| 522 |
-- error: "Is" expected |
| 523 |
|
| 524 |
-- the choice between these being made by looking at the casing convention |
| 525 |
-- used for keywords (actually the first compilation unit keyword) in the |
| 526 |
-- source file. |
| 527 |
|
| 528 |
-- Note: a special exception is that RM is never treated as a keyword |
| 529 |
-- but instead is copied literally into the message, this avoids the |
| 530 |
-- need for writing 'R'M for all reference manual quotes. A similar |
| 531 |
-- exception is applied to the occurrence of the string SPARK used in |
| 532 |
-- error messages about the SPARK subset of Ada. |
| 533 |
|
| 534 |
-- In the case of names, the default mode for the error text processor |
| 535 |
-- is to surround the name by quotation marks automatically. The case |
| 536 |
-- used for the identifier names is taken from the source program where |
| 537 |
-- possible, and otherwise is the default casing convention taken from |
| 538 |
-- the source file usage. |
| 539 |
|
| 540 |
-- In some cases, better control over the placement of quote marks is |
| 541 |
-- required. This is achieved using manual quotation mode. In this mode, |
| 542 |
-- one or more insertion sequences is surrounded by backquote characters. |
| 543 |
-- The backquote characters are output as double quote marks, and normal |
| 544 |
-- automatic insertion of quotes is suppressed between the double quotes. |
| 545 |
-- For example: |
| 546 |
|
| 547 |
-- Error_Msg_AP ("`END &;` expected"); |
| 548 |
|
| 549 |
-- generates a message like |
| 550 |
|
| 551 |
-- error: "end Open_Scope;" expected |
| 552 |
|
| 553 |
-- where the node specifying the name Open_Scope has been stored in |
| 554 |
-- Error_Msg_Node_1 prior to the call. The great majority of error |
| 555 |
-- messages operates in normal quotation mode. |
| 556 |
|
| 557 |
-- Note: the normal automatic insertion of spaces before insertion |
| 558 |
-- sequences (such as those that come from & and %) is suppressed in |
| 559 |
-- manual quotation mode, so blanks, if needed as in the above example, |
| 560 |
-- must be explicitly present. |
| 561 |
|
| 562 |
---------------------------- |
| 563 |
-- Message ID Definitions -- |
| 564 |
---------------------------- |
| 565 |
|
| 566 |
subtype Error_Msg_Id is Erroutc.Error_Msg_Id; |
| 567 |
function "=" (Left, Right : Error_Msg_Id) return Boolean |
| 568 |
renames Erroutc."="; |
| 569 |
-- A type used to represent specific error messages. Used by the clients |
| 570 |
-- of this package only in the context of the Get_Error_Id and |
| 571 |
-- Change_Error_Text subprograms. |
| 572 |
|
| 573 |
No_Error_Msg : constant Error_Msg_Id := Erroutc.No_Error_Msg; |
| 574 |
-- A constant which is different from any value returned by Get_Error_Id. |
| 575 |
-- Typically used by a client to indicate absense of a saved Id value. |
| 576 |
|
| 577 |
Warning_Msg : Error_Msg_Id := No_Error_Msg; |
| 578 |
-- This is set if a warning message is generated to the ID of the resulting |
| 579 |
-- message. Continuation messages have no effect. It is legitimate for the |
| 580 |
-- client to set this to No_Error_Msg and then test it to see if a warning |
| 581 |
-- message has been issued. |
| 582 |
|
| 583 |
procedure Delete_Warning_And_Continuations (Msg : Error_Msg_Id); |
| 584 |
-- Deletes the given warning message and all its continuations. This is |
| 585 |
-- typically used in conjunction with reading the value of Warning_Msg. |
| 586 |
|
| 587 |
function Get_Msg_Id return Error_Msg_Id renames Erroutc.Get_Msg_Id; |
| 588 |
-- Returns the Id of the message most recently posted using one of the |
| 589 |
-- Error_Msg routines. |
| 590 |
|
| 591 |
function Get_Location (E : Error_Msg_Id) return Source_Ptr |
| 592 |
renames Erroutc.Get_Location; |
| 593 |
-- Returns the flag location of the error message with the given id E |
| 594 |
|
| 595 |
------------------------ |
| 596 |
-- GNAT Explain Codes -- |
| 597 |
------------------------ |
| 598 |
|
| 599 |
-- Explain codes are used in GNATprove to provide more information on |
| 600 |
-- selected error/warning messages. The subset of those codes used in |
| 601 |
-- the GNAT frontend are defined here. |
| 602 |
|
| 603 |
GEC_None : constant := 0000; |
| 604 |
GEC_Volatile_At_Library_Level : constant := 0001; |
| 605 |
GEC_Type_Early_Call_Region : constant := 0003; |
| 606 |
GEC_Volatile_Non_Interfering_Context : constant := 0004; |
| 607 |
GEC_Required_Part_Of : constant := 0009; |
| 608 |
GEC_Ownership_Moved_Object : constant := 0010; |
| 609 |
GEC_SPARK_Mode_On_Not_Library_Level : constant := 0011; |
| 610 |
GEC_Output_In_Function_Global_Or_Depends : constant := 0014; |
| 611 |
GEC_Out_Parameter_In_Function : constant := 0015; |
| 612 |
GEC_Always_Terminates_On_Function : constant := 0016; |
| 613 |
GEC_Exceptional_Cases_On_Function : constant := 0017; |
| 614 |
|
| 615 |
------------------------ |
| 616 |
-- List Pragmas Table -- |
| 617 |
------------------------ |
| 618 |
|
| 619 |
-- When a pragma Page or pragma List is encountered by the parser, an |
| 620 |
-- entry is made in the following table. This table is then used to |
| 621 |
-- control the full listing if one is being generated. Note that the |
| 622 |
-- reason we do the processing in the parser is so that we get proper |
| 623 |
-- listing control even in syntax check only mode. |
| 624 |
|
| 625 |
type List_Pragma_Type is (List_On, List_Off, Page); |
| 626 |
|
| 627 |
type List_Pragma_Record is record |
| 628 |
Ptyp : List_Pragma_Type; |
| 629 |
Ploc : Source_Ptr; |
| 630 |
end record; |
| 631 |
|
| 632 |
-- Note: Ploc points to the terminating semicolon in the List_Off and Page |
| 633 |
-- cases, and to the pragma keyword for List_On. In the case of a pragma |
| 634 |
-- List_Off, a List_On entry is also made in the table, pointing to the |
| 635 |
-- pragma keyword. This ensures that, as required, a List (Off) pragma is |
| 636 |
-- listed even in list off mode. |
| 637 |
|
| 638 |
package List_Pragmas is new Table.Table ( |
| 639 |
Table_Component_Type => List_Pragma_Record, |
| 640 |
Table_Index_Type => Int, |
| 641 |
Table_Low_Bound => 1, |
| 642 |
Table_Initial => 50, |
| 643 |
Table_Increment => 200, |
| 644 |
Table_Name => "List_Pragmas"); |
| 645 |
|
| 646 |
--------------------------- |
| 647 |
-- Ignore_Errors Feature -- |
| 648 |
--------------------------- |
| 649 |
|
| 650 |
-- In certain cases, notably for optional subunits, the compiler operates |
| 651 |
-- in a mode where errors are to be ignored, and the whole unit is to be |
| 652 |
-- considered as not present. To implement this we provide the following |
| 653 |
-- flag to enable special handling, where error messages are suppressed, |
| 654 |
-- but the Fatal_Error flag will still be set in the normal manner. |
| 655 |
|
| 656 |
Ignore_Errors_Enable : Nat := 0; |
| 657 |
-- Triggering switch. If non-zero, then ignore errors mode is activated. |
| 658 |
-- This is a counter to allow convenient nesting of enable/disable. |
| 659 |
|
| 660 |
----------------------- |
| 661 |
-- CODEFIX Facility -- |
| 662 |
----------------------- |
| 663 |
|
| 664 |
-- The GNAT Studio and GNATBench IDE's have a codefix facility that allows |
| 665 |
-- for automatic correction of a subset of the errors and warnings issued |
| 666 |
-- by the compiler. This is done by recognizing the text of specific |
| 667 |
-- messages using appropriate matching patterns. |
| 668 |
|
| 669 |
-- The text of such messages should not be altered without coordinating |
| 670 |
-- with the codefix code. All such messages are marked by a specific |
| 671 |
-- style of comments, as shown by the following example: |
| 672 |
|
| 673 |
-- Error_Msg_N -- CODEFIX |
| 674 |
-- (parameters ....) |
| 675 |
|
| 676 |
-- Any message marked with this -- CODEFIX comment should not be modified |
| 677 |
-- without appropriate coordination. |
| 678 |
|
| 679 |
------------------------------ |
| 680 |
-- Error Output Subprograms -- |
| 681 |
------------------------------ |
| 682 |
|
| 683 |
procedure Initialize; |
| 684 |
-- Initializes for output of error messages. Must be called for each |
| 685 |
-- source file before using any of the other routines in the package. |
| 686 |
|
| 687 |
procedure Finalize (Last_Call : Boolean); |
| 688 |
-- Finalize processing of error message list. Includes processing for |
| 689 |
-- duplicated error messages, and other similar final adjustment of the |
| 690 |
-- list of error messages. Note that this procedure must be called before |
| 691 |
-- calling Compilation_Errors to determine if there were any errors. It |
| 692 |
-- is perfectly fine to call Finalize more than once, providing that the |
| 693 |
-- parameter Last_Call is set False for every call except the last call. |
| 694 |
|
| 695 |
-- This multiple call capability is used to do some processing that may |
| 696 |
-- generate messages. Call Finalize to eliminate duplicates and remove |
| 697 |
-- deleted warnings. Test for compilation errors using Compilation_Errors, |
| 698 |
-- then generate some more errors/warnings, call Finalize again to make |
| 699 |
-- sure that all duplicates in these new messages are dealt with, then |
| 700 |
-- finally call Output_Messages to output the final list of messages. The |
| 701 |
-- argument Last_Call must be set False on all calls except the last call, |
| 702 |
-- and must be set True on the last call (a value of True activates some |
| 703 |
-- processing that must only be done after all messages are posted). |
| 704 |
|
| 705 |
procedure Output_Messages; |
| 706 |
-- Output list of messages, including messages giving number of detected |
| 707 |
-- errors and warnings. |
| 708 |
|
| 709 |
procedure Error_Msg |
| 710 |
(Msg : String; Flag_Location : Source_Ptr); |
| 711 |
procedure Error_Msg |
| 712 |
(Msg : String; Flag_Span : Source_Span); |
| 713 |
procedure Error_Msg |
| 714 |
(Msg : String; Flag_Location : Source_Ptr; N : Node_Id); |
| 715 |
procedure Error_Msg |
| 716 |
(Msg : String; Flag_Span : Source_Span; N : Node_Id); |
| 717 |
-- Output a message at specified location. Can be called from the parser |
| 718 |
-- or the semantic analyzer. If N is set, points to the relevant node for |
| 719 |
-- this message. The version with a span is preferred whenever possible, |
| 720 |
-- in other cases the version with a location can still be used. |
| 721 |
|
| 722 |
procedure Error_Msg |
| 723 |
(Msg : String; |
| 724 |
Flag_Location : Source_Ptr; |
| 725 |
N : Node_Id; |
| 726 |
Is_Compile_Time_Pragma : Boolean); |
| 727 |
-- Same as Error_Msg (String, Source_Ptr, Node_Id) except |
| 728 |
-- Is_Compile_Time_Pragma lets the caller specify whether this is a |
| 729 |
-- Compile_Time_Warning or Compile_Time_Error pragma. |
| 730 |
|
| 731 |
procedure Error_Msg_S (Msg : String); |
| 732 |
-- Output a message at current scan pointer location. This routine can be |
| 733 |
-- called only from the parser, since it references Scan_Ptr. |
| 734 |
|
| 735 |
procedure Error_Msg_AP (Msg : String); |
| 736 |
-- Output a message just after the previous token. This routine can be |
| 737 |
-- called only from the parser, since it references Prev_Token_Ptr. |
| 738 |
|
| 739 |
procedure Error_Msg_BC (Msg : String); |
| 740 |
-- Output a message just before the current token. Note that the important |
| 741 |
-- difference between this and the previous routine is that the BC case |
| 742 |
-- posts a flag on the current line, whereas AP can post a flag at the |
| 743 |
-- end of the preceding line. This routine can be called only from the |
| 744 |
-- parser, since it references Token_Ptr. |
| 745 |
|
| 746 |
procedure Error_Msg_SC (Msg : String); |
| 747 |
-- Output a message at the start of the current token, unless we are at |
| 748 |
-- the end of file, in which case we always output the message after the |
| 749 |
-- last real token in the file. This routine can be called only from the |
| 750 |
-- parser, since it references Token_Ptr. |
| 751 |
|
| 752 |
procedure Error_Msg_SP (Msg : String); |
| 753 |
-- Output a message at the start of the previous token. This routine can |
| 754 |
-- be called only from the parser, since it references Prev_Token_Ptr. |
| 755 |
|
| 756 |
procedure Error_Msg_N (Msg : String; N : Node_Or_Entity_Id); |
| 757 |
-- Output a message at the Sloc of the given node. This routine can be |
| 758 |
-- called from the parser or the semantic analyzer, although the call from |
| 759 |
-- the latter is much more common (and is the most usual way of generating |
| 760 |
-- error messages from the analyzer). The message text may contain a |
| 761 |
-- single & insertion, which will reference the given node. The message is |
| 762 |
-- suppressed if the node N already has a message posted, or if it is a |
| 763 |
-- warning and N is an entity node for which warnings are suppressed. |
| 764 |
|
| 765 |
-- WARNING: There is a matching C declaration of this subprogram in fe.h |
| 766 |
|
| 767 |
procedure Error_Msg_F (Msg : String; N : Node_Id); |
| 768 |
-- Similar to Error_Msg_N except that the message is placed on the first |
| 769 |
-- node of the construct N (First_Node (N)). Note that this procedure uses |
| 770 |
-- Original_Node to look at the original source tree, since that's what we |
| 771 |
-- want for placing an error message flag in the right place. |
| 772 |
|
| 773 |
procedure Error_Msg_NE |
| 774 |
(Msg : String; |
| 775 |
N : Node_Or_Entity_Id; |
| 776 |
E : Node_Or_Entity_Id); |
| 777 |
-- Output a message at the Sloc of the given node N, with an insertion of |
| 778 |
-- the name from the given entity node E. This is used by the semantic |
| 779 |
-- routines, where this is a common error message situation. The Msg text |
| 780 |
-- will contain a & or } as usual to mark the insertion point. This |
| 781 |
-- routine can be called from the parser or the analyzer. |
| 782 |
|
| 783 |
-- WARNING: There is a matching C declaration of this subprogram in fe.h |
| 784 |
|
| 785 |
procedure Error_Msg_FE |
| 786 |
(Msg : String; |
| 787 |
N : Node_Id; |
| 788 |
E : Node_Or_Entity_Id); |
| 789 |
-- Same as Error_Msg_NE, except that the message is placed on the first |
| 790 |
-- node of the construct N (First_Node (N)). |
| 791 |
|
| 792 |
procedure Error_Msg_NEL |
| 793 |
(Msg : String; |
| 794 |
N : Node_Or_Entity_Id; |
| 795 |
E : Node_Or_Entity_Id; |
| 796 |
Flag_Location : Source_Ptr); |
| 797 |
procedure Error_Msg_NEL |
| 798 |
(Msg : String; |
| 799 |
N : Node_Or_Entity_Id; |
| 800 |
E : Node_Or_Entity_Id; |
| 801 |
Flag_Span : Source_Span); |
| 802 |
-- Exactly the same as Error_Msg_NE, except that the flag is placed at |
| 803 |
-- the specified Flag_Location/Flag_Span instead of at Sloc (N). |
| 804 |
|
| 805 |
procedure Error_Msg_NW |
| 806 |
(Eflag : Boolean; |
| 807 |
Msg : String; |
| 808 |
N : Node_Or_Entity_Id); |
| 809 |
-- This routine is used for posting a message conditionally. The message |
| 810 |
-- is posted (with the same effect as Error_Msg_N (Msg, N) if and only |
| 811 |
-- if Eflag is True and if the node N is within the main extended source |
| 812 |
-- unit and comes from source. Typically this is a warning mode flag. |
| 813 |
-- This routine can only be called during semantic analysis. It may not |
| 814 |
-- be called during parsing. |
| 815 |
|
| 816 |
procedure Change_Error_Text (Error_Id : Error_Msg_Id; New_Msg : String); |
| 817 |
-- The error message text of the message identified by Id is replaced by |
| 818 |
-- the given text. This text may contain insertion characters in the |
| 819 |
-- usual manner, and need not be the same length as the original text. |
| 820 |
|
| 821 |
procedure First_And_Last_Nodes |
| 822 |
(C : Node_Id; |
| 823 |
First_Node, Last_Node : out Node_Id); |
| 824 |
-- Given a construct C, finds the first and last node in the construct, |
| 825 |
-- i.e. the ones with the lowest and highest Sloc value. This is useful in |
| 826 |
-- placing error msgs. Note that this procedure uses Original_Node to look |
| 827 |
-- at the original source tree, since that's what we want for placing an |
| 828 |
-- error message flag in the right place. |
| 829 |
|
| 830 |
function First_Node (C : Node_Id) return Node_Id; |
| 831 |
-- Return the first output of First_And_Last_Nodes |
| 832 |
|
| 833 |
function First_Sloc (N : Node_Id) return Source_Ptr; |
| 834 |
-- Given the node for an expression, return a source pointer value that |
| 835 |
-- points to the start of the first token in the expression. In the case |
| 836 |
-- where the expression is parenthesized, an attempt is made to include |
| 837 |
-- the parentheses (i.e. to return the location of the initial paren). |
| 838 |
|
| 839 |
function Get_Ignore_Errors return Boolean; |
| 840 |
-- Return True if all error calls are ignored. |
| 841 |
|
| 842 |
function Last_Node (C : Node_Id) return Node_Id; |
| 843 |
-- Return the last output of First_And_Last_Nodes |
| 844 |
|
| 845 |
function Last_Sloc (N : Node_Id) return Source_Ptr; |
| 846 |
-- Given the node for an expression, return a source pointer value that |
| 847 |
-- points to the end of the last token in the expression. In the case |
| 848 |
-- where the expression is parenthesized, an attempt is made to include |
| 849 |
-- the parentheses (i.e. to return the location of the final paren). |
| 850 |
|
| 851 |
procedure Purge_Messages (From : Source_Ptr; To : Source_Ptr) |
| 852 |
renames Erroutc.Purge_Messages; |
| 853 |
-- All error messages whose location is in the range From .. To (not |
| 854 |
-- including the end points) will be deleted from the error listing. |
| 855 |
|
| 856 |
procedure Remove_Warning_Messages (N : Node_Id); |
| 857 |
-- Remove any warning messages corresponding to the Sloc of N or any |
| 858 |
-- of its descendant nodes. No effect if no such warnings. Note that |
| 859 |
-- style messages (identified by the fact that they start with "(style)") |
| 860 |
-- are not removed by this call. Basically the idea behind this procedure |
| 861 |
-- is to remove warnings about execution conditions from known dead code. |
| 862 |
|
| 863 |
procedure Remove_Warning_Messages (L : List_Id); |
| 864 |
-- Remove warnings on all elements of a list (Calls Remove_Warning_Messages |
| 865 |
-- on each element of the list, see above). |
| 866 |
|
| 867 |
procedure Set_Ignore_Errors (To : Boolean); |
| 868 |
-- Following a call to this procedure with To=True, all error calls are |
| 869 |
-- ignored. A call with To=False restores the default treatment in which |
| 870 |
-- error calls are treated as usual (and as described in this spec). |
| 871 |
|
| 872 |
procedure Set_Msg_Text (Text : String; Flag : Source_Ptr); |
| 873 |
-- Add a sequence of characters to the current message. The characters may |
| 874 |
-- be one of the special insertion characters (see documentation in spec). |
| 875 |
-- Flag is the location at which the error is to be posted, which is used |
| 876 |
-- to determine whether or not the # insertion needs a file name. The |
| 877 |
-- variables Msg_Buffer are set on return Msglen. |
| 878 |
|
| 879 |
procedure Set_Warnings_Mode_Off (Loc : Source_Ptr; Reason : String_Id) |
| 880 |
renames Erroutc.Set_Warnings_Mode_Off; |
| 881 |
-- Called in response to a pragma Warnings (Off) to record the source |
| 882 |
-- location from which warnings are to be turned off. Reason is the |
| 883 |
-- Reason from the pragma, or the null string if none is given. |
| 884 |
|
| 885 |
procedure Set_Warnings_Mode_On (Loc : Source_Ptr) |
| 886 |
renames Erroutc.Set_Warnings_Mode_On; |
| 887 |
-- Called in response to a pragma Warnings (On) to record the source |
| 888 |
-- location from which warnings are to be turned back on. |
| 889 |
|
| 890 |
procedure Set_Specific_Warning_Off |
| 891 |
(Node : Node_Id; |
| 892 |
Msg : String; |
| 893 |
Reason : String_Id; |
| 894 |
Config : Boolean; |
| 895 |
Used : Boolean := False) |
| 896 |
renames Erroutc.Set_Specific_Warning_Off; |
| 897 |
-- This is called in response to the two argument form of pragma Warnings |
| 898 |
-- where the first argument is OFF, and the second argument is a string |
| 899 |
-- which identifies a specific warning to be suppressed. The first argument |
| 900 |
-- is the start of the suppression range, and the second argument is the |
| 901 |
-- string from the pragma. Loc is the location of the pragma (which is the |
| 902 |
-- start of the range to suppress). Reason is the reason string from the |
| 903 |
-- pragma, or the null string if no reason is given. Config is True for the |
| 904 |
-- configuration pragma case (where there is no requirement for a matching |
| 905 |
-- OFF pragma). Used is set True to disable the check that the warning |
| 906 |
-- actually has the effect of suppressing a warning. |
| 907 |
|
| 908 |
procedure Set_Specific_Warning_On |
| 909 |
(Loc : Source_Ptr; |
| 910 |
Msg : String; |
| 911 |
Err : out Boolean) |
| 912 |
renames Erroutc.Set_Specific_Warning_On; |
| 913 |
-- This is called in response to the two argument form of pragma Warnings |
| 914 |
-- where the first argument is ON, and the second argument is the prefix |
| 915 |
-- of a specific warning to be suppressed. The first argument is the end |
| 916 |
-- of the suppression range, and the second argument is the string from |
| 917 |
-- the pragma. Err is set to True on return to report the error of no |
| 918 |
-- matching Warnings Off pragma preceding this one. |
| 919 |
|
| 920 |
function Compilation_Errors return Boolean; |
| 921 |
-- Returns True if errors have been detected, or warnings when they are |
| 922 |
-- treated as errors, which corresponds to switch -gnatwe in the compiler, |
| 923 |
-- and other switches in other tools. Note that it is mandatory to call |
| 924 |
-- Finalize before calling this routine. |
| 925 |
|
| 926 |
procedure Error_Msg_CRT (Feature : String; N : Node_Id); |
| 927 |
-- Posts a non-fatal message on node N saying that the feature identified |
| 928 |
-- by the Feature argument is not supported in either configurable |
| 929 |
-- run-time mode or no run-time mode (as appropriate). In the former case, |
| 930 |
-- the name of the library is output if available. |
| 931 |
|
| 932 |
procedure Error_Msg_PT (E : Entity_Id; Iface_Prim : Entity_Id); |
| 933 |
-- Posts an error on protected type entry or subprogram E (referencing its |
| 934 |
-- overridden interface primitive Iface_Prim) indicating wrong mode of the |
| 935 |
-- first formal (RM 9.4(11.9/3)). |
| 936 |
|
| 937 |
procedure Error_Msg_Ada_2005_Extension (Extension : String); |
| 938 |
-- Analogous to Error_Msg_Ada_2012_Feature, but phrase the message using |
| 939 |
-- "extension" and not "feature". This routine is only used in the parser, |
| 940 |
-- so the error is always placed at the Token_Ptr. |
| 941 |
|
| 942 |
procedure Error_Msg_Ada_2012_Feature (Feature : String; Loc : Source_Ptr); |
| 943 |
-- If not operating in Ada 2012 mode or higher, posts errors complaining |
| 944 |
-- that Feature is only supported in Ada 2012, with appropriate suggestions |
| 945 |
-- to fix this. Loc is the location at which the flag is to be posted. |
| 946 |
-- Feature, which appears at the start of the first generated message, may |
| 947 |
-- contain error message insertion characters in the normal manner, and in |
| 948 |
-- particular may start with | to flag a non-serious error. |
| 949 |
|
| 950 |
procedure Error_Msg_Ada_2022_Feature (Feature : String; Loc : Source_Ptr); |
| 951 |
-- Analogous to Error_Msg_Ada_2012_Feature, for Ada 2022 |
| 952 |
|
| 953 |
procedure Error_Msg_GNAT_Extension |
| 954 |
(Extension : String; |
| 955 |
Loc : Source_Ptr; |
| 956 |
Is_Core_Extension : Boolean := False); |
| 957 |
-- To be called as part of checking a GNAT language extension (either a |
| 958 |
-- core extension or not, as indicated by the Is_Core_Extension parameter). |
| 959 |
-- If switch -gnatX0 or pragma Extension_Allowed (All) is in effect, then |
| 960 |
-- either kind of extension is allowed; if switch -gnatX or pragma |
| 961 |
-- Extensions_Allowed (On) is in effect, then only core extensions are |
| 962 |
-- allowed. Otherwise, no extensions are allowed. A disallowed construct |
| 963 |
-- is flagged as an error. Loc indicates the source location of the |
| 964 |
-- extension construct. |
| 965 |
|
| 966 |
procedure dmsg (Id : Error_Msg_Id) renames Erroutc.dmsg; |
| 967 |
-- Debugging routine to dump an error message |
| 968 |
|
| 969 |
------------------------------------ |
| 970 |
-- SPARK Error Output Subprograms -- |
| 971 |
------------------------------------ |
| 972 |
|
| 973 |
-- The following routines are intended to report semantic errors in SPARK |
| 974 |
-- constructs subject to aspect/pragma SPARK_Mode. Note that syntax errors |
| 975 |
-- must be reported using the Error_Msg_XXX routines. This allows for the |
| 976 |
-- partial analysis of SPARK features when they are disabled via SPARK_Mode |
| 977 |
-- set to "off". |
| 978 |
|
| 979 |
procedure SPARK_Msg_N (Msg : String; N : Node_Or_Entity_Id); |
| 980 |
pragma Inline (SPARK_Msg_N); |
| 981 |
-- Same as Error_Msg_N, but the error is suppressed if SPARK_Mode is Off. |
| 982 |
-- The routine is inlined because it acts as a simple wrapper. |
| 983 |
|
| 984 |
procedure SPARK_Msg_NE |
| 985 |
(Msg : String; |
| 986 |
N : Node_Or_Entity_Id; |
| 987 |
E : Node_Or_Entity_Id); |
| 988 |
pragma Inline (SPARK_Msg_NE); |
| 989 |
-- Same as Error_Msg_NE, but the error is suppressed if SPARK_Mode is Off. |
| 990 |
-- The routine is inlined because it acts as a simple wrapper. |
| 991 |
|
| 992 |
------------------------------------------ |
| 993 |
-- Utility Interface for Casing Control -- |
| 994 |
------------------------------------------ |
| 995 |
|
| 996 |
procedure Adjust_Name_Case |
| 997 |
(Buf : in out Bounded_String; |
| 998 |
Loc : Source_Ptr); |
| 999 |
-- Given a name stored in Buf, set proper casing. Loc is an associated |
| 1000 |
-- source position, and if we can find a match between the name in Buf and |
| 1001 |
-- the name at that source location, we copy the casing from the source, |
| 1002 |
-- otherwise we set appropriate default casing. |
| 1003 |
|
| 1004 |
procedure Set_Identifier_Casing |
| 1005 |
(Identifier_Name : System.Address; |
| 1006 |
File_Name : System.Address); |
| 1007 |
pragma Convention (C, Set_Identifier_Casing); |
| 1008 |
-- This subprogram can be used by the back end for the purposes of |
| 1009 |
-- concocting error messages that are not output via Errout, e.g. |
| 1010 |
-- the messages generated by the gcc back end. |
| 1011 |
-- |
| 1012 |
-- The identifier is a null terminated string that represents the name of |
| 1013 |
-- an identifier appearing in the source program. File_Name is a null |
| 1014 |
-- terminated string giving the corresponding file name for the identifier |
| 1015 |
-- as obtained from the front end by the use of Full_Debug_Name to the |
| 1016 |
-- source file referenced by the corresponding source location value. On |
| 1017 |
-- return, the name is in Name_Buffer, null terminated with Name_Len set. |
| 1018 |
-- This name is the identifier name as passed, cased according to the |
| 1019 |
-- default identifier casing for the given file. |
| 1020 |
|
| 1021 |
-- WARNING: There is a matching C declaration of this subprogram in fe.h |
| 1022 |
|
| 1023 |
function Is_Size_Too_Small_Message (S : String) return Boolean; |
| 1024 |
Size_Too_Small_Message : constant String := |
| 1025 |
"size for& too small, minimum allowed is ^"; |
| 1026 |
-- This message is printed in Freeze and Sem_Ch13. We also test for it in |
| 1027 |
-- the body of this package (see Special_Msg_Delete). |
| 1028 |
-- Function Is_Size_Too_Small_Message tests for it by testing a prefix. |
| 1029 |
-- The function and constant should be kept in synch. |
| 1030 |
|
| 1031 |
end Errout; |