1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- This package contains variables common to error reporting packages
27 -- including Errout and Prj.Err.
29 with Namet
; use Namet
;
30 with Types
; use Types
;
31 with Uintp
; use Uintp
;
35 -- All of these variables are set when needed, so they do not need to be
36 -- initialized. However, there is code that saves and restores existing
37 -- values, which may malfunction in -gnatVa mode if the variable has never
38 -- been initialized, so we initialize some variables to avoid exceptions
39 -- from invalid values in such cases.
41 -- Note on error counts (Serious_Errors_Detected, Total_Errors_Detected,
42 -- Warnings_Detected, Info_Messages). These counts might more logically
43 -- appear in this unit, but we place them instead in atree.ads, because of
44 -- licensing issues. We need to be able to access these counts from units
45 -- that have the more general licensing conditions.
47 ----------------------------------
48 -- Error Message Mode Variables --
49 ----------------------------------
51 -- These variables control special error message modes. The initialized
52 -- values below give the normal default behavior, but they can be reset
53 -- by the caller to get different behavior as noted in the comments. These
54 -- variables are not reset by calls to the error message routines, so the
55 -- caller is responsible for resetting the default behavior after use.
57 Error_Msg_Qual_Level
: Int
:= 0;
58 -- Number of levels of qualification required for type name (see the
59 -- description of the } insertion character. Note that this value does
60 -- note get reset by any Error_Msg call, so the caller is responsible
63 Warn_On_Instance
: Boolean := False;
64 -- Normally if a warning is generated in a generic template from the
65 -- analysis of the template, then the warning really belongs in the
66 -- template, and the default value of False for this Boolean achieves
67 -- that effect. If Warn_On_Instance is set True, then the warnings are
68 -- generated on the instantiation (referring to the template) rather
69 -- than on the template itself.
71 Raise_Exception_On_Error
: Nat
:= 0;
72 -- If this value is non-zero, then any attempt to generate an error
73 -- message raises the exception Error_Msg_Exception, and the error
74 -- message is not output. This is used for defending against junk
75 -- resulting from illegalities, and also for substitution of more
76 -- appropriate error messages from higher semantic levels. It is
77 -- a counter so that the increment/decrement protocol nests neatly.
78 -- Initialized for -gnatVa use, see comment above.
80 Error_Msg_Exception
: exception;
81 -- Exception raised if Raise_Exception_On_Error is true
83 Current_Error_Source_File
: Source_File_Index
:= Internal_Source_File
;
84 -- Id of current messages. Used to post file name when unit changes. This
85 -- is initialized to Main_Source_File at the start of a compilation, which
86 -- means that no file names will be output unless there are errors in units
87 -- other than the main unit. However, if the main unit has a pragma
88 -- Source_Reference line, then this is initialized to No_Source_File,
89 -- to force an initial reference to the real source file name.
91 Warning_Doc_Switch
: Boolean := False;
92 -- If this is set True, then the ??/?x?/?x? sequences in error messages
93 -- are active (see errout.ads for details). If this switch is False, then
94 -- these sequences are ignored (i.e. simply equivalent to a single ?). The
95 -- -gnatw.d switch sets this flag True, -gnatw.D sets this flag False.
97 ----------------------------------------
98 -- Error Message Insertion Parameters --
99 ----------------------------------------
101 -- The error message routines work with strings that contain insertion
102 -- sequences that result in the insertion of variable data. The following
103 -- variables contain the required data. The procedure is to set one or more
104 -- of the following global variables to appropriate values before making a
105 -- call to one of the error message routines with a string containing the
106 -- insertion character to get the value inserted in an appropriate format.
108 Error_Msg_Col
: Column_Number
;
109 -- Column for @ insertion character in message
111 Error_Msg_Uint_1
: Uint
;
112 Error_Msg_Uint_2
: Uint
;
113 -- Uint values for ^ insertion characters in message
115 Error_Msg_Sloc
: Source_Ptr
;
116 -- Source location for # insertion character in message
118 Error_Msg_Name_1
: Name_Id
;
119 Error_Msg_Name_2
: Name_Id
;
120 Error_Msg_Name_3
: Name_Id
;
121 -- Name_Id values for % insertion characters in message
123 Error_Msg_File_1
: File_Name_Type
;
124 Error_Msg_File_2
: File_Name_Type
;
125 Error_Msg_File_3
: File_Name_Type
;
126 -- File_Name_Type values for { insertion characters in message
128 Error_Msg_Unit_1
: Unit_Name_Type
;
129 Error_Msg_Unit_2
: Unit_Name_Type
;
130 -- Unit_Name_Type values for $ insertion characters in message
132 Error_Msg_Node_1
: Node_Id
;
133 Error_Msg_Node_2
: Node_Id
;
134 -- Node_Id values for & insertion characters in message
136 Error_Msg_Warn
: Boolean;
137 -- Used if current message contains a < insertion character to indicate
138 -- if the current message is a warning message. Must be set appropriately
139 -- before any call to Error_Msg_xxx with a < insertion character present.
140 -- Setting is irrelevant if no < insertion character is present. Note
141 -- that it is not necessary to reset this after using it, since the proper
142 -- procedure is always to set it before issuing such a message. Note that
143 -- the warning documentation tag is always [enabled by default] in the
144 -- case where this flag is True.
146 Error_Msg_String
: String (1 .. 4096);
147 Error_Msg_Strlen
: Natural;
148 -- Used if current message contains a ~ insertion character to indicate
149 -- insertion of the string Error_Msg_String (1 .. Error_Msg_Strlen).