]> andersk Git - splint.git/blob - src/Headers/llerror.h
Added htmlfileformat flag.
[splint.git] / src / Headers / llerror.h
1 /*
2 ** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2001.
3 ** See ../LICENSE for license information.
4 **
5 */
6
7 # ifndef LLERROR_H
8 # define LLERROR_H
9
10 extern bool /*@alt void@*/ check (bool p_x);
11 # define check(p_x)  doCheck (p_x, cstring_fromChars (#p_x), cstring_makeLiteralTemp (__FILE__), __LINE__)
12
13 extern bool doCheck (bool p_x, cstring p_pred, cstring p_file, int p_line);
14
15 extern /*@noreturnwhenfalse@*/ void llassert (/*@sef@*/ bool p_test);
16 /*@-macroredef@*/
17 # define llassert(tst) \
18     do { if (!(tst)) { \
19            if (context_getFlag (FLG_TRYTORECOVER)) checkParseError (); \
20            lldiagmsg (message ("%s:%d: at source point", \
21                                cstring_makeLiteralTemp (__FILE__), __LINE__)); \
22            llbuglit ("llassert failed: " #tst); \
23        }} while (FALSE)
24 /*@=macroredef@*/
25
26 extern /*@noreturnwhenfalse@*/ void llassertretnull (/*@sef@*/ bool p_test);
27 # define llassertretnull(tst) \
28     do { if (!(tst)) { \
29            if (context_getFlag (FLG_TRYTORECOVER)) checkParseError (); \
30            lldiagmsg (message ("%s:%d: at source point", \
31                                cstring_makeLiteralTemp (__FILE__), __LINE__)); \
32            llbuglit ("llassert failed: " #tst); \
33        }} while (FALSE)
34
35 typedef void *tx_voidptr;
36
37 extern /*@noreturnwhenfalse@*/ void 
38 llassertretval (/*@sef@*/ bool p_test, /*@sef@*/ /*@null@*/ tx_voidptr /*@alt anytype@*/ p_val); 
39 # define llassertretval(tst,val) \
40     do { if (!(tst)) { \
41            if (context_getFlag (FLG_TRYTORECOVER)) checkParseError (); \
42            lldiagmsg (message ("%s:%d: at source point", \
43                                cstring_makeLiteralTemp (__FILE__), __LINE__)); \
44            llbuglit ("llassert failed: " #tst); \
45            /*@-type@*/ return (val); /*@=type@*/ \
46        }} while (FALSE)
47
48 /*
49 ** Use this for assertions in error-generation code (that
50 ** might lead to infinite loops of failed assertions if
51 ** the normal error generation routines are used).
52 */
53
54 extern /*@noreturnwhenfalse@*/ void llassertprotect (/*@sef@*/ bool p_test);
55 # define llassertprotect(tst) \
56     do { if (!(tst)) { \
57            fprintf (stderr, "%s:%d: at source point: ", __FILE__, __LINE__); \
58            fprintf (stderr, "protected fatal llassert failed: " #tst "\n"); \
59            llexit (EXIT_FAILURE); \
60        }} while (FALSE)
61
62 extern /*@noreturnwhenfalse@*/ void llassertfatal (/*@sef@*/ bool p_test);
63 # define llassertfatal(tst) \
64     do { if (!(tst)) \
65            llfatalbug (message("%s:%d: fatal llassert failed: " #tst, \
66                                cstring_makeLiteralTemp (__FILE__), __LINE__)); \
67        } while (FALSE)
68
69 /*
70 ** llassertprint and llassertprintret are in splintMacros.nf
71 */
72
73 extern void llmsg (/*@only@*/ cstring p_s) /*@modifies g_warningstream@*/ ;
74
75 extern void lldiagmsg (/*@only@*/ cstring p_s) /*@modifies stderr@*/ ;
76 extern void llmsgplain (/*@only@*/ cstring p_s) /*@modifies g_warningstream@*/ ;
77 extern void llhint (/*@only@*/ cstring p_s) 
78    /*@globals g_currentloc, g_warningstream;@*/ 
79    /*@modifies g_warningstream@*/ ;
80
81 extern /*@private@*/ /*@noreturn@*/ void 
82 xllfatalbug (char *p_srcFile, int p_srcLine, /*@only@*/ cstring p_s) 
83    /*@globals g_currentloc@*/
84    /*@modifies g_errorstream@*/ ;
85
86 extern /*@noreturn@*/ void llfatalbug (/*@only@*/ cstring p_s) 
87    /*@globals g_currentloc@*/
88    /*@modifies g_errorstream@*/ ;
89
90 # define llfatalbug(p_s) \
91      xllfatalbug (__FILE__, __LINE__, p_s)
92
93 extern /*@private@*/ bool xllgenerror (char *p_srcFile, int p_srcLine, flagcode p_o,
94                                        /*@only@*/ cstring p_s, fileloc p_fl)
95      /*@modifies g_warningstream@*/ ;
96
97 extern bool llgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_fl) 
98      /*@modifies g_warningstream@*/ ;
99 # define llgenerror(p_o, p_s, p_fl) \
100      xllgenerror (__FILE__, __LINE__, p_o, p_s, p_fl)
101
102 extern /*@private@*/ bool 
103    xllgenhinterror (char *p_srcFile, int p_srcLine,
104                     flagcode p_o, /*@only@*/ cstring p_s, /*@only@*/ cstring p_hint, 
105                     fileloc p_fl) 
106      /*@modifies g_warningstream@*/ ;
107
108 extern bool llgenhinterror (flagcode p_o, /*@only@*/ cstring p_s, /*@only@*/ cstring p_hint, 
109                             fileloc p_fl) /*@modifies g_warningstream@*/ ;
110
111 # define llgenhinterror(p_o, p_s, p_hint, p_fl) \
112      xllgenhinterror (__FILE__, __LINE__, p_o, p_s, p_hint, p_fl)
113
114
115 extern void llerror (flagcode p_o, /*@only@*/ cstring p_s) 
116    /*@globals g_warningstream, g_currentloc@*/ 
117    /*@modifies g_warningstream@*/ ;
118 # define llerror(p_o, p_s) \
119    ((void) llgenerror (p_o, p_s, g_currentloc))
120
121 extern void llgenmsg (/*@only@*/ cstring p_s, fileloc p_fl)
122    /*@modifies g_warningstream@*/ ;
123
124 extern /*@noreturn@*/ /*@private@*/ 
125 void xllfatalerror (char *p_srcFile, int p_srcLine, /*@only@*/ cstring p_s) 
126    /*@modifies g_errorstream@*/ ;
127
128 extern /*@noreturn@*/ void llfatalerror (/*@only@*/ cstring p_s) 
129    /*@modifies g_errorstream@*/ ;
130 # define llfatalerror(p_s) xllfatalerror (__FILE__, __LINE__, p_s)
131
132 extern /*@noreturn@*/ /*@private@*/ void 
133 xllfatalerrorLoc (char *p_srcFile, int p_srcLine, /*@only@*/ cstring p_s) 
134    /*@globals g_currentloc@*/ 
135    /*@modifies g_errorstream@*/ ;
136
137 extern /*@noreturn@*/ void llfatalerrorLoc (/*@only@*/ cstring p_s) 
138    /*@globals g_currentloc@*/ 
139    /*@modifies g_errorstream@*/ ;
140 # define llfatalerrorLoc(p_s) xllfatalerrorLoc (__FILE__, __LINE__, p_s)
141
142 extern /*@private@*/ void
143    xllparseerror (char *p_srcFile, int p_srcLine, /*@only@*/ cstring p_s)
144    /*@modifies g_warningstream@*/ ;
145
146 extern void llparseerror (/*@only@*/ cstring p_s) 
147    /*@globals g_currentloc@*/ ;
148 # define llparseerror(p_s) xllparseerror (__FILE__, __LINE__, p_s)
149 # ifndef NOLCL
150 extern /*@noreturn@*/ void lclplainfatalerror (/*@only@*/ cstring p_msg) /*@modifies g_warningstream@*/ ;
151 extern /*@noreturn@*/ void lclfatalbug (/*@temp@*/ char *p_msg) /*@modifies g_warningstream@*/ ;
152 extern int lclNumberErrors (void) /*@*/ ;
153 extern bool lclHadNewError (void) /*@modifies internalState@*/ ;
154 extern /*@noreturn@*/ void lclfatalerror (ltoken p_t, /*@only@*/ cstring p_msg);
155
156 extern void xlclerror (char *p_srcFile, int p_srcLine, ltoken p_t, /*@only@*/ cstring p_msg) ;
157
158 extern void lclerror (ltoken p_t, /*@only@*/ cstring p_msg);
159 # define lclerror(p_t,p_msg) \
160    xlclerror (__FILE__, __LINE__, p_t, p_msg)
161
162 extern void lclbug (/*@only@*/ cstring p_s);
163 extern void lclplainerror (/*@only@*/ cstring p_msg);
164 extern bool lclHadError (void);
165 extern void lclRedeclarationError (ltoken p_id);
166 # endif
167
168 extern void llerror_flagWarning (/*@only@*/ cstring p_s) /*@modifies g_warningstream@*/ ;
169
170 extern /*@noreturn@*/ void llbugaux (cstring p_file, int p_line, /*@only@*/ cstring p_s) 
171    /*@globals g_warningstream, g_currentloc@*/
172    /*@modifies *g_warningstream@*/ ; 
173
174 extern /*@noreturn@*/ void llbug (/*@only@*/ cstring p_s) 
175    /*@globals g_warningstream, g_currentloc@*/
176    /*@modifies *g_warningstream@*/ ; 
177
178    /* doesn't really exit, but don't mind errors if it doesn't */
179 # define llbug(s) llbugaux (cstring_makeLiteralTemp (__FILE__), __LINE__, s)
180
181 extern void llquietbugaux (/*@only@*/ cstring p_s, cstring, int) /*@modifies *g_warningstream@*/ ; 
182 extern void llquietbug (/*@only@*/ cstring) /*@modifies *g_warningstream@*/ ; 
183 # define llquietbug(s) llquietbugaux (s, cstring_makeLiteralTemp (__FILE__), __LINE__)
184
185 extern void llcontbug (/*@only@*/ cstring p_s) /*@modifies *g_warningstream@*/ ; 
186        /* doesn't really exit, but don't mind errors if it doesn't */
187 # define llcontbug(s)  (llbug (s))
188
189 extern void cleanupMessages (void) 
190    /*@globals g_warningstream, g_currentloc;@*/
191    /*@modifies g_warningstream, internalState@*/ ;
192
193 extern void displayScan (/*@only@*/ cstring p_msg)
194   /*@modifies g_messagestream@*/ ;
195
196 extern void displayScanOpen (/*@only@*/ cstring p_msg)
197   /*@modifies g_messagestream@*/ ;
198
199 extern void displayScanContinue (/*@temp@*/ cstring p_msg)
200   /*@modifies g_messagestream@*/ ;
201
202 extern void displayScanClose (void)
203   /*@modifies g_messagestream@*/ ;
204
205 /*
206 ** Report error iff f1 and f2 are set.
207 */
208
209 extern bool 
210 xoptgenerror2 (char *p_srcFile, int p_srcLine,
211                flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
212   /*@modifies *g_warningstream, internalState@*/ ;
213
214 extern bool 
215 optgenerror2 (flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
216   /*@modifies *g_warningstream, internalState@*/ ;
217 # define optgenerror2(p_f1, p_f2, p_s, p_loc) \
218   (xoptgenerror2 (__FILE__, __LINE__, p_f1, p_f2, p_s, p_loc))
219
220 /*
221 ** Report error if f1 is set and f2 is not set.
222 */
223
224 extern bool 
225 xoptgenerror2n (char *p_srcFile, int p_srcLine,
226                 flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
227   /*@modifies *g_warningstream, internalState@*/ ;
228
229 extern bool 
230 optgenerror2n (flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
231   /*@modifies *g_warningstream, internalState@*/ ;
232 # define optgenerror2n(p_f1, p_f2, p_s, p_loc) \
233   (xoptgenerror2n (__FILE__, __LINE__, p_f1, p_f2, p_s, p_loc))
234
235 extern /*@private@*/ bool xlloptgenerror (char *p_srcFile, int p_srcLine, flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
236   /*@modifies *g_warningstream, internalState@*/ ;
237
238 extern bool lloptgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
239   /*@modifies *g_warningstream, internalState@*/ ;
240 # define lloptgenerror(p_o, p_s, p_loc) \
241    (xlloptgenerror (__FILE__, __LINE__, p_o, p_s, p_loc))
242
243 extern bool xllnoptgenerror (char *p_srcFile, int p_srcLine,
244                              flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
245   /*@modifies *g_warningstream, internalState@*/ ;
246
247 extern bool llnoptgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
248   /*@modifies *g_warningstream, internalState@*/ ;
249 # define llnoptgenerror(p_o, p_s, p_loc) \
250    (xllnoptgenerror (__FILE__, __LINE__, p_o, p_s, p_loc))
251
252 extern /*@private@*/ bool 
253    xllgenformattypeerror (char *p_srcFile, int p_srcLine,
254                           ctype p_t1, exprNode p_e1, 
255                           ctype p_t2, exprNode p_e2,
256                           /*@only@*/ cstring p_s, fileloc p_fl)
257      /*@modifies *g_warningstream, internalState@*/ ;
258
259 extern bool llgenformattypeerror (ctype p_t1, exprNode p_e1, 
260                                   ctype p_t2, exprNode p_e2,
261                                   /*@only@*/ cstring p_s, fileloc p_fl)
262   /*@modifies *g_warningstream, internalState@*/ ;
263 # define llgenformattypeerror(p_t1, p_e1, p_t2, p_e2, p_s, p_fl) \
264   xllgenformattypeerror (__FILE__, __LINE__, p_t1, p_e1, p_t2, p_e2, p_s, p_fl)
265
266 extern bool xllgentypeerror (char *p_srcFile, int p_srcLine,
267                              ctype p_t1, exprNode p_e1,
268                              ctype p_t2, exprNode p_e2,
269                              /*@only@*/ cstring p_s,
270                              fileloc p_fl)
271   /*@modifies *g_warningstream, internalState@*/ ;
272
273 extern bool llgentypeerror (ctype p_t1, exprNode p_e1,
274                             ctype p_t2, exprNode p_e2,
275                             /*@only@*/ cstring p_s,
276                             fileloc p_fl)
277   /*@modifies *g_warningstream, internalState@*/ ;
278 # define llgentypeerror(p_t1, p_e1, p_t2, p_e2, p_s, p_fl) \
279   xllgentypeerror (__FILE__, __LINE__, p_t1, p_e1, p_t2, p_e2, p_s, p_fl)
280
281 extern bool gentypeerror (/*@sef@*/ ctype p_t1, 
282                           /*@sef@*/ exprNode p_e1,
283                           /*@sef@*/ ctype p_t2, 
284                           /*@sef@*/ exprNode p_e2,
285                           /*@sef@*/ /*@only@*/ cstring p_s,
286                           /*@sef@*/ fileloc p_loc)
287   /*@modifies *g_warningstream, internalState@*/ ;
288
289 /*@-branchstate@*/ /* sef only s is freed on one branch */
290 #define gentypeerror(t1, e1, t2, e2, s, loc)      \
291    (context_suppressFlagMsg (FLG_TYPE,loc) \
292     ? (flagcode_recordSuppressed (FLG_TYPE), FALSE) \
293     : llgentypeerror (t1, e1, t2, e2, s, loc))
294 /*@=branchstate@*/
295
296 /*
297 ** These are macros to save evaluating s (which may be some expensive
298 ** message generation function).
299 */
300
301 extern bool 
302   optgenerror (/*@sef@*/ flagcode p_o, /*@sef@*/ /*@only@*/ cstring p_s,
303                /*@sef@*/ fileloc p_loc)
304   /*@modifies *g_warningstream, internalState@*/ ;
305
306 /*@-branchstate@*/ /* sef only s is freed on one branch */
307 #define optgenerror(o,s,loc)      \
308    (context_suppressFlagMsg(o,loc) ? (flagcode_recordSuppressed(o), FALSE) \
309                                      : lloptgenerror (o, s, loc))
310 /*@=branchstate@*/
311
312 extern void 
313   voptgenerror (/*@sef@*/ flagcode p_o, /*@sef@*/ /*@only@*/ cstring p_s, 
314                 /*@sef@*/ fileloc p_loc)
315   /*@modifies *g_warningstream, internalState@*/ ;
316 #define voptgenerror(o, s, loc)   ((void) optgenerror(o,s,loc))
317
318 extern /*@private@*/ bool 
319   xfsgenerror (char *p_srcFile, int p_srcLine,
320                 flagSpec p_fs, /*@only@*/ cstring p_s, fileloc p_fl) 
321      /*@modifies g_warningstream, internalState@*/ ;
322
323 extern bool fsgenerror (flagSpec p_fs, /*@only@*/ cstring p_s, fileloc p_fl) 
324      /*@modifies g_warningstream, internalState@*/ ;
325 # define fsgenerror(p_fs, p_s, p_fl) \
326      xfsgenerror (__FILE__, __LINE__, p_fs, p_s, p_fl)
327
328 extern void 
329 vfsgenerror (/*@sef@*/ flagSpec p_fs, /*@sef@*/ /*@only@*/ cstring p_s, 
330              /*@sef@*/ fileloc p_loc)
331      /*@modifies *g_warningstream, internalState@*/ ;
332 #define vfsgenerror(fs, s, loc)   ((void) fsgenerror(fs,s,loc))
333
334 /*
335 ** Reports a warning when f1 is ON and f2 is ON
336 */
337
338 extern void 
339   voptgenerror2 (/*@sef@*/ flagcode p_f1, /*@sef@*/ flagcode p_f2, 
340                   /*@sef@*/ /*@only@*/ cstring p_s, /*@sef@*/ fileloc p_loc);
341 #define voptgenerror2(f1, f2, s, loc)   ((void) optgenerror2 (f1, f2, s, loc))
342
343 /*
344 ** Reports a warning when f1 is ON and f2 is OFF
345 */
346
347 extern void 
348   voptgenerror2n (/*@sef@*/ flagcode p_f1, /*@sef@*/ flagcode p_f2, 
349                   /*@sef@*/ /*@only@*/ cstring p_s, /*@sef@*/ fileloc p_loc);
350 #define voptgenerror2n(f1, f2, s, loc)   ((void) optgenerror2n (f1, f2, s, loc))
351
352 extern void noptgenerror (/*@sef@*/ flagcode p_code, 
353                           /*@sef@*/ /*@only@*/ cstring p_s,
354                           /*@sef@*/ fileloc p_loc);
355 /*@-branchstate@*/ /* sef only s is freed on one branch */
356 #define noptgenerror(o,s,loc)     \
357    (context_suppressNotFlagMsg (o, loc) \
358     ? (flagcode_recordSuppressed(o), FALSE) \
359     : llnoptgenerror (o, s, loc))
360 /*@=branchstate@*/
361
362 extern void 
363   vnoptgenerror (/*@sef@*/ flagcode p_code, /*@sef@*/ /*@only@*/ cstring p_msg,
364                  /*@sef@*/ fileloc p_loc);
365 # define vnoptgenerror(o, s, loc) ((void) noptgenerror(o, s, loc))
366
367 extern void 
368   vgenhinterror (flagcode p_code, /*@only@*/ cstring p_mst,
369                  /*@only@*/ cstring p_hint, /*@sef@*/ fileloc p_loc);
370 # define vgenhinterror(o, s, h, loc) \
371     ((void) llgenhinterror(o, s, h, loc))
372
373
374 extern /*@private@*/ bool /*@alt void@*/ xllforceerror (char *p_srcFile, int p_srcLine, flagcode p_code, /*@only@*/ cstring p_s, fileloc p_fl) 
375      /*@modifies g_warningstream@*/ ; 
376
377 extern bool /*@alt void@*/ llforceerror (flagcode p_code, /*@only@*/ cstring p_s, fileloc p_fl) 
378      /*@modifies g_warningstream@*/ ; 
379 # define llforceerror(p_code, p_s, p_fl) \
380      (xllforceerror (__FILE__, __LINE__, p_code, p_s, p_fl))
381
382 extern /*@private@*/ bool xcppoptgenerror (char *p_srcFile, int p_srcLine, flagcode p_o,
383                              /*@only@*/ cstring p_s, cppReader *p_pfile)
384      /*@modifies g_warningstream, p_pfile@*/ ;
385
386 extern bool /*@alt void@*/
387 cppoptgenerror (flagcode p_code, /*@only@*/ cstring p_s, cppReader *p_pfile)
388      /*@modifies g_warningstream, p_pfile@*/ ;
389 # define cppoptgenerror(p_code, p_s, p_pfile) \
390     (xcppoptgenerror (__FILE__, __LINE__, p_code, p_s, p_pfile))
391
392 extern void llerrorlit (flagcode p_o, char *p_s);
393 # define llerrorlit(o, s)   ((void) llerror (o, cstring_makeLiteral (s)))
394
395 extern void llgenindentmsg (/*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_warningstream@*/ ;
396
397 extern /*@noreturn@*/ void llbugexitlit (char *p_s);
398 # define llbugexitlit(s)    (llbug (cstring_makeLiteral (s)))
399
400 extern void llbuglit (char *p_s);
401 # define llbuglit(s)        (llbug (cstring_makeLiteral (s)))
402
403 extern void llcontbuglit (char *p_s);
404 # define llcontbuglit(s)    (llbug (cstring_makeLiteral (s)))
405
406 extern void checkParseError (void);
407
408 extern void llmsglit (char *p_s);
409 # define llmsglit(s)        (llmsg (cstring_makeLiteral (s)))
410
411 extern void ppllerror (/*@only@*/ cstring p_s);
412
413 extern void genppllerrorhint (flagcode p_code, /*@only@*/ cstring p_s, 
414                               /*@only@*/ cstring p_hint);
415 extern void genppllerror (flagcode p_code, /*@only@*/ cstring p_s);
416 extern /*@unused@*/ void pplldiagmsg (/*@only@*/ cstring p_s);
417 extern void loadllmsg (/*@only@*/ cstring p_s);
418
419 extern void llgenindentmsgnoloc (/*@only@*/ cstring p_s);
420
421 extern /*@observer@*/ cstring lldecodeerror (int) /*@*/ ;
422
423 /*@i523@*/
424 /*
425 ** should be static, but used in cpperror (which shouldn't exist)
426 */
427
428 extern void prepareMessage (void)
429   /*@modifies internalState, g_messagestream@*/ ;
430
431 extern void closeMessage (void)
432   /*@modifies internalState, g_messagestream@*/ ;
433
434 extern void llflush (void) /*@modifies systemState@*/ ;
435
436 # else
437 # error "Multiple include"
438 # endif
439
This page took 0.097783 seconds and 5 git commands to generate.