]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/ada/errutil.ads
trans-array.c (gfc_conv_descriptor_data_get): Rename from gfc_conv_descriptor_data.
[thirdparty/gcc.git] / gcc / ada / errutil.ads
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- E R R U T I L --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2002 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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 ------------------------------------------------------------------------------
26
27 -- This package contains routines to output error messages and the
28 -- corresponding instantiation of Styleg, suitable to instantiate Scng.
29
30 -- It is not dependent on the GNAT tree packages (Atree, Sinfo, ...).
31
32 -- It uses the same global variables as Errout, located in package
33 -- Err_Vars. Like Errout, it also uses the common variables and routines
34 -- in package Erroutc.
35
36 -- This package is used by the preprocessor (gprep.adb) and the project
37 -- manager (prj-err.ads).
38
39 with Styleg;
40 with Types; use Types;
41
42 package Errutil is
43
44 ---------------------------------------------------------
45 -- Error Message Text and Message Insertion Characters --
46 ---------------------------------------------------------
47
48 -- Error message text strings are composed of lower case letters, digits
49 -- and the special characters space, comma, period, colon and semicolon,
50 -- apostrophe and parentheses. Special insertion characters can also
51 -- appear which cause the error message circuit to modify the given
52 -- string as follows:
53
54 -- Ignored insertion characters: the following characters, used as
55 -- insertion characters by Errout are ignored: '$', '&', and '}'.
56 -- If present in an error message, they are not output and are not
57 -- replaced by any text.
58
59 -- Insertion character % (Percent: insert name from Names table)
60 -- The character % is replaced by the text for the name specified by
61 -- the Name_Id value stored in Error_Msg_Name_1. A blank precedes
62 -- the name if it is preceded by a non-blank character other than a
63 -- left parenthesis. The name is enclosed in quotes unless manual
64 -- quotation mode is set. If the Name_Id is set to No_Name, then
65 -- no insertion occurs; if the Name_Id is set to Error_Name, then
66 -- the string <error> is inserted. A second and third % may appear
67 -- in a single message, similarly replaced by the names which are
68 -- specified by the Name_Id values stored in Error_Msg_Name_2 and
69 -- Error_Msg_Name_3. The names are decoded and cased according to
70 -- the current identifier casing mode.
71
72 -- Insertion character { (Left brace: insert literally from names table)
73 -- The character { is treated similarly to %, except that the
74 -- name is output literally as stored in the names table without
75 -- adjusting the casing. This can be used for file names and in
76 -- other situations where the name string is to be output unchanged.
77
78 -- Insertion character * (Asterisk, insert reserved word name)
79 -- The insertion character * is treated exactly like % except that
80 -- the resulting name is cased according to the default conventions
81 -- for reserved words (see package Scans).
82
83 -- Insertion character # (Pound: insert line number reference)
84 -- The character # is replaced by the string indicating the source
85 -- position stored in Error_Msg_Sloc. There are two cases:
86 --
87 -- for locations in current file: at line nnn:ccc
88 -- for locations in other files: at filename:nnn:ccc
89 --
90 -- By convention, the # insertion character is only used at the end
91 -- of an error message, so the above strings only appear as the last
92 -- characters of an error message.
93
94 -- Insertion character @ (At: insert column number reference)
95 -- The character @ is replaced by null if the RM_Column_Check mode is
96 -- off (False). If the switch is on (True), then @ is replaced by the
97 -- text string " in column nnn" where nnn is the decimal representation
98 -- of the column number stored in Error_Msg_Col plus one (the plus one
99 -- is because the number is stored 0-origin and displayed 1-origin).
100
101 -- Insertion character ^ (Carret: insert integer value)
102 -- The character ^ is replaced by the decimal conversion of the Uint
103 -- value stored in Error_Msg_Uint_1, with a possible leading minus.
104 -- A second ^ may occur in the message, in which case it is replaced
105 -- by the decimal conversion of the Uint value in Error_Msg_Uint_2.
106
107 -- Insertion character ! (Exclamation: unconditional message)
108 -- The character ! appearing as the last character of a message makes
109 -- the message unconditional which means that it is output even if it
110 -- would normally be suppressed.
111
112 -- Insertion character ? (Question: warning message)
113 -- The character ? appearing anywhere in a message makes the message
114 -- a warning instead of a normal error message, and the text of the
115 -- message will be preceded by "Warning:" instead of "Error:" The
116 -- handling of warnings if further controlled by the Warning_Mode
117 -- option (-w switch), see package Opt for further details, and
118 -- also by the current setting from pragma Warnings. This pragma
119 -- applies only to warnings issued from the semantic phase (not
120 -- the parser), but currently all relevant warnings are posted
121 -- by the semantic phase anyway. Messages starting with (style)
122 -- are also treated as warning messages.
123
124 -- Insertion character A-Z (Upper case letter: Ada reserved word)
125 -- If two or more upper case letters appear in the message, they are
126 -- taken as an Ada reserved word, and are converted to the default
127 -- case for reserved words (see Scans package spec). Surrounding
128 -- quotes are added unless manual quotation mode is currently set.
129
130 -- Insertion character ` (Backquote: set manual quotation mode)
131 -- The backquote character always appears in pairs. Each backquote
132 -- of the pair is replaced by a double quote character. In addition,
133 -- Any reserved keywords, or name insertions between these backquotes
134 -- are not surrounded by the usual automatic double quotes. See the
135 -- section below on manual quotation mode for further details.
136
137 -- Insertion character ' (Quote: literal character)
138 -- Precedes a character which is placed literally into the message.
139 -- Used to insert characters into messages that are one of the
140 -- insertion characters defined here.
141
142 -- Insertion character \ (Backslash: continuation message)
143 -- Indicates that the message is a continuation of a message
144 -- previously posted. This is used to ensure that such groups
145 -- of messages are treated as a unit. The \ character must be
146 -- the first character of the message text.
147
148 -----------------------------------------------------
149 -- Format of Messages and Manual Quotation Control --
150 -----------------------------------------------------
151
152 -- Messages are generally all in lower case, except for inserted names
153 -- and appear in one of the following two forms:
154
155 -- error: text
156 -- warning: text
157
158 -- The prefixes error and warning are supplied automatically (depending
159 -- on the use of the ? insertion character), and the call to the error
160 -- message routine supplies the text. The "error: " prefix is omitted
161 -- in brief error message formats.
162
163 -- Reserved keywords in the message are in the default keyword case
164 -- (determined from the given source program), surrounded by quotation
165 -- marks. This is achieved by spelling the reserved word in upper case
166 -- letters, which is recognized as a request for insertion of quotation
167 -- marks by the error text processor. Thus for example:
168
169 -- Error_Msg_AP ("IS expected");
170
171 -- would result in the output of one of the following:
172
173 -- error: "is" expected
174 -- error: "IS" expected
175 -- error: "Is" expected
176
177 -- the choice between these being made by looking at the casing convention
178 -- used for keywords (actually the first compilation unit keyword) in the
179 -- source file.
180
181 -- In the case of names, the default mode for the error text processor
182 -- is to surround the name by quotation marks automatically. The case
183 -- used for the identifier names is taken from the source program where
184 -- possible, and otherwise is the default casing convention taken from
185 -- the source file usage.
186
187 -- In some cases, better control over the placement of quote marks is
188 -- required. This is achieved using manual quotation mode. In this mode,
189 -- one or more insertion sequences is surrounded by backquote characters.
190 -- The backquote characters are output as double quote marks, and normal
191 -- automatic insertion of quotes is suppressed between the double quotes.
192 -- For example:
193
194 -- Error_Msg_AP ("`END &;` expected");
195
196 -- generates a message like
197
198 -- error: "end Open_Scope;" expected
199
200 -- where the node specifying the name Open_Scope has been stored in
201 -- Error_Msg_Node_1 prior to the call. The great majority of error
202 -- messages operates in normal quotation mode.
203
204 -- Note: the normal automatic insertion of spaces before insertion
205 -- sequences (such as those that come from & and %) is suppressed in
206 -- manual quotation mode, so blanks, if needed as in the above example,
207 -- must be explicitly present.
208
209 ------------------------------
210 -- Error Output Subprograms --
211 ------------------------------
212
213 procedure Initialize;
214 -- Initializes for output of error messages. Must be called for each
215 -- file before using any of the other routines in the package.
216
217 procedure Finalize (Source_Type : String := "project");
218 -- Finalize processing of error messages for one file and output message
219 -- indicating the number of detected errors.
220 -- Source_Type is used in verbose mode to indicate the type of the source
221 -- being parsed (project file, definition file or input file for the
222 -- preprocessor).
223
224 procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr);
225 -- Output a message at specified location.
226
227 procedure Error_Msg_S (Msg : String);
228 -- Output a message at current scan pointer location.
229
230 procedure Error_Msg_SC (Msg : String);
231 -- Output a message at the start of the current token, unless we are at
232 -- the end of file, in which case we always output the message after the
233 -- last real token in the file.
234
235 procedure Error_Msg_SP (Msg : String);
236 -- Output a message at the start of the previous token.
237
238 procedure Set_Ignore_Errors (To : Boolean);
239 -- Indicate, when To = True, that all reported errors should
240 -- be ignored. By default reported errors are not ignored.
241
242 package Style is new Styleg
243 (Error_Msg => Error_Msg,
244 Error_Msg_S => Error_Msg_S,
245 Error_Msg_SC => Error_Msg_SC,
246 Error_Msg_SP => Error_Msg_SP);
247 -- Instantiation of the generic style package, suitable for an
248 -- instantiation of Scng.
249
250 end Errutil;