2 * SDCCerr - Standard error handler
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.
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.
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.
24 #define USE_STDOUT_FOR_ERRORS 0
26 #if USE_STDOUT_FOR_ERRORS
27 #define DEFAULT_ERROR_OUT stdout
29 #define DEFAULT_ERROR_OUT stderr
33 ERROR_LOG_LEVEL logLevel;
44 extern char *filename ;
46 extern int fatalError ;
53 { ERROR ,"error *** Duplicate symbol '%s', symbol IGNORED\n" },
54 { ERROR ,"error *** Syntax Error Declaration ignored\n" },
55 { ERROR ,"error *** Constant Expected Found Variable\n" },
56 { ERROR ,"error *** 'malloc' failed file '%s' for size %ld\n" },
57 { ERROR ,"error *** 'fopen' failed on file '%s'\n" },
58 { ERROR ,"error *** Internal Error Oclass invalid '%s'\n" },
59 { ERROR ,"error *** Cannot allocate variable '%s'.\n" },
60 { ERROR ,"error *** Old style C declaration. IGNORED '%s'\n" },
61 { ERROR ,"error *** Out of stack Space. '%s' not allocated\n" },
62 { ERROR ,"error *** FATAL Compiler Internal Error in file '%s' line number '%d' : %s \nContact Author with source code\n" },
63 { ERROR ,"error *** 'lvalue' required for '%s' operation .\n" },
64 { ERROR ,"error *** Creation of temp file failed\n" },
65 { ERROR ,"error *** Function expected here '%s'\n" },
66 { ERROR ,"error *** 'using', 'interrupt' or 'reentrant' must follow a function definiton .'%s'\n"},
67 { ERROR ,"error *** Absolute address & initial value both cannot be specified for\n a 'sfr','sbit' storage class, initial value ignored '%s'\n" },
68 { WARNING,"warning *** Variable in the storage class cannot be initialized.'%s'\n"},
69 { WARNING,"warning *** storage class not allowed for automatic variable '%s' in reentrant function\n" },
70 { ERROR ,"error *** absolute address not allowed for automatic var '%s' in reentrant function \n" },
71 { WARNING,"warning *** Initializer different levels of indirections\n" },
72 { ERROR ,"error *** Function name '%s' redefined \n" },
73 { ERROR ,"error *** Undefined identifier '%s'\n" },
74 { WARNING,"warning *** stack exceeds 256 bytes for function '%s'\n"},
75 { ERROR ,"error *** Array or pointer required for '%s' operation \n" },
76 { ERROR ,"error *** Array index not an integer\n" },
77 { ERROR ,"error *** Array bound Exceeded, assuming zero\n" },
78 { ERROR ,"error *** Structure/Union expected left of '.%s'\n" },
79 { ERROR ,"error *** '%s' not a structure/union member\n" },
80 { ERROR ,"error *** Pointer required\n" },
81 { ERROR ,"error *** 'unary %c': illegal operand\n" },
82 { ERROR ,"error *** convertion error: integral promotion failed\n" },
83 { ERROR ,"error *** type must be INT for bit field definition\n" },
84 { ERROR ,"error *** bit field size greater than 16 . assuming 16\n" },
85 { WARNING,"warning *** high order truncation might occur\n" },
86 { ERROR ,"error *** Attempt to assign value to a constant variable %s\n" },
87 { ERROR ,"error *** Lvalue specifies constant object\n" },
88 { ERROR ,"error *** '&' illegal operand , %s\n" },
89 { ERROR ,"error *** illegal cast (cast cannot be aggregate)\n" },
90 { ERROR ,"error *** '*' bad operand\n" },
91 { ERROR ,"error *** Argument count error, argument ignored\n" },
92 { ERROR ,"error *** Function was expecting more arguments\n" },
93 { ERROR ,"error *** Function name expected '%s'.ANSI style declaration REQUIRED\n"},
94 { ERROR ,"error *** invalid operand '%s'\n" },
95 { ERROR ,"error *** pointer + pointer invalid\n" },
96 { ERROR ,"error *** invalid operand for shift operator\n" },
97 { ERROR ,"error *** compare operand cannot be struct/union\n" },
98 { ERROR ,"error *** operand invalid for bitwise operation\n" },
99 { ERROR ,"error *** Invalid operand for '&&' or '||'\n" },
100 { WARNING,"warning *** indirections to different types %s %s \n" },
101 { ERROR ,"error *** cannot assign values to aggregates\n" },
102 { ERROR ,"error *** bit Arrays can be accessed by literal index only\n" },
103 { ERROR ,"error *** Array or Pointer to bit|sbit|sfr not allowed.'%s'\n" },
104 { ERROR ,"error *** typedef/enum '%s' duplicate.Previous definiton Ignored\n" },
105 { ERROR ,"error *** Actual Argument type different from declaration %d\n" },
106 { ERROR ,"error *** Function return value mismatch\n" },
107 { ERROR ,"error *** Function cannot return aggregate. Func body ignored\n" },
108 { ERROR ,"error *** ANSI Style declaration needed\n" },
109 { ERROR ,"error *** Label name redefined '%s'\n" },
110 { ERROR ,"error *** Label undefined '%s'\n" },
111 { ERROR ,"error *** void function returning value\n" },
112 { ERROR ,"error *** function '%s' must return value\n" },
113 { WARNING,"warning *** function return value mismatch\n" },
114 { ERROR ,"error *** 'case/default' found without 'switch'.statement ignored\n" },
115 { ERROR ,"error *** 'case' expression not constant. statement ignored\n" },
116 { ERROR ,"error *** 'break/continue' statement out of context\n" },
117 { ERROR ,"error *** nonintegral used in switch expression\n" },
118 { ERROR ,"error *** function '%s' already has body\n" },
119 { ERROR ,"error *** attempt to allocate variable of unknown size '%s'\n" },
120 { ERROR ,"error *** aggregate 'auto' variable '%s' cannot be initialized\n" },
121 { ERROR ,"error *** too many initializers\n" },
122 { ERROR ,"error *** struct/union/array '%s' :initialization needs curly braces\n"},
123 { ERROR ,"error *** non-address initialization expression\n" },
124 { ERROR ,"error *** interrupt no '%d' already has a service routine '%s'\n" },
125 { ERROR ,"error *** interrupt routine cannot have arguments, arguments ingored\n"},
126 { ERROR ,"error *** critical compiler #include file missing. \n" },
127 { ERROR ,"error *** function 'main' undefined\n" },
128 { ERROR ,"error *** 'extern' variable '%s' cannot be initialised \n" },
129 { ERROR ,"error *** Pre-Processor %s\n" },
130 { ERROR ,"error *** _dup call failed\n" },
131 { WARNING,"warning *** pointer being cast to incompatible type \n" },
132 { WARNING,"warning *** 'while' loop with 'zero' constant.loop eliminated\n" },
133 { WARNING,"warning *** %s expression has NO side effects.expr eliminated\n" },
134 { PEDANTIC,"warning *** constant value '%s', out of range.\n" },
135 { WARNING,"warning *** comparison will either, ALWAYs succeed or ALWAYs fail\n" },
136 { ERROR ,"error *** Compiler Terminating , contact author with source\n" },
137 { WARNING,"warning *** 'auto' variable '%s' may be used before initialization at %s(%d)\n" },
138 { WARNING,"warning *** in function %s unreferenced %s : '%s'\n" },
139 { ERROR ,"error *** unknown size for operand\n" },
140 { WARNING,"warning *** '%s' 'long' not supported , declared as 'int' .\n" },
141 { WARNING,"warning *** LITERAL value being cast to '_generic' pointer\n" },
142 { ERROR ,"error *** %s '%s' address out of range\n" },
143 { ERROR ,"error *** storage class CANNOT be specified for bit variable '%s'\n" },
144 { WARNING,"warning *** extern definition for '%s' mismatches with declaration.\n" },
145 { WARNING,"warning *** Functions called via pointers must be 'reentrant' to take arguments\n" },
146 { WARNING,"warning *** type 'double' not supported assuming 'float'\n" },
147 { WARNING,"warning *** if-statement condition always false.if-statement not generated\n"},
148 { WARNING,"warning *** no 'return' statement found for function '%s'\n" },
149 { WARNING,"warning *** Pre-Processor %s\n" },
150 { WARNING,"warning *** structure '%s' passed as function argument changed to pointer\n"},
151 { ERROR ,"error *** conflict with previous definition of '%s' for attribute '%s'\n" },
152 { ERROR ,"error *** variable '%s' declared in code space must have initialiser\n" },
153 { ERROR ,"error *** operands not integral for assignment operation\n" },
154 { ERROR ,"error *** too many parameters \n" },
155 { ERROR ,"error *** too few parameters\n" },
156 { ERROR ,"error *** code not generated for '%s' due to previous errors\n"},
157 { WARNING,"warning *** type mismatch for parameter number %d\n"},
158 { ERROR ,"error *** invalid float constant '%s'\n"},
159 { ERROR ,"error *** invalid operand for '%s' operation\n"},
160 { ERROR ,"error *** switch value not an integer\n"},
161 { ERROR ,"error *** case label not an integer\n"},
162 { WARNING,"warning *** function '%s' too large for global optimization\n"},
163 { PEDANTIC,"warning *** conditional flow changed by optimizer '%s(%d)':so said EVELYN the modified DOG\n"},
164 { WARNING,"warning *** invalid type specifier for pointer type specifier ignored\n"},
165 { WARNING,"warning *** function '%s' implicit declaration\n"},
166 { WARNING,"warning *** %s"},
167 { WARNING,"info *** %s extended by %d bytes for compiler temp(s) :in function '%s': %s \n"},
168 { WARNING,"warning *** unknown or unsupported #pragma directive '%s'\n"},
169 { PEDANTIC, "warning *** %s shifting more than size of object changed to zero\n"},
170 { WARNING,"warning *** unknown compiler option '%s' ignored\n"},
171 { WARNING,"warning *** option '%s' no longer supported '%s' \n"},
172 { WARNING,"warning *** don't know what to do with file '%s'. file extension unsupported\n"},
173 { WARNING,"warning *** cannot compile more than one source file . file '%s' ignored\n"},
174 { WARNING,"info *** function '%s', # edges %d , # nodes %d , cyclomatic complexity %d\n"},
175 { ERROR ,"error *** dividing by ZERO\n"},
176 { ERROR ,"error *** function cannot return 'bit'\n"},
177 { ERROR ,"error *** casting from to type 'void' is illegal\n"},
178 { WARNING,"warning *** constant is out of range %s\n" },
179 { PEDANTIC,"warning *** unreachable code %s(%d)\n"},
180 { WARNING,"warning *** non-pointer type cast to _generic pointer\n"},
181 { WARNING,"warning *** possible code generation error at line %d,\n send source to sandeep.dutta@usa.net\n"},
182 { WARNING,"warning *** pointer types incompatible \n" },
183 { WARNING,"warning *** unknown memory model at %s : %d\n" },
184 { ERROR ,"error *** cannot generate code for target '%s'\n"},
185 { WARNING,"warning *** Indirect call to a banked function not implemented.\n"},
186 { WARNING,"warning *** Model '%s' not supported for %s, ignored.\n"},
187 { WARNING,"warning *** Both banked and nonbanked attributes used. nonbanked wins.\n"},
188 { WARNING,"warning *** Both banked and static used. static wins.\n"},
189 { WARNING,"warning *** converting integer type to generic pointer: assuming XDATA\n"},
190 { WARNING,"warning *** escape sequence out of range for char.\n"},
191 { ERROR ,"error *** \\x used with no following hex digits.\n"}
194 -------------------------------------------------------------------------------
195 SetErrorOut - Set the error output file
197 -------------------------------------------------------------------------------
200 FILE *SetErrorOut(FILE *NewErrorOut)
203 _SDCCERRG.out = NewErrorOut ;
209 setErrorLogLevel (ERROR_LOG_LEVEL level)
211 _SDCCERRG.logLevel = level;
215 -------------------------------------------------------------------------------
216 vwerror - Output a standard eror message with variable number of arguements
218 -------------------------------------------------------------------------------
221 void vwerror (int errNum, va_list marker)
223 if (_SDCCERRG.out == NULL) {
224 _SDCCERRG.out = DEFAULT_ERROR_OUT;
227 if (ErrTab[errNum].errType >= _SDCCERRG.logLevel) {
228 if ( ErrTab[errNum].errType == ERROR )
231 if ( filename && lineno ) {
232 fprintf(_SDCCERRG.out, "%s(%d):",filename,lineno);
234 fprintf(_SDCCERRG.out, "at %d:", lineno);
237 vfprintf(_SDCCERRG.out, ErrTab[errNum].errText,marker);
240 // Below the logging level, drop.
244 -------------------------------------------------------------------------------
245 werror - Output a standard eror message with variable number of arguements
247 -------------------------------------------------------------------------------
250 void werror (int errNum, ... )
253 va_start(marker,errNum);
254 vwerror(errNum, marker);