-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2004 Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
--- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
--- MA 02111-1307, USA. --
+-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
+-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- 5. If a message attempts to insert an Error node, or a direct
-- reference to the Any_Type node, then the message is suppressed.
+ -- 6. Note that cases 2-5 only apply to error messages, not warning
+ -- messages. Warning messages are only suppressed for case 1.
+
-- This normal suppression action may be overridden in cases 2-5 (but not
-- in case 1) by setting All_Errors mode, or by setting the special
-- unconditional message insertion character (!) at the end of the message
-- The character ! appearing as the last character of a message makes
-- the message unconditional which means that it is output even if it
-- would normally be suppressed. See section above for a description
- -- of the cases in which messages are normally suppressed.
+ -- of the cases in which messages are normally suppressed. Note that
+ -- warnings are never suppressed, so the use of the ! character in a
+ -- warning message is never useful.
+ --
+ -- Note: the presence of ! is ignored in continuation messages (i.e.
+ -- messages starting with the \ insertion character). The effect of the
+ -- use of ! in a parent message automatically applies to all of its
+ -- continuation messages (since we clearly don't want any case in which
+ -- continuations are separated from the parent message. It is allowable
+ -- to put ! in continuation messages, and the usual style is to include
+ -- it, since it makes it clear that the continuation is part of an
+ -- unconditional message.
-- Insertion character ? (Question: warning message)
-- The character ? appearing anywhere in a message makes the message
- -- a warning instead of a normal error message, and the text of the
- -- message will be preceded by "Warning:" instead of "Error:" The
- -- handling of warnings if further controlled by the Warning_Mode
- -- option (-w switch), see package Opt for further details, and also
- -- by the current setting from pragma Warnings. This pragma applies
- -- only to warnings issued from the semantic phase (not the parser),
- -- but currently all relevant warnings are posted by the semantic
- -- phase anyway. Messages starting with (style) are also treated as
- -- warning messages.
+ -- warning instead of a normal error message, and the text of the
+ -- message will be preceded by "Warning:" instead of "Error:" in the
+ -- normal case. The handling of warnings if further controlled by the
+ -- Warning_Mode option (-w switch), see package Opt for further
+ -- details, and also by the current setting from pragma Warnings. This
+ -- pragma applies only to warnings issued from the semantic phase (not
+ -- the parser), but currently all relevant warnings are posted by the
+ -- semantic phase anyway. Messages starting with (style) are also
+ -- treated as warning messages.
+ --
+ -- Note: the presence of ? is ignored in continuation messages (i.e.
+ -- messages starting with the \ insertion character). The warning
+ -- status of continuations is determined only by the parent message
+ -- which is being continued. It is allowable to put ? in continuation
+ -- messages, and the usual style is to include it, since it makes it
+ -- clear that the continuation is part of a warning message.
+
+ -- Insertion character < (Less Than: conditional warning message)
+ -- The character < appearing anywhere in a message is used for a
+ -- conditional error message. If Error_Msg_Warn is True, then the
+ -- effect is the same as ? described above. If Error_Msg_Warn is
+ -- False, then there is no effect.
-- Insertion character A-Z (Upper case letter: Ada reserved word)
-- If two or more upper case letters appear in the message, they are
-- Insertion character ` (Backquote: set manual quotation mode)
-- The backquote character always appears in pairs. Each backquote of
- -- the pair is replaced by a double quote character. In addition, Any
+ -- the pair is replaced by a double quote character. In addition, any
-- reserved keywords, or name insertions between these backquotes are
-- not surrounded by the usual automatic double quotes. See the
-- section below on manual quotation mode for further details.
-- messages are treated as a unit. The \ character must be the first
-- character of the message text.
- -- Insertion character | (vertical bar, non-serious error)
+ -- Insertion character \\ (Two backslashes, continuation with new line)
+ -- This differs from \ only in -gnatjnn mode (Error_Message_Line_Length
+ -- set non-zero). This sequence forces a new line to start even when
+ -- continuations are being gathered into a single message.
+
+ -- Insertion character | (Vertical bar: non-serious error)
-- By default, error messages (other than warning messages) are
-- considered to be fatal error messages which prevent expansion or
-- generation of code in the presence of the -gnatQ switch. If the
-- non-serious, and does not cause Serious_Errors_Detected to be
-- incremented (so expansion is not prevented by such a msg).
+ -- Insertion character ~ (Tilde: insert string)
+ -- Indicates that Error_Msg_String (1 .. Error_Msg_Strlen) is to be
+ -- inserted to replace the ~ character. The string is inserted in the
+ -- literal form it appears, without any action on special characters.
+
----------------------------------------
-- Specialization of Messages for VMS --
----------------------------------------
-- passed to the error message routine for insertion sequences described
-- above. The reason these are passed globally is that the insertion
-- mechanism is essentially an untyped one in which the appropriate
- -- variables are set dependingon the specific insertion characters used.
+ -- variables are set depending on the specific insertion characters used.
+
+ -- Note that is mandatory that the caller ensure that global variables
+ -- are set before the Error_Msg call, otherwise the result is undefined.
Error_Msg_Col : Column_Number renames Err_Vars.Error_Msg_Col;
-- Column for @ insertion character in message
-- note get reset by any Error_Msg call, so the caller is responsible
-- for resetting it.
+ Error_Msg_Warn : Boolean renames Err_Vars.Error_Msg_Warn;
+ -- Used if current message contains a < insertion character to indicate
+ -- if the current message is a warning message.
+
+ Error_Msg_String : String renames Err_Vars.Error_Msg_String;
+ Error_Msg_Strlen : Natural renames Err_Vars.Error_Msg_Strlen;
+ -- Used if current message contains a ~ insertion character to indicate
+ -- insertion of the string Error_Msg_String (1 .. Error_Msg_Strlen).
+
-----------------------------------------------------
-- Format of Messages and Manual Quotation Control --
-----------------------------------------------------
function Get_Location (E : Error_Msg_Id) return Source_Ptr
renames Erroutc.Get_Location;
- -- Returns the flag location of the error message with the given id E.
+ -- Returns the flag location of the error message with the given id E
------------------------
-- List Pragmas Table --
-- This routine is used for posting a message conditionally. The message
-- is posted (with the same effect as Error_Msg_N (Msg, N) if and only
-- if Eflag is True and if the node N is within the main extended source
- -- unit. Typically this is a warning mode flag.
+ -- unit and comes from source. Typically this is a warning mode flag.
procedure Change_Error_Text (Error_Id : Error_Msg_Id; New_Msg : String);
-- The error message text of the message identified by Id is replaced by
-- of its descendent nodes. No effect if no such warnings.
procedure Remove_Warning_Messages (L : List_Id);
- -- Remove warnings on all elements of a list.
+ -- Remove warnings on all elements of a list
procedure Set_Ignore_Errors (To : Boolean);
-- Following a call to this procedure with To=True, all error calls are
-- Called in response to a pragma Warnings (On) to record the source
-- location from which warnings are to be turned back on.
+ procedure Set_Specific_Warning_Off (Loc : Source_Ptr; Msg : String)
+ renames Erroutc.Set_Specific_Warning_Off;
+ -- This is called in response to the two argument form of pragma Warnings
+ -- where the first argument is OFF, and the second argument is the prefix
+ -- of a specific warning to be suppressed. The first argument is the start
+ -- of the suppression range, and the second argument is the string from
+ -- the pragma.
+
+ procedure Set_Specific_Warning_On
+ (Loc : Source_Ptr;
+ Msg : String;
+ Err : out Boolean)
+ renames Erroutc.Set_Specific_Warning_On;
+ -- This is called in response to the two argument form of pragma Warnings
+ -- where the first argument is ON, and the second argument is the prefix
+ -- of a specific warning to be suppressed. The first argument is the end
+ -- of the suppression range, and the second argument is the string from
+ -- the pragma. Err is set to True on return to report the error of no
+ -- matching Warnings Off pragma preceding this one.
+
function Compilation_Errors return Boolean
renames Erroutc.Compilation_Errors;
-- Returns true if errors have been detected, or warnings in -gnatwe