Imported Upstream version 2.9.0
[debian/cc1111] / src / SDCCerr.h
1 /*
2 ===============================================================================
3 SDCCERR - SDCC Standard error handler
4
5
6 ===============================================================================
7 */
8
9 #if !defined(__SDCCERR_H)
10
11 #define __SDCCERR_H
12
13 #include <stdio.h>
14 #include <stdarg.h>
15
16 /* ERROR Message Definition */
17
18 #define E_DUPLICATE                     0 /* Duplicate variable   */
19 #define E_SYNTAX_ERROR                  1 /* Syntax Error         */
20 #define E_CONST_EXPECTED                2 /* constant expected    */
21 #define E_OUT_OF_MEM                    3 /* malloc failed        */
22 #define E_FILE_OPEN_ERR                 4 /* File open failed     */
23 #define E_INVALID_OCLASS                5 /* output class invalid */
24 #define E_CANNOT_ALLOC                  6 /* cannot allocate space*/
25 #define E_OLD_STYLE                     7 /* old style C ! allowed*/
26 #define E_STACK_OUT                     8 /* v r out of stack     */
27 #define E_INTERNAL_ERROR                9 /* unable to alloc tvar */
28 #define E_LVALUE_REQUIRED              10 /* lvalue required      */
29 #define E_TMPFILE_FAILED               11 /* tmpfile creation failed */
30 #define E_FUNCTION_EXPECTED            12 /* function expected    */
31 #define E_USING_ERROR                  13 /* using in error       */
32 #define E_SFR_INIT                     14 /* init error for sbit  */
33 #define W_INIT_IGNORED                 15 /* initialiser ignored  */
34 #define E_AUTO_ASSUMED                 16 /* sclass auto assumed  */
35 #define E_AUTO_ABSA                    17 /* abs addr for auto var*/
36 #define W_INIT_WRONG                   18 /* initializer type !=  */
37 #define E_FUNC_REDEF                   19 /* func name redefined  */
38 #define E_ID_UNDEF                     20 /* identifer undefined  */
39 #define W_STACK_OVERFLOW               21 /* stack overflow       */
40 #define E_NEED_ARRAY_PTR               22 /* array or pointer reqd*/
41 #define E_IDX_NOT_INT                  23 /* index not an integer */
42 #define W_IDX_OUT_OF_BOUNDS            24 /* array index out of bounds */
43 #define E_STRUCT_UNION                 25 /* struct,union expected*/
44 #define E_NOT_MEMBER                   26 /* !struct/union member */
45 #define E_PTR_REQD                     27 /* pointer required     */
46 #define E_UNARY_OP                     28 /* unary operator bad op*/
47 #define E_CONV_ERR                     29 /* conversion error     */
48 #define E_INT_REQD                     30 /* bit field must be int*/
49 #define E_BITFLD_SIZE                  31 /* bit field size > 16  */
50 #define W_TRUNCATION                   32 /* high order trucation */
51 #define E_CODE_WRITE                   33 /* trying 2 write to code */
52 #define E_LVALUE_CONST                 34 /* lvalue is a const   */
53 #define E_ILLEGAL_ADDR                 35 /* address of bit      */
54 #define E_CAST_ILLEGAL                 36 /* cast illegal        */
55 #define E_MULT_INTEGRAL                37 /* mult opernd must b integral */
56 #define E_ARG_ERROR                    38 /* argument count error*/
57 #define E_ARG_COUNT                    39 /* func expecting more */
58 #define E_FUNC_EXPECTED                40 /* func name expected  */
59 #define E_PLUS_INVALID                 41 /* plus invalid        */
60 #define E_PTR_PLUS_PTR                 42 /* pointer + pointer   */
61 #define E_SHIFT_OP_INVALID             43 /* shft op op invalid  */
62 #define E_COMPARE_OP                   44 /* compare operand     */
63 #define E_BITWISE_OP                   45 /* bit op invalid op   */
64 #define E_ANDOR_OP                     46 /* && || op invalid    */
65 #define E_TYPE_MISMATCH                47 /* type mismatch       */
66 #define E_AGGR_ASSIGN                  48 /* aggr assign         */
67 #define E_ARRAY_DIRECT                 49 /* array indexing in   */
68 #define E_BIT_ARRAY                    50 /* bit array not allowed  */
69 #define E_DUPLICATE_TYPEDEF            51 /* typedef name duplicate */
70 #define E_ARG_TYPE                     52 /* arg type mismatch   */
71 #define E_RET_VALUE                    53 /* return value mismatch */
72 #define E_FUNC_AGGR                    54 /* function returing aggr */
73 #define E_FUNC_DEF                     55 /* ANSI Style def neede */
74 #define E_DUPLICATE_LABEL              56 /* duplicate label name */
75 #define E_LABEL_UNDEF                  57 /* undefined label used */
76 #define E_FUNC_VOID                    58 /* void func ret value  */
77 #define W_VOID_FUNC                    59 /* func must return value */
78 #define W_RETURN_MISMATCH              60 /* return value mismatch */
79 #define E_CASE_CONTEXT                 61 /* case stmnt without switch */
80 #define E_CASE_CONSTANT                62 /* case expression ! const */
81 #define E_BREAK_CONTEXT                63 /* break statement invalid */
82 #define E_SWITCH_AGGR                  64 /* non integral for switch */
83 #define E_FUNC_BODY                    65 /* func has body already */
84 #define E_UNKNOWN_SIZE                 66 /* variable has unknown size */
85 #define E_AUTO_AGGR_INIT               67 /* auto aggregates no init */
86 #define E_INIT_COUNT                   68 /* too many initializers */
87 #define E_INIT_STRUCT                  69 /* struct init wrong   */
88 #define E_INIT_NON_ADDR                70 /* non address xpr for init */
89 #define E_INT_DEFINED                  71 /* interrupt already over */
90 #define E_INT_ARGS                     72 /* interrupt rtn cannot have args */
91 #define E_INCLUDE_MISSING              73 /* compiler include missing */
92 #define E_NO_MAIN                      74 /* main function undefined */
93 #define E_EXTERN_INIT                  75 /* extern variable initialised */
94 #define E_PRE_PROC_FAILED              76 /* preprocessor failed */
95 #define E_DUP_FAILED                   77 /* file DUP failed     */
96 #define E_INCOMPAT_TYPES               78 /* incompatible types casting */
97 #define W_LOOP_ELIMINATE               79 /* loop eliminated     */
98 #define W_NO_SIDE_EFFECTS              80 /* expression has no side effects */
99 #define W_CONST_TOO_LARGE              81 /* constant out of range */
100 #define W_BAD_COMPARE                  82 /* bad comparison      */
101 #define E_TERMINATING                  83 /* compiler terminating */
102 #define W_LOCAL_NOINIT                 84 /* local reference before assignment */
103 #define W_NO_REFERENCE                 85 /* no reference to local variable */
104 #define E_OP_UNKNOWN_SIZE              86 /* unknown size for operand */
105 #define W_LONG_UNSUPPORTED             87 /* 'long' not supported yet */
106 #define E_LITERAL_GENERIC              88 /* literal being cast to generic pointer */
107 #define E_SFR_ADDR_RANGE               89 /* sfr address out of range */
108 #define E_BITVAR_STORAGE               90 /* storage given for 'bit' variable */
109 #define E_EXTERN_MISMATCH              91 /* extern declaration mismatches */
110 #define E_NONRENT_ARGS                 92 /* fptr non reentrant has args */
111 #define W_DOUBLE_UNSUPPORTED           93 /* 'double' not supported yet */
112 #define W_COMP_RANGE                   94 /* comparison is always %s due to limited range of data type */
113 #define W_FUNC_NO_RETURN               95 /* no return statement found */
114 #define W_PRE_PROC_WARNING             96 /* preprocessor generated warning */
115 #define W_STRUCT_AS_ARG                97 /* structure passed as argument */
116 #define E_PREV_DEF_CONFLICT            98 /* previous definition conflicts with current */
117 #define E_CODE_NO_INIT                 99 /* vars in code space must have initializer */
118 #define E_OPS_INTEGRAL                100 /* operans must be integral for certian assignments */
119 #define E_TOO_MANY_PARMS              101 /* too many parameters */
120 #define E_TOO_FEW_PARMS               102 /* to few parameters   */
121 #define E_FUNC_NO_CODE                103 /* fatalError          */
122 #define E_TYPE_MISMATCH_PARM          104 /* type mismatch for parameter */
123 #define E_INVALID_FLOAT_CONST         105 /* invalid floating point literal string */
124 #define E_INVALID_OP                  106 /* invalid operand for some operation */
125 #define E_SWITCH_NON_INTEGER          107 /* switch value not integer */
126 #define E_CASE_NON_INTEGER            108 /* case value not integer */
127 #define W_FUNC_TOO_LARGE              109 /* function too large  */
128 #define W_CONTROL_FLOW                110 /* control flow changed due to optimization */
129 #define W_PTR_TYPE_INVALID            111 /* invalid type specifier for pointer */
130 #define W_IMPLICIT_FUNC               112 /* function declared implicitly */
131 #define W_CONTINUE                    113 /* more than one line  */
132 #define I_EXTENDED_STACK_SPILS        114 /* too many spils occured */
133 #define W_UNKNOWN_PRAGMA              115 /* #pragma directive unsupported */
134 #define W_SHIFT_CHANGED               116 /* shift changed to zero */
135 #define W_UNKNOWN_OPTION              117 /* don't know the option */
136 #define W_UNSUPP_OPTION               118 /* processor reset has been redifned */
137 #define W_UNKNOWN_FEXT                119 /* unknown file extension */
138 #define W_TOO_MANY_SRC                120 /* can only compile one .c file at a time */
139 #define I_CYCLOMATIC                  121 /* information message */
140 #define E_DIVIDE_BY_ZERO              122 /* / 0 */
141 #define E_FUNC_BIT                    123 /* function cannot return bit */
142 #define E_CAST_ZERO                   124 /* casting to from size zero */
143 #define W_CONST_RANGE                 125 /* constant too large  */
144 #define W_CODE_UNREACH                126 /* unreachable code    */
145 #define E_NONPTR2_GENPTR              127 /* non pointer cast to generic pointer */
146 #define W_POSSBUG                     128 /* possible code generation error */
147 #define E_INCOMPAT_PTYPES             129 /* incampatible pointer assignment */
148 #define W_UNKNOWN_MODEL               130 /* Unknown memory model */
149 #define E_UNKNOWN_TARGET              131 /* target not defined  */
150 #define W_INDIR_BANKED                132 /* Indirect call to a banked fun */
151 #define W_UNSUPPORTED_MODEL           133 /* Unsupported model, ignored */
152 #define W_BANKED_WITH_NONBANKED       134 /* banked and nonbanked attributes mixed */
153 #define W_BANKED_WITH_STATIC          135 /* banked and static mixed */
154 #define W_INT_TO_GEN_PTR_CAST         136 /* Converting integer type to generic pointer. */
155 #define W_ESC_SEQ_OOR_FOR_CHAR        137 /* Escape sequence of of range for char */
156 #define E_INVALID_HEX                 138 /* \x used with no following hex digits */
157 #define W_FUNCPTR_IN_USING_ISR        139 /* Call via function pointer in ISR with using attribute. */
158 #define E_NO_SUCH_BANK                140 /* 'using' attribute specifies non-existant register bank. */
159 #define E_TWO_OR_MORE_DATA_TYPES      141
160 #define E_LONG_OR_SHORT_INVALID       142 /* long or short invalid for .. */
161 #define E_SIGNED_OR_UNSIGNED_INVALID  143 /* signed or unsigned invalid for .. */
162 #define E_LONG_AND_SHORT_INVALID      144 /* long and short invalid for .. */
163 #define E_SIGNED_AND_UNSIGNED_INVALID 145 /* signed and unsigned invalid for .. */
164 #define E_TWO_OR_MORE_STORAGE_CLASSES 146
165 #define W_EXCESS_INITIALIZERS         147 /* too much initializers for array */
166 #define E_ARGUMENT_MISSING            148 /* Option requires an argument. */
167 #define W_STRAY_BACKSLASH             149
168 #define W_NEWLINE_IN_STRING           150
169 #define E_CANNOT_USE_GENERIC_POINTER  151
170 #define W_EXCESS_SHORT_OPTIONS        152
171 #define E_VOID_VALUE_USED             153
172 #define W_INTEGRAL2PTR_NOCAST         154
173 #define W_PTR2INTEGRAL_NOCAST         155
174 #define W_SYMBOL_NAME_TOO_LONG        156
175 #define W_CAST_STRUCT_PTR             157 /* pointer to different structure types */
176 #define W_LIT_OVERFLOW                158 /* overflow in implicit constant conversion */
177 #define E_PARAM_NAME_OMITTED          159
178 #define W_NO_FILE_ARG_IN_C1           160
179 #define E_NEED_OPT_O_IN_C1            161
180 #define W_ILLEGAL_OPT_COMBINATION     162
181 #define E_DUPLICATE_MEMBER            163
182 #define E_STACK_VIOLATION             164 /* internal stack violation */
183 #define W_INT_OVL                     165 /* integer overflow in expression */
184 #define W_USELESS_DECL                166 /* useless declaration */
185 #define E_INT_BAD_INTNO               167 /* invalid interrupt number */
186 #define W_BITFLD_NAMED                168 /* declarator used with 0 length bitfield */
187 #define E_FUNC_ATTR                   169 /* function attribute without function */
188 #define W_SAVE_RESTORE                170 /* unmatched #pragma SAVE and #pragma RESTORE */
189 #define E_INVALID_CRITICAL            171 /* operation invalid in critical sequence */
190 #define E_NOT_ALLOWED                 172 /* %s not allowed here */
191 #define E_BAD_TAG                     173 /* '%s' is not a %s tag */
192 #define E_ENUM_NON_INTEGER            174 /* enumeration constant not an integer */
193 #define W_DEPRECATED_PRAGMA           175 /* deprecated pragma */
194 #define E_SIZEOF_INCOMPLETE_TYPE      176 /* sizeof applied to an incomplete type */
195 #define E_PREVIOUS_DEF                177 /* previously defined here */
196 #define W_SIZEOF_VOID                 178 /* size of void is zero */
197 #define W_POSSBUG2                    179 /* possible bug, new format */
198 #define W_COMPLEMENT                  180 /* ~bit can give unexpected results */
199 #define E_SHADOWREGS_NO_ISR           181 /* shadowregs keyword following non-ISR function */
200 #define W_SFR_ABSRANGE                182 /* sfr at address out of range */
201 #define E_BANKED_WITH_CALLEESAVES     183 /* banked and callee-saves mixed */
202 #define W_INVALID_INT_CONST           184 /* invalid integer literal string */
203 #define W_CMP_SU_CHAR                 185 /* comparison of 'signed char' with 'unsigned char' requires promotion to int */
204 #define W_INVALID_FLEXARRAY           186 /* invalid use of structure with flexible array member */
205 #define W_C89_NO_FLEXARRAY            187 /* ISO C90 does not support flexible array members */
206 #define E_FLEXARRAY_NOTATEND          188 /* flexible array member not at end of struct */
207 #define E_FLEXARRAY_INEMPTYSTRCT      189 /* flexible array in otherwise empty struct */
208 #define W_EMPTY_SOURCE_FILE           190 /* ISO C forbids an empty source file */
209 #define W_BAD_PRAGMA_ARGUMENTS        191 /* #pragma %s: bad argument(s); pragma ignored */
210 #define E_BAD_RESTRICT                192 /* Only pointers may be qualified with 'restrict' */
211 #define E_BAD_INLINE                  193 /* Only functions may be qualified with 'inline' */
212 #define E_BAD_INT_ARGUMENT            194 /* Bad integer option argument */
213 #define E_NEGATIVE_ARRAY_SIZE         195 /* Size of array '%s' is negative */
214 #define MAX_ERROR_WARNING             256 /* size of disable warnings array */
215
216 /** Describes the maximum error level that will be logged.  Any level
217  *  includes all of the levels listed after it.
218  *
219  *
220  */
221 enum _ERROR_LOG_LEVEL {
222     /** Everything.  Currently the same as PEDANTIC. */
223     ERROR_LEVEL_ALL,
224     /** All warnings, including those considered 'reasonable to use,
225         on occasion, in clean programs' (man 3 gcc). */
226     ERROR_LEVEL_PEDANTIC,
227     /** 'informational' warnings */
228     ERROR_LEVEL_INFO,
229     /** Most warnings. */
230     ERROR_LEVEL_WARNING,
231     /** Errors only. */
232     ERROR_LEVEL_ERROR
233 };
234
235 typedef enum _ERROR_LOG_LEVEL ERROR_LOG_LEVEL;
236
237 struct SDCCERRG {
238     ERROR_LOG_LEVEL logLevel;
239     FILE *out;
240     int style;                        /* 1=MSVC */
241     int werror;                       /* treat the warnings as errors */
242     char disabled[MAX_ERROR_WARNING]; /* 1=warning disabled*/
243 };
244
245 extern struct SDCCERRG _SDCCERRG;
246
247 /** Sets the maximum error level to log.
248     See MAX_ERROR_LEVEL.  The default is ERROR_LEVEL_ALL.
249 */
250 void setErrorLogLevel (ERROR_LOG_LEVEL level);
251
252 /*
253 -------------------------------------------------------------------------------
254 SetErrorOut - Set the error output file
255
256 -------------------------------------------------------------------------------
257 */
258
259 FILE * SetErrorOut(FILE *NewErrorOut) ;
260
261 /*
262 -------------------------------------------------------------------------------
263 vwerror - Output a standard eror message with variable number of arguements
264
265 -------------------------------------------------------------------------------
266 */
267
268 void vwerror (int errNum, va_list marker) ;
269
270 /*
271 -------------------------------------------------------------------------------
272 werror - Output a standard eror message with variable number of arguements
273
274 -------------------------------------------------------------------------------
275 */
276
277 void werror (int errNum, ... ) ;
278
279 /*
280 -------------------------------------------------------------------------------
281 werrorfl - Output a standard eror message with variable number of arguements.
282            Use a specified filename and line number instead of the default.
283
284 -------------------------------------------------------------------------------
285 */
286
287 void werrorfl (char *newFilename, int newLineno, int errNum, ...) ;
288
289 /*
290 -------------------------------------------------------------------------------
291 fatal - Output a standard eror message with variable number of arguements and
292         call exit()
293 -------------------------------------------------------------------------------
294 */
295
296 void fatal (int exitCode, int errNum, ... ) ;
297
298 /*
299 -------------------------------------------------------------------------------
300 style - Change the output error style to MSVC
301 -------------------------------------------------------------------------------
302 */
303
304 void MSVC_style (int style) ;
305
306 /*
307 -------------------------------------------------------------------------------
308 disabled - Disable output of specified warning
309 -------------------------------------------------------------------------------
310 */
311
312 void setWarningDisabled (int errNum) ;
313
314 /*
315 -------------------------------------------------------------------------------
316 Set the flag to treat warnings as errors
317 -------------------------------------------------------------------------------
318 */
319 void setWError (int flag);
320
321 #endif