missing return values is a warning now
[fw/sdcc] / support / Util / SDCCerr.c
1 /*
2  * SDCCerr - Standard error handler
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU Library General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18
19 #include <stdio.h>
20
21 #include "SDCCerr.h"
22
23
24 #define USE_STDOUT_FOR_ERRORS           0
25
26 #if USE_STDOUT_FOR_ERRORS
27 #define DEFAULT_ERROR_OUT       stdout
28 #else
29 #define DEFAULT_ERROR_OUT       stderr
30 #endif
31
32 static struct {
33     ERROR_LOG_LEVEL logLevel;
34     FILE *out;
35 } _SDCCERRG;
36
37 extern char *filename ;
38 extern int lineno ;
39 extern int fatalError ;
40
41 /* Currently the errIndex field must match the position of the 
42  * entry in the array. It is only included in order to make 
43  * human error lookup easier.
44  */
45 struct  
46 {
47     int                 errIndex;
48     ERROR_LOG_LEVEL     errType;
49     const char          *errText;
50 } ErrTab [] =
51 {
52 { E_DUPLICATE, ERROR_LEVEL_ERROR,
53    "Duplicate symbol '%s', symbol IGNORED" },
54 { E_SYNTAX_ERROR, ERROR_LEVEL_ERROR,
55    "Syntax error, declaration ignored at '%s'" },
56 { E_CONST_EXPECTED, ERROR_LEVEL_ERROR,
57     "Initializer element is not constant" },
58 { E_OUT_OF_MEM, ERROR_LEVEL_ERROR,
59    "'malloc' failed file '%s' for size %ld" },
60 { E_FILE_OPEN_ERR, ERROR_LEVEL_ERROR,
61    "'fopen' failed on file '%s'" },
62 { E_INVALID_OCLASS, ERROR_LEVEL_ERROR,
63    "Internal Error Oclass invalid '%s'" },
64 { E_CANNOT_ALLOC, ERROR_LEVEL_ERROR,
65    "Cannot allocate variable '%s'." },
66 { E_OLD_STYLE, ERROR_LEVEL_ERROR,
67    "Old style C declaration. IGNORED '%s'" },
68 { E_STACK_OUT, ERROR_LEVEL_ERROR,
69    "Out of stack Space. '%s' not allocated" },
70 { E_INTERNAL_ERROR, ERROR_LEVEL_ERROR,
71    "FATAL Compiler Internal Error in file '%s' line number '%d' : %s \n"
72    "Contact Author with source code" },
73 { E_LVALUE_REQUIRED, ERROR_LEVEL_ERROR,
74    "'lvalue' required for '%s' operation." },
75 { E_TMPFILE_FAILED, ERROR_LEVEL_ERROR,
76    "Creation of temp file failed" },
77 { E_FUNCTION_EXPECTED, ERROR_LEVEL_ERROR,
78    "called object is not a function" },
79 { E_USING_ERROR, ERROR_LEVEL_ERROR,
80    "'using', 'interrupt' or 'reentrant' must follow a function definiton.'%s'" },
81 { E_SFR_INIT, ERROR_LEVEL_ERROR,
82    "Absolute address & initial value both cannot be specified for\n"
83    " a 'sfr','sbit' storage class, initial value ignored '%s'" },
84 { W_INIT_IGNORED, ERROR_LEVEL_WARNING,
85    "Variable in the storage class cannot be initialized.'%s'" },
86 { E_AUTO_ASSUMED, ERROR_LEVEL_ERROR,
87    "storage class not allowed for automatic variable '%s' in reentrant function unless static" },
88 { E_AUTO_ABSA, ERROR_LEVEL_ERROR,
89    "absolute address not allowed for automatic var '%s' in reentrant function " },
90 { W_INIT_WRONG, ERROR_LEVEL_WARNING,
91    "Initializer different levels of indirections" },
92 { E_FUNC_REDEF, ERROR_LEVEL_ERROR,
93    "Function name '%s' redefined " },
94 { E_ID_UNDEF, ERROR_LEVEL_ERROR,
95    "Undefined identifier '%s'" },
96 { W_STACK_OVERFLOW, ERROR_LEVEL_WARNING,
97    "stack exceeds 256 bytes for function '%s'" },
98 { E_NEED_ARRAY_PTR, ERROR_LEVEL_ERROR,
99    "Array or pointer required for '%s' operation " },
100 { E_IDX_NOT_INT, ERROR_LEVEL_ERROR,
101    "Array index not an integer" },
102 { E_ARRAY_BOUND, ERROR_LEVEL_ERROR,
103    "Array bound Exceeded, assuming zero" },
104 { E_STRUCT_UNION, ERROR_LEVEL_ERROR,
105    "Structure/Union expected left of '.%s'" },
106 { E_NOT_MEMBER, ERROR_LEVEL_ERROR,
107    "'%s' not a structure/union member" },
108 { E_PTR_REQD, ERROR_LEVEL_ERROR,
109    "Pointer required" },
110 { E_UNARY_OP, ERROR_LEVEL_ERROR,
111    "'unary %c': illegal operand" },
112 { E_CONV_ERR, ERROR_LEVEL_ERROR,
113    "convertion error: integral promotion failed" },
114 { E_INT_REQD, ERROR_LEVEL_ERROR,
115    "type must be INT for bit field definition" },
116 { E_BITFLD_SIZE, ERROR_LEVEL_ERROR,
117    "bit field size greater than 16. assuming 16" },
118 { W_TRUNCATION, ERROR_LEVEL_WARNING,
119    "high order truncation might occur" },
120 { E_CODE_WRITE, ERROR_LEVEL_ERROR,
121    "Attempt to assign value to a constant variable (%s)" },
122 { E_LVALUE_CONST, ERROR_LEVEL_ERROR,
123    "Lvalue specifies constant object" },
124 { E_ILLEGAL_ADDR, ERROR_LEVEL_ERROR,
125    "'&' illegal operand , %s" },
126 { E_CAST_ILLEGAL, ERROR_LEVEL_ERROR,
127    "illegal cast (cast cannot be aggregate)" },
128 { E_MULT_INTEGRAL, ERROR_LEVEL_ERROR,
129    "'*' bad operand" },
130 { E_ARG_ERROR, ERROR_LEVEL_ERROR,
131    "Argument count error, argument ignored" },
132 { E_ARG_COUNT, ERROR_LEVEL_ERROR,
133    "Function was expecting more arguments" },
134 { E_FUNC_EXPECTED, ERROR_LEVEL_ERROR,
135    "Function name expected '%s'.ANSI style declaration REQUIRED" },
136 { E_PLUS_INVALID, ERROR_LEVEL_ERROR,
137    "invalid operand '%s'" },
138 { E_PTR_PLUS_PTR, ERROR_LEVEL_ERROR,
139    "pointer + pointer invalid" },
140 { E_SHIFT_OP_INVALID, ERROR_LEVEL_ERROR,
141    "invalid operand for shift operator" },
142 { E_COMPARE_OP, ERROR_LEVEL_ERROR,
143    "compare operand cannot be struct/union" },
144 { E_BITWISE_OP, ERROR_LEVEL_ERROR,
145    "operand invalid for bitwise operation" },
146 { E_ANDOR_OP, ERROR_LEVEL_ERROR,
147    "Invalid operand for '&&' or '||'" },
148 { E_TYPE_MISMATCH, ERROR_LEVEL_ERROR,
149    "indirections to different types %s %s " },
150 { E_AGGR_ASSIGN, ERROR_LEVEL_ERROR,
151    "cannot assign values to aggregates" },
152 { E_ARRAY_DIRECT, ERROR_LEVEL_ERROR,
153    "bit Arrays can be accessed by literal index only" },
154 { E_BIT_ARRAY, ERROR_LEVEL_ERROR,
155    "Array or Pointer to bit|sbit|sfr not allowed.'%s'" },
156 { E_DUPLICATE_TYPEDEF, ERROR_LEVEL_ERROR,
157    "typedef/enum '%s' duplicate.Previous definiton Ignored" },
158 { E_ARG_TYPE, ERROR_LEVEL_ERROR,
159    "Actual Argument type different from declaration %d" },
160 { E_RET_VALUE, ERROR_LEVEL_ERROR,
161    "Function return value mismatch" },
162 { E_FUNC_AGGR, ERROR_LEVEL_ERROR,
163    "Function cannot return aggregate. Func body ignored" },
164 { E_FUNC_DEF, ERROR_LEVEL_ERROR,
165    "ANSI Style declaration needed" },
166 { E_DUPLICATE_LABEL, ERROR_LEVEL_ERROR,
167    "Label name redefined '%s'" },
168 { E_LABEL_UNDEF, ERROR_LEVEL_ERROR,
169    "Label undefined '%s'" },
170 { E_FUNC_VOID, ERROR_LEVEL_ERROR,
171    "void function returning value" },
172 { W_VOID_FUNC, ERROR_LEVEL_WARNING,
173    "function '%s' must return value" },
174 { W_RETURN_MISMATCH, ERROR_LEVEL_WARNING,
175    "function return value mismatch" },
176 { E_CASE_CONTEXT, ERROR_LEVEL_ERROR,
177    "'case/default' found without 'switch'.statement ignored" },
178 { E_CASE_CONSTANT, ERROR_LEVEL_ERROR,
179    "'case' expression not constant. statement ignored" },
180 { E_BREAK_CONTEXT, ERROR_LEVEL_ERROR,
181    "'break/continue' statement out of context" },
182 { E_SWITCH_AGGR, ERROR_LEVEL_ERROR,
183    "nonintegral used in switch expression" },
184 { E_FUNC_BODY, ERROR_LEVEL_ERROR,
185    "function '%s' already has body" },
186 { E_UNKNOWN_SIZE, ERROR_LEVEL_ERROR,
187    "attempt to allocate variable of unknown size '%s'" },
188 { E_AUTO_AGGR_INIT, ERROR_LEVEL_ERROR,
189    "aggregate 'auto' variable '%s' cannot be initialized" },
190 { E_INIT_COUNT, ERROR_LEVEL_ERROR,
191    "too many initializers" },
192 { E_INIT_STRUCT, ERROR_LEVEL_ERROR,
193    "struct/union/array '%s' :initialization needs curly braces" },
194 { E_INIT_NON_ADDR, ERROR_LEVEL_ERROR,
195    "non-address initialization expression" },
196 { E_INT_DEFINED, ERROR_LEVEL_ERROR,
197    "interrupt no '%d' already has a service routine '%s'" },
198 { E_INT_ARGS, ERROR_LEVEL_ERROR,
199    "interrupt routine cannot have arguments, arguments ingored" },
200 { E_INCLUDE_MISSING, ERROR_LEVEL_ERROR,
201    "critical compiler #include file missing.            " },
202 { E_NO_MAIN, ERROR_LEVEL_ERROR,
203    "function 'main' undefined" },
204 { E_EXTERN_INIT, ERROR_LEVEL_ERROR,
205    "'extern' variable '%s' cannot be initialised        " },
206 { E_PRE_PROC_FAILED, ERROR_LEVEL_ERROR,
207    "Pre-Processor %s" },
208 { E_DUP_FAILED, ERROR_LEVEL_ERROR,
209    "_dup call failed" },
210 { E_INCOMPAT_TYPES, ERROR_LEVEL_ERROR,
211    "incompatible types" },
212 { W_LOOP_ELIMINATE, ERROR_LEVEL_WARNING,
213    "'while' loop with 'zero' constant.loop eliminated" },
214 { W_NO_SIDE_EFFECTS, ERROR_LEVEL_WARNING,
215    "%s expression has NO side effects.expr eliminated" },
216 { W_CONST_TOO_LARGE, ERROR_LEVEL_PEDANTIC,
217    "constant value '%s', out of range." },
218 { W_BAD_COMPARE, ERROR_LEVEL_WARNING,
219    "comparison will either, ALWAYs succeed or ALWAYs fail" },
220 { E_TERMINATING, ERROR_LEVEL_ERROR,
221    "Compiler Terminating , contact author with source" },
222 { W_LOCAL_NOINIT, ERROR_LEVEL_WARNING,
223    "'auto' variable '%s' may be used before initialization at %s(%d)" },
224 { W_NO_REFERENCE, ERROR_LEVEL_WARNING,
225    "in function %s unreferenced %s : '%s'" },
226 { E_OP_UNKNOWN_SIZE, ERROR_LEVEL_ERROR,
227    "unknown size for operand" },
228 { W_LONG_UNSUPPORTED, ERROR_LEVEL_WARNING,
229    "'%s' 'long' not supported , declared as 'int'." },
230 { E_LITERAL_GENERIC, ERROR_LEVEL_ERROR,
231     //"illegal cast of LITERAL value to 'generic' pointer: assuming 'xdata' pointer" },
232     "illegal cast of LITERAL value to 'generic' pointer" },
233 { E_SFR_ADDR_RANGE, ERROR_LEVEL_ERROR,
234    "%s '%s' address out of range" },
235 { E_BITVAR_STORAGE, ERROR_LEVEL_ERROR,
236    "storage class CANNOT be specified for bit variable '%s'" },
237 { E_EXTERN_MISMATCH, ERROR_LEVEL_ERROR,
238    "extern definition for '%s' mismatches with declaration." },
239 { W_NONRENT_ARGS, ERROR_LEVEL_WARNING,
240    "Functions called via pointers must be 'reentrant' to take arguments" },
241 { W_DOUBLE_UNSUPPORTED, ERROR_LEVEL_WARNING,
242    "type 'double' not supported assuming 'float'" },
243 { W_IF_NEVER_TRUE, ERROR_LEVEL_WARNING,
244    "if-statement condition always false, if-statement not generated" },
245 { W_FUNC_NO_RETURN, ERROR_LEVEL_WARNING,
246    "no 'return' statement found for function '%s'" },
247 { W_PRE_PROC_WARNING, ERROR_LEVEL_WARNING,
248    "Pre-Processor %s" },
249 { W_STRUCT_AS_ARG, ERROR_LEVEL_WARNING,
250    "structure '%s' passed as function argument changed to pointer" },
251 { E_PREV_DEF_CONFLICT, ERROR_LEVEL_ERROR,
252    "conflict with previous definition of '%s' for attribute '%s'" },
253 { E_CODE_NO_INIT, ERROR_LEVEL_ERROR,
254    "variable '%s' declared in code space must have initialiser" },
255 { E_OPS_INTEGRAL, ERROR_LEVEL_ERROR,
256    "operands not integral for assignment operation" },
257 { E_TOO_MANY_PARMS, ERROR_LEVEL_ERROR,
258    "too many parameters " },
259 { E_TOO_FEW_PARMS, ERROR_LEVEL_ERROR,
260    "too few parameters" },
261 { E_FUNC_NO_CODE, ERROR_LEVEL_ERROR,
262    "code not generated for '%s' due to previous errors" },
263 { E_TYPE_MISMATCH_PARM, ERROR_LEVEL_ERROR,
264    "type mismatch for parameter number %d" },
265 { E_INVALID_FLOAT_CONST, ERROR_LEVEL_ERROR,
266    "invalid float constant '%s'" },
267 { E_INVALID_OP, ERROR_LEVEL_ERROR,
268    "invalid operand for '%s' operation" },
269 { E_SWITCH_NON_INTEGER, ERROR_LEVEL_ERROR,
270    "switch value not an integer" },
271 { E_CASE_NON_INTEGER, ERROR_LEVEL_ERROR,
272    "case label not an integer" },
273 { W_FUNC_TOO_LARGE, ERROR_LEVEL_WARNING,
274    "function '%s' too large for global optimization" },
275 { W_CONTROL_FLOW, ERROR_LEVEL_PEDANTIC,
276    "conditional flow changed by optimizer '%s(%d)':so said EVELYN the modified DOG" },
277 { W_PTR_TYPE_INVALID, ERROR_LEVEL_WARNING,
278    "invalid type specifier for pointer type specifier ignored" },
279 { W_IMPLICIT_FUNC, ERROR_LEVEL_WARNING,
280    "function '%s' implicit declaration" },
281 { W_CONTINUE, ERROR_LEVEL_WARNING,
282    "%s" },
283 { I_EXTENDED_STACK_SPILS, ERROR_LEVEL_INFO,
284    "extended stack by %d bytes for compiler temp(s) :in function  '%s': %s " },
285 { W_UNKNOWN_PRAGMA, ERROR_LEVEL_WARNING,
286    "unknown or unsupported #pragma directive '%s'" },
287 { W_SHIFT_CHANGED, ERROR_LEVEL_PEDANTIC,
288    "%s shifting more than size of object changed to zero" },
289 { W_UNKNOWN_OPTION, ERROR_LEVEL_WARNING,
290    "unknown compiler option '%s' ignored" },
291 { W_UNSUPP_OPTION, ERROR_LEVEL_WARNING,
292    "option '%s' no longer supported  '%s' " },
293 { W_UNKNOWN_FEXT, ERROR_LEVEL_WARNING,
294    "don't know what to do with file '%s'. file extension unsupported" },
295 { W_TOO_MANY_SRC, ERROR_LEVEL_WARNING,
296    "cannot compile more than one source file. file '%s' ignored" },
297 { I_CYCLOMATIC, ERROR_LEVEL_INFO,
298    "function '%s', # edges %d , # nodes %d , cyclomatic complexity %d" },
299 { E_DIVIDE_BY_ZERO, ERROR_LEVEL_ERROR,
300    "dividing by ZERO" },
301 { E_FUNC_BIT, ERROR_LEVEL_ERROR,
302    "function cannot return 'bit'" },
303 { E_CAST_ZERO, ERROR_LEVEL_ERROR,
304    "casting from to type 'void' is illegal" },
305 { W_CONST_RANGE, ERROR_LEVEL_WARNING,
306    "constant is out of range %s" },
307 { W_CODE_UNREACH, ERROR_LEVEL_PEDANTIC,
308    "unreachable code %s(%d)" },
309 { E_NONPTR2_GENPTR, ERROR_LEVEL_ERROR,
310    "non-pointer type cast to generic pointer" },
311 { W_POSSBUG, ERROR_LEVEL_WARNING,
312    "possible code generation error at line %d,\n"
313    " send source to sandeep.dutta@usa.net" },
314 { E_INCOMPAT_PTYPES, ERROR_LEVEL_ERROR,
315    "pointer types incompatible " },
316 { W_UNKNOWN_MODEL, ERROR_LEVEL_WARNING,
317    "unknown memory model at %s : %d" },
318 { E_UNKNOWN_TARGET, ERROR_LEVEL_ERROR,
319    "cannot generate code for target '%s'" },
320 { W_INDIR_BANKED, ERROR_LEVEL_WARNING,
321    "Indirect call to a banked function not implemented." },
322 { W_UNSUPPORTED_MODEL, ERROR_LEVEL_WARNING,
323    "Model '%s' not supported for %s, ignored." },
324 { W_BANKED_WITH_NONBANKED, ERROR_LEVEL_WARNING,
325    "Both banked and nonbanked attributes used.  nonbanked wins." },
326 { W_BANKED_WITH_STATIC, ERROR_LEVEL_WARNING,
327    "Both banked and static used.  static wins." },
328 { W_INT_TO_GEN_PTR_CAST, ERROR_LEVEL_WARNING,
329    "converting integer type to generic pointer: assuming XDATA" },
330 { W_ESC_SEQ_OOR_FOR_CHAR, ERROR_LEVEL_WARNING,
331    "escape sequence out of range for char." },
332 { E_INVALID_HEX, ERROR_LEVEL_ERROR,
333    "\\x used with no following hex digits." },
334 { W_FUNCPTR_IN_USING_ISR, ERROR_LEVEL_WARNING,
335    "call via function pointer in ISR using non-zero register bank.\n"
336    "            Cannot determine which register bank to save." },
337 { E_NO_SUCH_BANK, ERROR_LEVEL_ERROR,
338    "called function uses unknown register bank %d." },
339 { E_TWO_OR_MORE_DATA_TYPES, ERROR_LEVEL_ERROR,
340     "two or more data types in declaration for '%s'" },
341 { E_LONG_OR_SHORT_INVALID, ERROR_LEVEL_ERROR,
342     "long or short specified for %s '%s'" },
343 { E_SIGNED_OR_UNSIGNED_INVALID, ERROR_LEVEL_ERROR,
344     "signed or unsigned specified for %s '%s'" },
345 { E_LONG_AND_SHORT_INVALID, ERROR_LEVEL_ERROR,
346     "both long and short specified for %s '%s'" },
347 { E_SIGNED_AND_UNSIGNED_INVALID, ERROR_LEVEL_ERROR,
348     "both signed and unsigned specified for %s '%s'" },
349 { E_TWO_OR_MORE_STORAGE_CLASSES, ERROR_LEVEL_ERROR,
350     "two or more storage classes in declaration for '%s'" },
351 { W_EXCESS_INITIALIZERS, ERROR_LEVEL_WARNING,
352     "excess elements in %s initializer after `%s' at line %d" },
353 { E_ARGUMENT_MISSING, ERROR_LEVEL_ERROR,
354    "Option %s requires an argument." },
355 { W_STRAY_BACKSLASH, ERROR_LEVEL_WARNING,
356     "stray '\\' at column %d" },
357 { W_NEWLINE_IN_STRING, ERROR_LEVEL_WARNING,
358     "newline in string constant" },
359 { E_CANNOT_USE_GENERIC_POINTER, ERROR_LEVEL_ERROR,
360     "cannot use generic pointer %s to initialize %s" },
361 { W_EXCESS_SHORT_OPTIONS, ERROR_LEVEL_WARNING,
362     "Only one short option can be specified at a time.  Rest of %s ignored." },
363 { E_VOID_VALUE_USED, ERROR_LEVEL_ERROR,
364     "void value not ignored as it ought to be" },
365 { W_INTEGRAL2PTR_NOCAST, ERROR_LEVEL_WARNING,
366     "converting integral to pointer without a cast" },
367 { W_PTR2INTEGRAL_NOCAST, ERROR_LEVEL_WARNING,
368     "converting pointer to integral without a cast" },
369 { W_SYMBOL_NAME_TOO_LONG, ERROR_LEVEL_WARNING,
370     "symbol name too long, truncated to %d chars" },
371 { W_CAST_STRUCT_PTR,ERROR_LEVEL_WARNING,
372           "cast of struct %s * to struct %s * " },
373 { W_IF_ALWAYS_TRUE, ERROR_LEVEL_WARNING,
374     "if-statement condition always true, if-statement not generated" },
375 { E_PARAM_NAME_OMITTED, ERROR_LEVEL_ERROR,
376     "in function %s: name omitted for parameter %d" },
377 { W_NO_FILE_ARG_IN_C1, ERROR_LEVEL_WARNING,
378     "only standard input is compiled in c1 mode. file '%s' ignored" },
379 { E_NEED_OPT_O_IN_C1, ERROR_LEVEL_ERROR,
380     "must specify assembler file name with -o in c1 mode" },
381 { W_ILLEGAL_OPT_COMBINATION, ERROR_LEVEL_WARNING,
382     "illegal combination of options (--c1mode, -E, -S -c)" },
383 };
384
385 /*
386 -------------------------------------------------------------------------------
387 SetErrorOut - Set the error output file
388
389 -------------------------------------------------------------------------------
390 */
391
392 FILE *SetErrorOut(FILE *NewErrorOut)
393
394 {
395     _SDCCERRG.out = NewErrorOut ;
396
397 return NewErrorOut ;
398 }
399
400 void
401 setErrorLogLevel (ERROR_LOG_LEVEL level)
402 {
403     _SDCCERRG.logLevel = level;
404 }
405
406 /*
407 -------------------------------------------------------------------------------
408 vwerror - Output a standard eror message with variable number of arguements
409
410 -------------------------------------------------------------------------------
411 */
412
413 void vwerror (int errNum, va_list marker)
414 {
415     if (_SDCCERRG.out == NULL) {
416         _SDCCERRG.out = DEFAULT_ERROR_OUT;
417     }
418
419     if (ErrTab[errNum].errIndex != errNum)
420     {
421         fprintf(_SDCCERRG.out, 
422                 "Internal error: error table entry for %d inconsistent.", errNum);
423     }
424
425
426     if (ErrTab[errNum].errType >= _SDCCERRG.logLevel) {
427         if ( ErrTab[errNum].errType == ERROR_LEVEL_ERROR )
428             fatalError++ ;
429   
430         if ( filename && lineno ) {
431             fprintf(_SDCCERRG.out, "%s:%d: ",filename,lineno);
432         } else if (lineno) {
433             fprintf(_SDCCERRG.out, "at %d: ", lineno);
434         } else {
435             fprintf(_SDCCERRG.out, "-:0: ");
436         }
437     
438         switch(ErrTab[errNum].errType)
439         {
440             case ERROR_LEVEL_ERROR:
441                 fprintf(_SDCCERRG.out, "error: ");
442                 break;
443             case ERROR_LEVEL_WARNING:
444             case ERROR_LEVEL_PEDANTIC:
445                 fprintf(_SDCCERRG.out, "warning: ");
446                 break;
447             case ERROR_LEVEL_INFO:
448                 fprintf(_SDCCERRG.out, "info: ");
449                 break;
450             default:
451                 break;                  
452         }
453     
454         vfprintf(_SDCCERRG.out, ErrTab[errNum].errText,marker);
455         fprintf(_SDCCERRG.out, "\n");
456     }
457     else {
458         // Below the logging level, drop.
459     }
460 }
461 /*
462 -------------------------------------------------------------------------------
463 werror - Output a standard eror message with variable number of arguements
464
465 -------------------------------------------------------------------------------
466 */
467
468 void werror (int errNum, ... )
469 {
470     va_list     marker;
471     va_start(marker,errNum);
472     vwerror(errNum, marker);
473     va_end( marker );
474 }
475