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