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