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