1------------------------------------------------------------------------------
2--                                                                          --
3--                         GNAT COMPILER COMPONENTS                         --
4--                                                                          --
5--                              E R R O U T C                               --
6--                                                                          --
7--                                 S p e c                                  --
8--                                                                          --
9--          Copyright (C) 1992-2020, 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 packages contains global variables and routines common to error
27--  reporting packages, including Errout and Prj.Err.
28
29with Table;
30with Types; use Types;
31
32package Erroutc is
33
34   Class_Flag : Boolean := False;
35   --  This flag is set True when outputting a reference to a class-wide
36   --  type, and is used by Add_Class to insert 'Class at the proper point
37
38   Continuation : Boolean := False;
39   --  Indicates if current message is a continuation. Initialized from the
40   --  Msg_Cont parameter in Error_Msg_Internal and then set True if a \
41   --  insertion character is encountered.
42
43   Continuation_New_Line : Boolean := False;
44   --  Indicates if current message was a continuation line marked with \\ to
45   --  force a new line. Set True if \\ encountered.
46
47   Flag_Source : Source_File_Index;
48   --  Source file index for source file where error is being posted
49
50   Has_Double_Exclam : Boolean := False;
51   --  Set true to indicate that the current message contains the insertion
52   --  sequence !! (force warnings even in non-main unit source files).
53
54   Has_Insertion_Line : Boolean := False;
55   --  Set True to indicate that the current message contains the insertion
56   --  character # (insert line number reference).
57
58   Is_Compile_Time_Msg : Boolean := False;
59   --  Set true to indicate that the current message originates from a
60   --  Compile_Time_Warning or Compile_Time_Error pragma.
61
62   Is_Serious_Error : Boolean := False;
63   --  Set True for a serious error (i.e. any message that is not a warning
64   --  or style message, and that does not contain a | insertion character).
65
66   Is_Unconditional_Msg : Boolean := False;
67   --  Set True to indicate that the current message contains the insertion
68   --  character ! and is thus to be treated as an unconditional message.
69
70   Is_Warning_Msg : Boolean := False;
71   --  Set True to indicate if current message is warning message (contains ?
72   --  or contains < and Error_Msg_Warn is True.
73
74   Is_Info_Msg : Boolean := False;
75   --  Set True to indicate that the current message starts with the characters
76   --  "info: " and is to be treated as an information message. This string
77   --  will be prepended to the message and all its continuations.
78
79   Is_Check_Msg : Boolean := False;
80   --  Set True to indicate that the current message starts with one of
81   --  "high: ", "medium: ", "low: " and is to be treated as a check message.
82
83   Warning_Msg_Char : Character;
84   --  Warning character, valid only if Is_Warning_Msg is True
85   --    ' '      -- ?   or <   appeared on its own in message
86   --    '?'      -- ??  or <<  appeared in message
87   --    'x'      -- ?x? or <x< appeared in message (x = a .. z)
88   --    'X'      -- ?X? or <X< appeared in message (X = A .. Z)
89   --    '*'      -- ?*? or <*< appeared in message
90   --    '$'      -- ?$? or <$< appeared in message
91   --  In the case of the < sequences, this is set only if the message is
92   --  actually a warning, i.e. if Error_Msg_Warn is True
93
94   Is_Style_Msg : Boolean := False;
95   --  Set True to indicate if the current message is a style message
96   --  (i.e. a message whose text starts with the characters "(style)").
97
98   Kill_Message : Boolean := False;
99   --  A flag used to kill weird messages (e.g. those containing uninterpreted
100   --  implicit type references) if we have already seen at least one message
101   --  already. The idea is that we hope the weird message is a junk cascaded
102   --  message that should be suppressed.
103
104   Last_Killed : Boolean := False;
105   --  Set True if the most recently posted non-continuation message was
106   --  killed. This is used to determine the processing of any continuation
107   --  messages that follow.
108
109   List_Pragmas_Index : Int := 0;
110   --  Index into List_Pragmas table
111
112   List_Pragmas_Mode : Boolean := False;
113   --  Starts True, gets set False by pragma List (Off), True by List (On)
114
115   Manual_Quote_Mode : Boolean := False;
116   --  Set True in manual quotation mode
117
118   Max_Msg_Length : constant := 1024 + 2 * Int (Column_Number'Last);
119   --  Maximum length of error message. The addition of 2 * Column_Number'Last
120   --  ensures that two insertion tokens of maximum length can be accommodated.
121   --  The value of 1024 is an arbitrary value that should be more than long
122   --  enough to accommodate any reasonable message (and for that matter, some
123   --  pretty unreasonable messages).
124
125   Msg_Buffer : String (1 .. Max_Msg_Length);
126   --  Buffer used to prepare error messages
127
128   Msglen : Integer := 0;
129   --  Number of characters currently stored in the message buffer
130
131   Suppress_Message : Boolean;
132   --  A flag used to suppress certain obviously redundant messages (i.e.
133   --  those referring to a node whose type is Any_Type). This suppression
134   --  is effective only if All_Errors_Mode is off.
135
136   Suppress_Instance_Location : Boolean := False;
137   --  Normally, if a # location in a message references a location within
138   --  a generic template, then a note is added giving the location of the
139   --  instantiation. If this variable is set True, then this note is not
140   --  output. This is used for internal processing for the case of an
141   --  illegal instantiation. See Error_Msg routine for further details.
142
143   type Subprogram_Name_Type is access function (N : Node_Id) return String;
144   Subprogram_Name_Ptr : Subprogram_Name_Type;
145   --  Indirect call to Sem_Util.Subprogram_Name to break circular
146   --  dependency with the static elaboration model.
147
148   ----------------------------
149   -- Message ID Definitions --
150   ----------------------------
151
152   type Error_Msg_Id is new Int;
153   --  A type used to represent specific error messages. Used by the clients
154   --  of this package only in the context of the Get_Error_Id and
155   --  Change_Error_Text subprograms.
156
157   No_Error_Msg : constant Error_Msg_Id := 0;
158   --  A constant which is different from any value returned by Get_Error_Id.
159   --  Typically used by a client to indicate absence of a saved Id value.
160
161   Cur_Msg : Error_Msg_Id := No_Error_Msg;
162   --  Id of most recently posted error message
163
164   function Get_Msg_Id return Error_Msg_Id;
165   --  Returns the Id of the message most recently posted using one of the
166   --  Error_Msg routines.
167
168   function Get_Location (E : Error_Msg_Id) return Source_Ptr;
169   --  Returns the flag location of the error message with the given id E
170
171   -----------------------------------
172   -- Error Message Data Structures --
173   -----------------------------------
174
175   --  The error messages are stored as a linked list of error message objects
176   --  sorted into ascending order by the source location (Sloc). Each object
177   --  records the text of the message and its source location.
178
179   --  The following record type and table are used to represent error
180   --  messages, with one entry in the table being allocated for each message.
181
182   type Error_Msg_Object is record
183      Text : String_Ptr;
184      --  Text of error message, fully expanded with all insertions
185
186      Next : Error_Msg_Id;
187      --  Pointer to next message in error chain. A value of No_Error_Msg
188      --  indicates the end of the chain.
189
190      Prev : Error_Msg_Id;
191      --  Pointer to previous message in error chain. Only set during the
192      --  Finalize procedure. A value of No_Error_Msg indicates the first
193      --  message in the chain.
194
195      Sfile : Source_File_Index;
196      --  Source table index of source file. In the case of an error that
197      --  refers to a template, always references the original template
198      --  not an instantiation copy.
199
200      Sptr : Source_Ptr;
201      --  Flag pointer. In the case of an error that refers to a template,
202      --  always references the original template, not an instantiation copy.
203      --  This value is the actual place in the source that the error message
204      --  will be posted. Note that an error placed on an instantiation will
205      --  have Sptr pointing to the instantiation point.
206
207      Optr : Source_Ptr;
208      --  Flag location used in the call to post the error. This is the same as
209      --  Sptr, except when an error is posted on a particular instantiation of
210      --  a generic. In such a case, Sptr will point to the original source
211      --  location of the instantiation itself, but Optr will point to the
212      --  template location (more accurately to the template copy in the
213      --  instantiation copy corresponding to the instantiation referenced by
214      --  Sptr).
215
216      Insertion_Sloc : Source_Ptr;
217      --  Location in message for insertion character # when used
218
219      Line : Physical_Line_Number;
220      --  Line number for error message
221
222      Col : Column_Number;
223      --  Column number for error message
224
225      Compile_Time_Pragma : Boolean;
226      --  True if the message originates from a Compile_Time_Warning or
227      --  Compile_Time_Error pragma
228
229      Warn : Boolean;
230      --  True if warning message
231
232      Info : Boolean;
233      --  True if info message
234
235      Check : Boolean;
236      --  True if check message
237
238      Warn_Err : Boolean;
239      --  True if this is a warning message which is to be treated as an error
240      --  as a result of a match with a Warning_As_Error pragma.
241
242      Warn_Chr : Character;
243      --  Warning character (note: set even if Warning_Doc_Switch is False)
244      --    ' '      -- ?   or <   appeared on its own in message
245      --    '?'      -- ??  or <<  appeared in message
246      --    'x'      -- ?x? or <x< appeared in message (x = a .. z)
247      --    'X'      -- ?X? or <X< appeared in message (X = A .. Z)
248      --    '*'      -- ?*? or <*< appeared in message
249      --    '$'      -- ?$? or <$< appeared in message
250      --  In the case of the < sequences, this is set only if the message is
251      --  actually a warning, i.e. if Error_Msg_Warn is True
252
253      Style : Boolean;
254      --  True if style message (starts with "(style)")
255
256      Serious : Boolean;
257      --  True if serious error message (not a warning and no | character)
258
259      Uncond : Boolean;
260      --  True if unconditional message (i.e. insertion character ! appeared)
261
262      Msg_Cont : Boolean;
263      --  This is used for logical messages that are composed of multiple
264      --  individual messages. For messages that are not part of such a
265      --  group, or that are the first message in such a group. Msg_Cont
266      --  is set to False. For subsequent messages in a group, Msg_Cont
267      --  is set to True. This is used to make sure that such a group of
268      --  messages is either suppressed or retained as a group (e.g. in
269      --  the circuit that deletes identical messages).
270
271      Deleted : Boolean;
272      --  If this flag is set, the message is not printed. This is used
273      --  in the circuit for deleting duplicate/redundant error messages.
274
275      Node : Node_Id;
276      --  If set, points to the node relevant for this message which will be
277      --  used to compute the enclosing subprogram name if
278      --  Opt.Include_Subprogram_In_Messages is set.
279   end record;
280
281   package Errors is new Table.Table (
282     Table_Component_Type => Error_Msg_Object,
283     Table_Index_Type     => Error_Msg_Id,
284     Table_Low_Bound      => 1,
285     Table_Initial        => 200,
286     Table_Increment      => 200,
287     Table_Name           => "Error");
288
289   First_Error_Msg : Error_Msg_Id;
290   --  The list of error messages, i.e. the first entry on the list of error
291   --  messages. This is not the same as the physically first entry in the
292   --  error message table, since messages are not always inserted in sequence.
293
294   Last_Error_Msg : Error_Msg_Id;
295   --  The last entry on the list of error messages. Note: this is not the same
296   --  as the physically last entry in the error message table, since messages
297   --  are not always inserted in sequence.
298
299   --------------------------
300   -- Warning Mode Control --
301   --------------------------
302
303   --  Pragma Warnings allows warnings to be turned off for a specified region
304   --  of code, and the following tables are the data structures used to keep
305   --  track of these regions.
306
307   --  The first table is used for the basic command line control, and for the
308   --  forms of Warning with a single ON or OFF parameter.
309
310   --  It contains pairs of source locations, the first being the start
311   --  location for a warnings off region, and the second being the end
312   --  location. When a pragma Warnings (Off) is encountered, a new entry is
313   --  established extending from the location of the pragma to the end of the
314   --  current source file. A subsequent pragma Warnings (On) adjusts the end
315   --  point of this entry appropriately.
316
317   --  If all warnings are suppressed by command switch, then there is a dummy
318   --  entry (put there by Errout.Initialize) at the start of the table which
319   --  covers all possible Source_Ptr values. Note that the source pointer
320   --  values in this table always reference the original template, not an
321   --  instantiation copy, in the generic case.
322
323   --  Reason is the reason from the pragma Warnings (Off,..) or the null
324   --  string if no reason parameter is given.
325
326   type Warnings_Entry is record
327      Start  : Source_Ptr;
328      Stop   : Source_Ptr;
329      Reason : String_Id;
330   end record;
331
332   package Warnings is new Table.Table (
333     Table_Component_Type => Warnings_Entry,
334     Table_Index_Type     => Natural,
335     Table_Low_Bound      => 1,
336     Table_Initial        => 100,
337     Table_Increment      => 200,
338     Table_Name           => "Warnings");
339
340   --  The second table is used for the specific forms of the pragma, where
341   --  the first argument is ON or OFF, and the second parameter is a string
342   --  which is the pattern to match for suppressing a warning.
343
344   type Specific_Warning_Entry is record
345      Start : Source_Ptr;
346      Stop  : Source_Ptr;
347      --  Starting and ending source pointers for the range. These are always
348      --  from the same source file.
349
350      Reason : String_Id;
351      --  Reason string from pragma Warnings, or null string if none
352
353      Msg : String_Ptr;
354      --  Message from pragma Warnings (Off, string)
355
356      Open : Boolean;
357      --  Set to True if OFF has been encountered with no matching ON
358
359      Used : Boolean;
360      --  Set to True if entry has been used to suppress a warning
361
362      Config : Boolean;
363      --  True if pragma is configuration pragma (in which case no matching Off
364      --  pragma is required, and it is not required that a specific warning be
365      --  suppressed).
366   end record;
367
368   package Specific_Warnings is new Table.Table (
369     Table_Component_Type => Specific_Warning_Entry,
370     Table_Index_Type     => Natural,
371     Table_Low_Bound      => 1,
372     Table_Initial        => 100,
373     Table_Increment      => 200,
374     Table_Name           => "Specific_Warnings");
375
376   --  Note on handling configuration case versus specific case. A complication
377   --  arises from this example:
378
379   --     pragma Warnings (Off, "not referenced*");
380   --     procedure Mumble (X : Integer) is
381   --     pragma Warnings (On, "not referenced*");
382   --     begin
383   --        null;
384   --     end Mumble;
385
386   --  The trouble is that the first pragma is technically a configuration
387   --  pragma, and yet it is clearly being used in the context of thinking of
388   --  it as a specific case. To deal with this, what we do is that the On
389   --  entry can match a configuration pragma from the same file, and if we
390   --  find such an On entry, we cancel the indication of it being the
391   --  configuration case. This seems to handle all cases we run into ok.
392
393   -----------------
394   -- Subprograms --
395   -----------------
396
397   procedure Add_Class;
398   --  Add 'Class to buffer for class wide type case (Class_Flag set)
399
400   function Buffer_Ends_With (C : Character) return Boolean;
401   --  Tests if message buffer ends with given character
402
403   function Buffer_Ends_With (S : String) return Boolean;
404   --  Tests if message buffer ends with given string preceded by a space
405
406   procedure Buffer_Remove (C : Character);
407   --  Remove given character fron end of buffer if it is present
408
409   procedure Buffer_Remove (S : String);
410   --  Removes given string from end of buffer if it is present at end of
411   --  buffer, and preceded by a space.
412
413   function Compilation_Errors return Boolean;
414   --  Returns true if errors have been detected, or warnings in -gnatwe
415   --  (treat warnings as errors) mode.
416
417   procedure dmsg (Id : Error_Msg_Id);
418   --  Debugging routine to dump an error message
419
420   procedure Debug_Output (N : Node_Id);
421   --  Called from Error_Msg_N and Error_Msg_NE to generate line of debug
422   --  output giving node number (of node N) if the debug X switch is set.
423
424   procedure Check_Duplicate_Message (M1, M2 : Error_Msg_Id);
425   --  This function is passed the Id values of two error messages. If either
426   --  M1 or M2 is a continuation message, or is already deleted, the call is
427   --  ignored. Otherwise a check is made to see if M1 and M2 are duplicated or
428   --  redundant. If so, the message to be deleted and all its continuations
429   --  are marked with the Deleted flag set to True.
430
431   function Count_Compile_Time_Pragma_Warnings return Int;
432   --  Returns the number of warnings in the Errors table that were triggered
433   --  by a Compile_Time_Warning pragma.
434
435   function Get_Warning_Tag (Id : Error_Msg_Id) return String;
436   --  Given an error message ID, return tag showing warning message class, or
437   --  the null string if this option is not enabled or this is not a warning.
438
439   procedure Output_Error_Msgs (E : in out Error_Msg_Id);
440   --  Output source line, error flag, and text of stored error message and all
441   --  subsequent messages for the same line and unit. On return E is set to be
442   --  one higher than the last message output.
443
444   procedure Output_Line_Number (L : Logical_Line_Number);
445   --  Output a line number as six digits (with leading zeroes suppressed),
446   --  followed by a period and a blank (note that this is 8 characters which
447   --  means that tabs in the source line will not get messed up). Line numbers
448   --  that match or are less than the last Source_Reference pragma are listed
449   --  as all blanks, avoiding output of junk line numbers.
450
451   procedure Output_Msg_Text (E : Error_Msg_Id);
452   --  Outputs characters of text in the text of the error message E. Note that
453   --  no end of line is output, the caller is responsible for adding the end
454   --  of line. If Error_Msg_Line_Length is non-zero, this is the routine that
455   --  splits the line generating multiple lines of output, and in this case
456   --  the last line has no terminating end of line character.
457
458   procedure Prescan_Message (Msg : String);
459   --  Scans message text and sets the following variables:
460   --
461   --    Is_Warning_Msg is set True if Msg is a warning message (contains a
462   --    question mark character), and False otherwise.
463   --
464   --    Is_Style_Msg is set True if Msg is a style message (starts with
465   --    "(style)") and False otherwise.
466   --
467   --    Is_Info_Msg is set True if Msg is an information message (starts
468   --    with "info: ". Such messages must contain a ? sequence since they
469   --    are also considered to be warning messages, and get a tag.
470   --
471   --    Is_Serious_Error is set to True unless the message is a warning or
472   --    style message or contains the character | (non-serious error).
473   --
474   --    Is_Unconditional_Msg is set True if the message contains the character
475   --    ! and is otherwise set False.
476   --
477   --    Has_Double_Exclam is set True if the message contains the sequence !!
478   --    and is otherwise set False.
479   --
480   --    Has_Insertion_Line is set True if the message contains the character #
481   --    and is otherwise set False.
482   --
483   --  We need to know right away these aspects of a message, since we will
484   --  test these values before doing the full error scan.
485   --
486   --  Note that the call has no effect for continuation messages (those whose
487   --  first character is '\'), and all variables are left unchanged, unless
488   --  -gnatdF is set.
489
490   procedure Purge_Messages (From : Source_Ptr; To : Source_Ptr);
491   --  All error messages whose location is in the range From .. To (not
492   --  including the end points) will be deleted from the error listing.
493
494   function Same_Error (M1, M2 : Error_Msg_Id) return Boolean;
495   --  See if two messages have the same text. Returns true if the text of the
496   --  two messages is identical, or if one of them is the same as the other
497   --  with an appended "instance at xxx" tag.
498
499   procedure Set_Msg_Blank;
500   --  Sets a single blank in the message if the preceding character is a
501   --  non-blank character other than a left parenthesis or minus. Has no
502   --  effect if manual quote mode is turned on.
503
504   procedure Set_Msg_Blank_Conditional;
505   --  Sets a single blank in the message if the preceding character is a
506   --  non-blank character other than a left parenthesis or quote. Has no
507   --  effect if manual quote mode is turned on.
508
509   procedure Set_Msg_Char (C : Character);
510   --  Add a single character to the current message. This routine does not
511   --  check for special insertion characters (they are just treated as text
512   --  characters if they occur).
513
514   procedure Set_Msg_Insertion_File_Name;
515   --  Handle file name insertion (left brace insertion character)
516
517   procedure Set_Msg_Insertion_Line_Number (Loc, Flag : Source_Ptr);
518   --  Handle line number insertion (# insertion character). Loc is the
519   --  location to be referenced, and Flag is the location at which the
520   --  flag is posted (used to determine whether to add "in file xxx")
521
522   procedure Set_Msg_Insertion_Name_Literal;
523
524   procedure Set_Msg_Insertion_Name;
525   --  Handle name insertion (% insertion character)
526
527   procedure Set_Msg_Insertion_Reserved_Name;
528   --  Handle insertion of reserved word name (* insertion character)
529
530   procedure Set_Msg_Insertion_Reserved_Word
531     (Text : String;
532      J    : in out Integer);
533   --  Handle reserved word insertion (upper case letters). The Text argument
534   --  is the current error message input text, and J is an index which on
535   --  entry points to the first character of the reserved word, and on exit
536   --  points past the last character of the reserved word. Note that RM and
537   --  SPARK are treated specially and not considered to be keywords.
538
539   procedure Set_Msg_Insertion_Run_Time_Name;
540   --  If package System contains a definition for Run_Time_Name (see package
541   --  Targparm for details), then this procedure will insert a message of
542   --  the form (name) into the current error message, with name set in mixed
543   --  case (upper case after any spaces). If no run time name is defined,
544   --  then this routine has no effect).
545
546   procedure Set_Msg_Insertion_Uint;
547   --  Handle Uint insertion (^ insertion character)
548
549   procedure Set_Msg_Int (Line : Int);
550   --  Set the decimal representation of the argument in the error message
551   --  buffer with no leading zeroes output.
552
553   procedure Set_Msg_Name_Buffer;
554   --  Output name from Name_Buffer, with surrounding quotes unless manual
555   --  quotation mode is in effect.
556
557   procedure Set_Msg_Quote;
558   --  Set quote if in normal quote mode, nothing if in manual quote mode
559
560   procedure Set_Msg_Str (Text : String);
561   --  Add a sequence of characters to the current message. This routine does
562   --  not check for special insertion characters (they are just treated as
563   --  text characters if they occur). It does perform the transformation of
564   --  the special strings _xxx (xxx = Pre/Post/Type_Invariant) to xxx'Class.
565
566   procedure Set_Next_Non_Deleted_Msg (E : in out Error_Msg_Id);
567   --  Given a message id, move to next message id, but skip any deleted
568   --  messages, so that this results in E on output being the first non-
569   --  deleted message following the input value of E, or No_Error_Msg if
570   --  the input value of E was either already No_Error_Msg, or was the
571   --  last non-deleted message.
572
573   procedure Set_Specific_Warning_Off
574     (Loc    : Source_Ptr;
575      Msg    : String;
576      Reason : String_Id;
577      Config : Boolean;
578      Used   : Boolean := False);
579   --  This is called in response to the two argument form of pragma Warnings
580   --  where the first argument is OFF, and the second argument is a string
581   --  which identifies a specific warning to be suppressed. The first argument
582   --  is the start of the suppression range, and the second argument is the
583   --  string from the pragma. Loc is the location of the pragma (which is the
584   --  start of the range to suppress). Reason is the reason string from the
585   --  pragma, or the null string if no reason is given. Config is True for the
586   --  configuration pragma case (where there is no requirement for a matching
587   --  OFF pragma). Used is set True to disable the check that the warning
588   --  actually has the effect of suppressing a warning.
589
590   procedure Set_Specific_Warning_On
591     (Loc : Source_Ptr;
592      Msg : String;
593      Err : out Boolean);
594   --  This is called in response to the two argument form of pragma Warnings
595   --  where the first argument is ON, and the second argument is a string
596   --  which identifies a specific warning to be suppressed. The first argument
597   --  is the end of the suppression range, and the second argument is the
598   --  string from the pragma. Err is set to True on return to report the error
599   --  of no matching Warnings Off pragma preceding this one.
600
601   procedure Set_Warnings_Mode_Off (Loc : Source_Ptr; Reason : String_Id);
602   --  Called in response to a pragma Warnings (Off) to record the source
603   --  location from which warnings are to be turned off. Reason is the
604   --  Reason from the pragma, or the null string if none is given.
605
606   procedure Set_Warnings_Mode_On (Loc : Source_Ptr);
607   --  Called in response to a pragma Warnings (On) to record the source
608   --  location from which warnings are to be turned back on.
609
610   function Warnings_Suppressed (Loc : Source_Ptr) return String_Id;
611   --  Determines if given location is covered by a warnings off suppression
612   --  range in the warnings table (or is suppressed by compilation option,
613   --  which generates a warning range for the whole source file). This routine
614   --  only deals with the general ON/OFF case, not specific warnings. The
615   --  returned result is No_String if warnings are not suppressed. If warnings
616   --  are suppressed for the given location, then corresponding Reason
617   --  parameter from the pragma is returned (or the null string if no Reason
618   --  parameter was present).
619
620   function Warning_Specifically_Suppressed
621     (Loc : Source_Ptr;
622      Msg : String_Ptr;
623      Tag : String := "") return String_Id;
624   --  Determines if given message to be posted at given location is suppressed
625   --  by specific ON/OFF Warnings pragmas specifying this particular message.
626   --  If the warning is not suppressed then No_String is returned, otherwise
627   --  the corresponding warning string is returned (or the null string if no
628   --  Warning argument was present in the pragma). Tag is the error message
629   --  tag for the message in question or the null string if there is no tag.
630   --
631   --  Note: we have a null default for Tag to deal with calls from an old
632   --  branch of gnat2why, which does not know about tags in the calls but
633   --  which uses the latest version of erroutc.
634
635   function Warning_Treated_As_Error (Msg : String) return Boolean;
636   --  Returns True if the warning message Msg matches any of the strings
637   --  given by Warning_As_Error pragmas, as stored in the Warnings_As_Errors
638   --  table.
639
640   type Error_Msg_Proc is
641     access procedure (Msg : String; Flag_Location : Source_Ptr);
642   procedure Validate_Specific_Warnings (Eproc : Error_Msg_Proc);
643   --  Checks that specific warnings are consistent (for non-configuration
644   --  case, properly closed, and used). The argument is a pointer to the
645   --  Error_Msg procedure to be called if any inconsistencies are detected.
646
647end Erroutc;
648