]> andersk Git - splint.git/blame - src/Headers/llerror.h
Merged code tree with Dave Evans's version. Many changes to numberous to list....
[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
80extern /*@private@*/ void xllgloberror (char *p_srcFile, int p_srcLine,
81 /*@only@*/ cstring p_s)
82 /*@modifies g_msgstream@*/ ;
83
885824d3 84extern void llgloberror (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ;
28bf4b0b 85# define llgloberror(p_s) \
86 xllgloberror (__FILE__, __LINE__, p_s)
87
88extern /*@private@*/ bool xllgenerror (char *p_srcFile, int p_srcLine, flagcode p_o,
89 /*@only@*/ cstring p_s, fileloc p_fl)
90 /*@modifies g_msgstream@*/ ;
91
92extern bool llgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_fl)
93 /*@modifies g_msgstream@*/ ;
94# define llgenerror(p_o, p_s, p_fl) \
95 xllgenerror (__FILE__, __LINE__, p_o, p_s, p_fl)
96
97extern /*@private@*/ bool
98 xllgenhinterror (char *p_srcFile, int p_srcLine,
99 flagcode p_o, /*@only@*/ cstring p_s, /*@only@*/ cstring p_hint,
100 fileloc p_fl)
101 /*@modifies g_msgstream@*/ ;
102
885824d3 103extern bool llgenhinterror (flagcode p_o, /*@only@*/ cstring p_s, /*@only@*/ cstring p_hint,
104 fileloc p_fl) /*@modifies g_msgstream@*/ ;
28bf4b0b 105
106# define llgenhinterror(p_o, p_s, p_hint, p_fl) \
107 xllgenhinterror (__FILE__, __LINE__, p_o, p_s, p_hint, p_fl)
108
109
885824d3 110extern void llerror (flagcode p_o, /*@only@*/ cstring p_s)
111 /*@globals g_msgstream, g_currentloc@*/
112 /*@modifies g_msgstream@*/ ;
28bf4b0b 113# define llerror(p_o, p_s) \
114 ((void) llgenerror (p_o, p_s, g_currentloc))
115
885824d3 116extern void llgenmsg (/*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_msgstream@*/ ;
117extern /*@exits@*/ void llfatalerror (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ;
118extern /*@exits@*/ void llfatalerrorLoc (/*@only@*/ cstring p_s)
119 /*@globals g_currentloc@*/
120 /*@modifies stderr@*/ ;
121extern void llparseerror (/*@only@*/ cstring p_s)
122 /*@globals g_msgstream, g_currentloc@*/
123 /*@modifies g_msgstream@*/ ;
124
125# ifndef NOLCL
126extern /*@exits@*/ void lclplainfatalerror (/*@only@*/ cstring p_msg) /*@modifies g_msgstream@*/ ;
127extern /*@exits@*/ void lclfatalbug (/*@temp@*/ char *p_msg) /*@modifies g_msgstream@*/ ;
128extern int lclNumberErrors (void) /*@*/ ;
129extern bool lclHadNewError (void) /*@modifies internalState@*/ ;
130extern /*@exits@*/ void lclfatalerror (ltoken p_t, /*@only@*/ cstring p_msg);
28bf4b0b 131
132extern void xlclerror (char *p_srcFile, int p_srcLine, ltoken p_t, /*@only@*/ cstring p_msg) ;
133
885824d3 134extern void lclerror (ltoken p_t, /*@only@*/ cstring p_msg);
28bf4b0b 135# define lclerror(p_t,p_msg) \
136 xlclerror (__FILE__, __LINE__, p_t, p_msg)
885824d3 137
138extern void lclbug (/*@only@*/ cstring p_s);
139extern void lclplainerror (/*@only@*/ cstring p_msg);
140extern bool lclHadError (void);
141extern void lclRedeclarationError (ltoken p_id);
142# endif
143
144extern void flagWarning (/*@observer@*/ cstring p_s) /*@modifies g_msgstream@*/ ;
145
146extern /*@exits@*/ void llbugaux (cstring p_file, int p_line, /*@only@*/ cstring p_s)
147 /*@globals g_msgstream, g_currentloc@*/
148 /*@modifies *g_msgstream@*/ ;
149
150extern /*@exits@*/ void llbug (/*@only@*/ cstring p_s)
151 /*@globals g_msgstream, g_currentloc@*/
152 /*@modifies *g_msgstream@*/ ;
153
154 /* doesn't really exit, but don't mind errors if it doesn't */
155# define llbug(s) llbugaux (cstring_makeLiteralTemp (__FILE__), __LINE__, s)
156
157extern void llquietbugaux (/*@only@*/ cstring p_s, cstring, int) /*@modifies *g_msgstream@*/ ;
158extern void llquietbug (/*@only@*/ cstring) /*@modifies *g_msgstream@*/ ;
159# define llquietbug(s) llquietbugaux (s, cstring_makeLiteralTemp (__FILE__), __LINE__)
160
161extern void llcontbug (/*@only@*/ cstring p_s) /*@modifies *g_msgstream@*/ ;
162 /* doesn't really exit, but don't mind errors if it doesn't */
163# define llcontbug(s) (llbug (s))
164
165extern void cleanupMessages (void)
166 /*@globals g_msgstream, g_currentloc;@*/
167 /*@modifies g_msgstream, internalState@*/ ;
168
169/*
170** Report error iff f1 and f2 are set.
171*/
172
28bf4b0b 173extern bool
174xoptgenerror2 (char *p_srcFile, int p_srcLine,
175 flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
176 /*@modifies *g_msgstream, internalState@*/ ;
177
885824d3 178extern bool
179optgenerror2 (flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
180 /*@modifies *g_msgstream, internalState@*/ ;
28bf4b0b 181# define optgenerror2(p_f1, p_f2, p_s, p_loc) \
182 (xoptgenerror2 (__FILE__, __LINE__, p_f1, p_f2, p_s, p_loc))
885824d3 183
184/*
185** Report error if f1 is set and f2 is not set.
186*/
187
28bf4b0b 188extern bool
189xoptgenerror2n (char *p_srcFile, int p_srcLine,
190 flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
191 /*@modifies *g_msgstream, internalState@*/ ;
192
885824d3 193extern bool
194optgenerror2n (flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
195 /*@modifies *g_msgstream, internalState@*/ ;
28bf4b0b 196# define optgenerror2n(p_f1, p_f2, p_s, p_loc) \
197 (xoptgenerror2n (__FILE__, __LINE__, p_f1, p_f2, p_s, p_loc))
198
199extern /*@private@*/ bool xlloptgenerror (char *p_srcFile, int p_srcLine, flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
200 /*@modifies *g_msgstream, internalState@*/ ;
885824d3 201
202extern bool lloptgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
203 /*@modifies *g_msgstream, internalState@*/ ;
28bf4b0b 204# define lloptgenerror(p_o, p_s, p_loc) \
205 (xlloptgenerror (__FILE__, __LINE__, p_o, p_s, p_loc))
206
207extern bool xllnoptgenerror (char *p_srcFile, int p_srcLine,
208 flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
209 /*@modifies *g_msgstream, internalState@*/ ;
885824d3 210
211extern bool llnoptgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
212 /*@modifies *g_msgstream, internalState@*/ ;
28bf4b0b 213# define llnoptgenerror(p_o, p_s, p_loc) \
214 (xllnoptgenerror (__FILE__, __LINE__, p_o, p_s, p_loc))
215
216extern /*@private@*/ bool
217 xllgenformattypeerror (char *p_srcFile, int p_srcLine,
218 ctype p_t1, exprNode p_e1,
219 ctype p_t2, exprNode p_e2,
220 /*@only@*/ cstring p_s, fileloc p_fl)
221 /*@modifies *g_msgstream, internalState@*/ ;
885824d3 222
223extern bool llgenformattypeerror (ctype p_t1, exprNode p_e1,
224 ctype p_t2, exprNode p_e2,
225 /*@only@*/ cstring p_s, fileloc p_fl)
226 /*@modifies *g_msgstream, internalState@*/ ;
28bf4b0b 227# define llgenformattypeerror(p_t1, p_e1, p_t2, p_e2, p_s, p_fl) \
228 xllgenformattypeerror (__FILE__, __LINE__, p_t1, p_e1, p_t2, p_e2, p_s, p_fl)
229
230extern bool xllgentypeerror (char *p_srcFile, int p_srcLine,
231 ctype p_t1, exprNode p_e1,
232 ctype p_t2, exprNode p_e2,
233 /*@only@*/ cstring p_s,
234 fileloc p_fl)
235 /*@modifies *g_msgstream, internalState@*/ ;
885824d3 236
237extern bool llgentypeerror (ctype p_t1, exprNode p_e1,
238 ctype p_t2, exprNode p_e2,
239 /*@only@*/ cstring p_s,
240 fileloc p_fl)
241 /*@modifies *g_msgstream, internalState@*/ ;
28bf4b0b 242# define llgentypeerror(p_t1, p_e1, p_t2, p_e2, p_s, p_fl) \
243 xllgentypeerror (__FILE__, __LINE__, p_t1, p_e1, p_t2, p_e2, p_s, p_fl)
885824d3 244
245extern bool gentypeerror (/*@sef@*/ ctype p_t1,
246 /*@sef@*/ exprNode p_e1,
247 /*@sef@*/ ctype p_t2,
248 /*@sef@*/ exprNode p_e2,
249 /*@sef@*/ /*@only@*/ cstring p_s,
250 /*@sef@*/ fileloc p_loc)
251 /*@modifies *g_msgstream, internalState@*/ ;
252
253/*@-branchstate@*/ /* sef only s is freed on one branch */
254#define gentypeerror(t1, e1, t2, e2, s, loc) \
255 (context_suppressFlagMsg (FLG_TYPE,loc) \
256 ? (flagcode_recordSuppressed (FLG_TYPE), FALSE) \
257 : llgentypeerror (t1, e1, t2, e2, s, loc))
258/*@=branchstate@*/
259
260/*
261** These are macros to save evaluating s (which may be some expensive
262** message generation function).
263*/
264
265extern bool
266 optgenerror (/*@sef@*/ flagcode p_o, /*@sef@*/ /*@only@*/ cstring p_s,
267 /*@sef@*/ fileloc p_loc)
268 /*@modifies *g_msgstream, internalState@*/ ;
269
270/*@-branchstate@*/ /* sef only s is freed on one branch */
271#define optgenerror(o,s,loc) \
272 (context_suppressFlagMsg(o,loc) ? (flagcode_recordSuppressed(o), FALSE) \
273 : lloptgenerror (o, s, loc))
274/*@=branchstate@*/
275
276extern void
277 voptgenerror (/*@sef@*/ flagcode p_o, /*@sef@*/ /*@only@*/ cstring p_s,
278 /*@sef@*/ fileloc p_loc)
279 /*@modifies *g_msgstream, internalState@*/ ;
280#define voptgenerror(o, s, loc) ((void) optgenerror(o,s,loc))
281
28bf4b0b 282extern /*@private@*/ bool
283 xfsgenerror (char *p_srcFile, int p_srcLine,
284 flagSpec p_fs, /*@only@*/ cstring p_s, fileloc p_fl)
285 /*@modifies g_msgstream, internalState@*/ ;
286
287extern bool fsgenerror (flagSpec p_fs, /*@only@*/ cstring p_s, fileloc p_fl)
288 /*@modifies g_msgstream, internalState@*/ ;
289# define fsgenerror(p_fs, p_s, p_fl) \
290 xfsgenerror (__FILE__, __LINE__, p_fs, p_s, p_fl)
291
292extern void
293vfsgenerror (/*@sef@*/ flagSpec p_fs, /*@sef@*/ /*@only@*/ cstring p_s,
294 /*@sef@*/ fileloc p_loc)
295 /*@modifies *g_msgstream, internalState@*/ ;
296#define vfsgenerror(fs, s, loc) ((void) fsgenerror(fs,s,loc))
297
298/*
299** Reports a warning when f1 is ON and f2 is ON
300*/
301
885824d3 302extern void
303 voptgenerror2 (/*@sef@*/ flagcode p_f1, /*@sef@*/ flagcode p_f2,
28bf4b0b 304 /*@sef@*/ /*@only@*/ cstring p_s, /*@sef@*/ fileloc p_loc);
885824d3 305#define voptgenerror2(f1, f2, s, loc) ((void) optgenerror2 (f1, f2, s, loc))
306
28bf4b0b 307/*
308** Reports a warning when f1 is ON and f2 is OFF
309*/
310
885824d3 311extern void
312 voptgenerror2n (/*@sef@*/ flagcode p_f1, /*@sef@*/ flagcode p_f2,
313 /*@sef@*/ /*@only@*/ cstring p_s, /*@sef@*/ fileloc p_loc);
314#define voptgenerror2n(f1, f2, s, loc) ((void) optgenerror2n (f1, f2, s, loc))
315
316extern void noptgenerror (/*@sef@*/ flagcode p_code,
317 /*@sef@*/ /*@only@*/ cstring p_s,
318 /*@sef@*/ fileloc p_loc);
319/*@-branchstate@*/ /* sef only s is freed on one branch */
320#define noptgenerror(o,s,loc) \
321 (context_suppressNotFlagMsg (o, loc) \
322 ? (flagcode_recordSuppressed(o), FALSE) \
323 : llnoptgenerror (o, s, loc))
324/*@=branchstate@*/
325
326extern void
327 vnoptgenerror (/*@sef@*/ flagcode p_code, /*@sef@*/ /*@only@*/ cstring p_msg,
328 /*@sef@*/ fileloc p_loc);
329# define vnoptgenerror(o, s, loc) ((void) noptgenerror(o, s, loc))
330
331extern void
332 vgenhinterror (flagcode p_code, /*@only@*/ cstring p_mst,
333 /*@only@*/ cstring p_hint, /*@sef@*/ fileloc p_loc);
334# define vgenhinterror(o, s, h, loc) \
335 ((void) llgenhinterror(o, s, h, loc))
336
28bf4b0b 337
338extern /*@private@*/ bool /*@alt void@*/ xllforceerror (char *p_srcFile, int p_srcLine, flagcode p_code, /*@only@*/ cstring p_s, fileloc p_fl)
339 /*@modifies g_msgstream@*/ ;
340
341extern bool /*@alt void@*/ llforceerror (flagcode p_code, /*@only@*/ cstring p_s, fileloc p_fl)
342 /*@modifies g_msgstream@*/ ;
343# define llforceerror(p_code, p_s, p_fl) \
344 (xllforceerror (__FILE__, __LINE__, p_code, p_s, p_fl))
885824d3 345
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
351extern /*@exits@*/ 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.10591 seconds and 5 git commands to generate.