]> git.sur5r.net Git - cc65/blob - src/ca65/error.h
Add gcc attributes, fixed a format string problem
[cc65] / src / ca65 / error.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                  error.h                                  */
4 /*                                                                           */
5 /*                Error handling for the ca65 macroassembler                 */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2003 Ullrich von Bassewitz                                       */
10 /*               Römerstrasse 52                                             */
11 /*               D-70794 Filderstadt                                         */
12 /* EMail:        uz@cc65.org                                                 */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef ERROR_H
37 #define ERROR_H
38
39
40
41 /* common */
42 #include "attrib.h"
43 #include "filepos.h"
44
45
46
47 /*****************************************************************************/
48 /*                                   Data                                    */
49 /*****************************************************************************/
50
51
52
53 /* Warning numbers */
54 enum Warnings {
55     WARN_NONE,                          /* No warning */
56     WARN_SYM_NOT_REFERENCED,
57     WARN_IMPORT_NOT_REFERENCED,
58     WARN_CANNOT_TRACK_STATUS,
59     WARN_SUSPICIOUS_ADDREXPR,
60     WARN_USER,
61     WARN_COUNT                          /* Warning count */
62 };
63
64 /* Error numbers */
65 enum Errors {
66     ERR_NONE,                           /* No error */
67     ERR_NOT_IMPLEMENTED,                /* Command/operation not implemented */
68     ERR_CANNOT_OPEN_INCLUDE,
69     ERR_CANNOT_READ_INCLUDE,
70     ERR_INCLUDE_NESTING,
71     ERR_INVALID_CHAR,
72     ERR_HEX_DIGIT_EXPECTED,
73     ERR_DIGIT_EXPECTED,
74     ERR_01_EXPECTED,
75     ERR_NUM_OVERFLOW,
76     ERR_PSEUDO_EXPECTED,
77     ERR_TOO_MANY_CHARS,
78     ERR_COLON_EXPECTED,
79     ERR_LPAREN_EXPECTED,
80     ERR_RPAREN_EXPECTED,
81     ERR_RBRACK_EXPECTED,
82     ERR_COMMA_EXPECTED,
83     ERR_ONOFF_EXPECTED,
84     ERR_Y_EXPECTED,
85     ERR_X_EXPECTED,
86     ERR_INTCON_EXPECTED,
87     ERR_STRCON_EXPECTED,
88     ERR_CHARCON_EXPECTED,
89     ERR_CONSTEXPR_EXPECTED,
90     ERR_IDENT_EXPECTED,
91     ERR_ENDMACRO_EXPECTED,
92     ERR_OPTION_KEY_EXPECTED,
93     ERR_EQ_EXPECTED,
94     ERR_816_MODE_ONLY,
95     ERR_USER,
96     ERR_STRING_TOO_LONG,
97     ERR_NEWLINE_IN_STRING,
98     ERR_ILLEGAL_CHARCON,
99     ERR_ILLEGAL_ADDR_MODE,
100     ERR_ILLEGAL_LOCALSTART,
101     ERR_ILLEGAL_LOCAL_USE,
102     ERR_ILLEGAL_SEGMENT,
103     ERR_ILLEGAL_SEG_ATTR,
104     ERR_ILLEGAL_MACPACK,
105     ERR_ILLEGAL_FEATURE,
106     ERR_ILLEGAL_SCOPE,
107     ERR_ILLEGAL_ASSERT_ACTION,
108     ERR_SYNTAX,
109     ERR_SYM_ALREADY_DEFINED,
110     ERR_SYM_UNDEFINED,
111     ERR_SYM_ALREADY_IMPORT,
112     ERR_SYM_ALREADY_EXPORT,
113     ERR_EXPORT_UNDEFINED,
114     ERR_EXPORT_MUST_BE_CONST,
115     ERR_UNEXPECTED_EOF,
116     ERR_UNEXPECTED_EOL,
117     ERR_UNEXPECTED,
118     ERR_DIV_BY_ZERO,
119     ERR_MOD_BY_ZERO,
120     ERR_RANGE,
121     ERR_TOO_MANY_PARAMS,
122     ERR_MACRO_PARAM_EXPECTED,
123     ERR_CIRCULAR_REFERENCE,
124     ERR_SYM_REDECL_MISMATCH,
125     ERR_ALIGN,
126     ERR_DUPLICATE_ELSE,
127     ERR_OPEN_IF,
128     ERR_OPEN_PROC,
129     ERR_NO_OPEN_PROC,
130     ERR_SEG_ATTR_MISMATCH,
131     ERR_SEGSTACK_OVERFLOW,
132     ERR_SEGSTACK_EMPTY,
133     ERR_SEGSTACK_NOT_EMPTY,
134     ERR_CPU_NOT_SUPPORTED,
135     ERR_COUNTER_UNDERFLOW,
136     ERR_UNDEFINED_LABEL,
137     ERR_OPEN_STMT,
138     ERR_FILENAME_NOT_FOUND,
139     ERR_COUNT                           /* Error count */
140 };
141
142 /* Fatal errors */
143 enum Fatals {
144     FAT_NONE,
145     FAT_MAX_INPUT_FILES,
146     FAT_OUT_OF_MEMORY,
147     FAT_TOO_MANY_SEGMENTS,
148     FAT_STRING_TOO_LONG,
149     FAT_CANNOT_OPEN_INPUT,
150     FAT_CANNOT_STAT_INPUT,
151     FAT_CANNOT_OPEN_OUTPUT,
152     FAT_CANNOT_WRITE_OUTPUT,
153     FAT_CANNOT_OPEN_LISTING,
154     FAT_CANNOT_WRITE_LISTING,
155     FAT_CANNOT_READ_LISTING,
156     FAT_NESTING,
157     FAT_IF_NESTING,
158     FAT_TOO_MANY_SYMBOLS,
159     FAT_COUNT                           /* Fatal error count */
160 };
161
162
163
164 /* Warning levels */
165 extern unsigned         WarnLevel;
166
167 /* Statistics */
168 extern unsigned ErrorCount;
169 extern unsigned WarningCount;
170
171
172
173 /*****************************************************************************/
174 /*                                   Code                                    */
175 /*****************************************************************************/
176
177
178
179 void Warning (unsigned WarnNum, ...);
180 /* Print warning message. */
181
182 void PWarning (const FilePos* Pos, unsigned WarnNum, ...);
183 /* Print warning message giving an explicit file and position. */
184
185 void Error (unsigned ErrNum, ...);
186 /* Print an error message */
187
188 void PError (const FilePos* Pos, unsigned ErrNum, ...);
189 /* Print an error message giving an explicit file and position. */
190
191 void ErrorSkip (unsigned ErrNum, ...);
192 /* Print an error message and skip the rest of the line */
193
194 void Fatal (unsigned FatNum, ...) attribute ((noreturn));
195 /* Print a message about a fatal error and die */
196
197 void Internal (const char* Format, ...) attribute((noreturn, format(printf,1,2)));
198 /* Print a message about an internal compiler error and die. */
199
200
201
202 /* End of error.h */
203
204 #endif
205
206
207
208