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