]> andersk Git - splint.git/blob - src/Headers/llerror.h
o Make lltok an abstract type, a pointer to structure instead of a plain
[splint.git] / src / Headers / llerror.h
1 /*
2 ** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2001.
3 ** See ../LICENSE for license information.
4 **
5 */
6
7 # ifndef LLERROR_H
8 # define LLERROR_H
9
10 extern bool /*@alt void@*/ check (bool p_x);
11 # define check(p_x)  doCheck (p_x, cstring_fromChars (#p_x), cstring_makeLiteralTemp (__FILE__), __LINE__)
12
13 extern bool doCheck (bool p_x, cstring p_pred, cstring p_file, int p_line);
14
15 extern /*@noreturnwhenfalse@*/ void llassert (/*@sef@*/ bool p_test);
16 /*@-macroredef@*/
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)
24 /*@=macroredef@*/
25
26 extern /*@noreturnwhenfalse@*/ 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        }} while (FALSE)
34
35 extern /*@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
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
51 extern /*@noreturnwhenfalse@*/ void llassertprotect (/*@sef@*/ bool p_test);
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)
58
59 extern /*@noreturnwhenfalse@*/ void llassertfatal (/*@sef@*/ bool p_test);
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 /*
67 ** llassertprint and llassertprintret are in splintMacros.nf
68 */
69
70 extern void llmsg (/*@only@*/ cstring p_s) /*@modifies g_warningstream@*/ ;
71
72 extern void lldiagmsg (/*@only@*/ cstring p_s) /*@modifies stderr@*/ ;
73 extern void llmsgplain (/*@only@*/ cstring p_s) /*@modifies g_warningstream@*/ ;
74 extern void llhint (/*@only@*/ cstring p_s) 
75    /*@globals g_currentloc, g_warningstream;@*/ 
76    /*@modifies g_warningstream@*/ ;
77
78 extern /*@private@*/ /*@noreturn@*/ void 
79 xllfatalbug (char *p_srcFile, int p_srcLine, /*@only@*/ cstring p_s) 
80    /*@globals g_currentloc@*/
81    /*@modifies g_errorstream@*/ ;
82
83 extern /*@noreturn@*/ void llfatalbug (/*@only@*/ cstring p_s) 
84    /*@globals g_currentloc@*/
85    /*@modifies g_errorstream@*/ ;
86
87 # define llfatalbug(p_s) \
88      xllfatalbug (__FILE__, __LINE__, p_s)
89
90 extern /*@private@*/ bool xllgenerror (char *p_srcFile, int p_srcLine, flagcode p_o,
91                                        /*@only@*/ cstring p_s, fileloc p_fl)
92      /*@modifies g_warningstream@*/ ;
93
94 extern bool llgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_fl) 
95      /*@modifies g_warningstream@*/ ;
96 # define llgenerror(p_o, p_s, p_fl) \
97      xllgenerror (__FILE__, __LINE__, p_o, p_s, p_fl)
98
99 extern /*@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) 
103      /*@modifies g_warningstream@*/ ;
104
105 extern bool llgenhinterror (flagcode p_o, /*@only@*/ cstring p_s, /*@only@*/ cstring p_hint, 
106                             fileloc p_fl) /*@modifies g_warningstream@*/ ;
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
112 extern void llerror (flagcode p_o, /*@only@*/ cstring p_s) 
113    /*@globals g_warningstream, g_currentloc@*/ 
114    /*@modifies g_warningstream@*/ ;
115 # define llerror(p_o, p_s) \
116    ((void) llgenerror (p_o, p_s, g_currentloc))
117
118 extern void llgenmsg (/*@only@*/ cstring p_s, fileloc p_fl)
119    /*@modifies g_warningstream@*/ ;
120
121 extern /*@noreturn@*/ void llfatalerror (/*@only@*/ cstring p_s) 
122    /*@modifies g_errorstream@*/ ;
123
124 extern /*@noreturn@*/ void llfatalerrorLoc (/*@only@*/ cstring p_s) 
125    /*@globals g_currentloc@*/ 
126    /*@modifies g_errorstream@*/ ;
127
128 extern void llparseerror (/*@only@*/ cstring p_s) 
129    /*@globals g_errorstream, g_currentloc@*/ 
130    /*@modifies g_errorstream@*/ ;
131
132 # ifndef NOLCL
133 extern /*@noreturn@*/ void lclplainfatalerror (/*@only@*/ cstring p_msg) /*@modifies g_warningstream@*/ ;
134 extern /*@noreturn@*/ void lclfatalbug (/*@temp@*/ char *p_msg) /*@modifies g_warningstream@*/ ;
135 extern int lclNumberErrors (void) /*@*/ ;
136 extern bool lclHadNewError (void) /*@modifies internalState@*/ ;
137 extern /*@noreturn@*/ void lclfatalerror (ltoken p_t, /*@only@*/ cstring p_msg);
138
139 extern void xlclerror (char *p_srcFile, int p_srcLine, ltoken p_t, /*@only@*/ cstring p_msg) ;
140
141 extern void lclerror (ltoken p_t, /*@only@*/ cstring p_msg);
142 # define lclerror(p_t,p_msg) \
143    xlclerror (__FILE__, __LINE__, p_t, p_msg)
144
145 extern void lclbug (/*@only@*/ cstring p_s);
146 extern void lclplainerror (/*@only@*/ cstring p_msg);
147 extern bool lclHadError (void);
148 extern void lclRedeclarationError (ltoken p_id);
149 # endif
150
151 extern void llerror_flagWarning (/*@only@*/ cstring p_s) /*@modifies g_warningstream@*/ ;
152
153 extern /*@noreturn@*/ void llbugaux (cstring p_file, int p_line, /*@only@*/ cstring p_s) 
154    /*@globals g_warningstream, g_currentloc@*/
155    /*@modifies *g_warningstream@*/ ; 
156
157 extern /*@noreturn@*/ void llbug (/*@only@*/ cstring p_s) 
158    /*@globals g_warningstream, g_currentloc@*/
159    /*@modifies *g_warningstream@*/ ; 
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
164 extern void llquietbugaux (/*@only@*/ cstring p_s, cstring, int) /*@modifies *g_warningstream@*/ ; 
165 extern void llquietbug (/*@only@*/ cstring) /*@modifies *g_warningstream@*/ ; 
166 # define llquietbug(s) llquietbugaux (s, cstring_makeLiteralTemp (__FILE__), __LINE__)
167
168 extern void llcontbug (/*@only@*/ cstring p_s) /*@modifies *g_warningstream@*/ ; 
169        /* doesn't really exit, but don't mind errors if it doesn't */
170 # define llcontbug(s)  (llbug (s))
171
172 extern void cleanupMessages (void) 
173    /*@globals g_warningstream, g_currentloc;@*/
174    /*@modifies g_warningstream, internalState@*/ ;
175
176 extern void displayScan (/*@only@*/ cstring p_msg)
177   /*@modifies g_messagestream@*/ ;
178
179 extern void displayScanOpen (/*@only@*/ cstring p_msg)
180   /*@modifies g_messagestream@*/ ;
181
182 extern void displayScanContinue (/*@temp@*/ cstring p_msg)
183   /*@modifies g_messagestream@*/ ;
184
185 extern void displayScanClose (void)
186   /*@modifies g_messagestream@*/ ;
187
188 /*
189 ** Report error iff f1 and f2 are set.
190 */
191
192 extern bool 
193 xoptgenerror2 (char *p_srcFile, int p_srcLine,
194                flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
195   /*@modifies *g_warningstream, internalState@*/ ;
196
197 extern bool 
198 optgenerror2 (flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
199   /*@modifies *g_warningstream, internalState@*/ ;
200 # define optgenerror2(p_f1, p_f2, p_s, p_loc) \
201   (xoptgenerror2 (__FILE__, __LINE__, p_f1, p_f2, p_s, p_loc))
202
203 /*
204 ** Report error if f1 is set and f2 is not set.
205 */
206
207 extern bool 
208 xoptgenerror2n (char *p_srcFile, int p_srcLine,
209                 flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
210   /*@modifies *g_warningstream, internalState@*/ ;
211
212 extern bool 
213 optgenerror2n (flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
214   /*@modifies *g_warningstream, internalState@*/ ;
215 # define optgenerror2n(p_f1, p_f2, p_s, p_loc) \
216   (xoptgenerror2n (__FILE__, __LINE__, p_f1, p_f2, p_s, p_loc))
217
218 extern /*@private@*/ bool xlloptgenerror (char *p_srcFile, int p_srcLine, flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
219   /*@modifies *g_warningstream, internalState@*/ ;
220
221 extern bool lloptgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
222   /*@modifies *g_warningstream, internalState@*/ ;
223 # define lloptgenerror(p_o, p_s, p_loc) \
224    (xlloptgenerror (__FILE__, __LINE__, p_o, p_s, p_loc))
225
226 extern bool xllnoptgenerror (char *p_srcFile, int p_srcLine,
227                              flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
228   /*@modifies *g_warningstream, internalState@*/ ;
229
230 extern bool llnoptgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
231   /*@modifies *g_warningstream, internalState@*/ ;
232 # define llnoptgenerror(p_o, p_s, p_loc) \
233    (xllnoptgenerror (__FILE__, __LINE__, p_o, p_s, p_loc))
234
235 extern /*@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)
240      /*@modifies *g_warningstream, internalState@*/ ;
241
242 extern bool llgenformattypeerror (ctype p_t1, exprNode p_e1, 
243                                   ctype p_t2, exprNode p_e2,
244                                   /*@only@*/ cstring p_s, fileloc p_fl)
245   /*@modifies *g_warningstream, internalState@*/ ;
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
249 extern 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)
254   /*@modifies *g_warningstream, internalState@*/ ;
255
256 extern bool llgentypeerror (ctype p_t1, exprNode p_e1,
257                             ctype p_t2, exprNode p_e2,
258                             /*@only@*/ cstring p_s,
259                             fileloc p_fl)
260   /*@modifies *g_warningstream, internalState@*/ ;
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)
263
264 extern 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)
270   /*@modifies *g_warningstream, internalState@*/ ;
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
284 extern bool 
285   optgenerror (/*@sef@*/ flagcode p_o, /*@sef@*/ /*@only@*/ cstring p_s,
286                /*@sef@*/ fileloc p_loc)
287   /*@modifies *g_warningstream, internalState@*/ ;
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
295 extern void 
296   voptgenerror (/*@sef@*/ flagcode p_o, /*@sef@*/ /*@only@*/ cstring p_s, 
297                 /*@sef@*/ fileloc p_loc)
298   /*@modifies *g_warningstream, internalState@*/ ;
299 #define voptgenerror(o, s, loc)   ((void) optgenerror(o,s,loc))
300
301 extern /*@private@*/ bool 
302   xfsgenerror (char *p_srcFile, int p_srcLine,
303                 flagSpec p_fs, /*@only@*/ cstring p_s, fileloc p_fl) 
304      /*@modifies g_warningstream, internalState@*/ ;
305
306 extern bool fsgenerror (flagSpec p_fs, /*@only@*/ cstring p_s, fileloc p_fl) 
307      /*@modifies g_warningstream, internalState@*/ ;
308 # define fsgenerror(p_fs, p_s, p_fl) \
309      xfsgenerror (__FILE__, __LINE__, p_fs, p_s, p_fl)
310
311 extern void 
312 vfsgenerror (/*@sef@*/ flagSpec p_fs, /*@sef@*/ /*@only@*/ cstring p_s, 
313              /*@sef@*/ fileloc p_loc)
314      /*@modifies *g_warningstream, internalState@*/ ;
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
321 extern void 
322   voptgenerror2 (/*@sef@*/ flagcode p_f1, /*@sef@*/ flagcode p_f2, 
323                   /*@sef@*/ /*@only@*/ cstring p_s, /*@sef@*/ fileloc p_loc);
324 #define voptgenerror2(f1, f2, s, loc)   ((void) optgenerror2 (f1, f2, s, loc))
325
326 /*
327 ** Reports a warning when f1 is ON and f2 is OFF
328 */
329
330 extern 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
335 extern 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
345 extern 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
350 extern 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
356
357 extern /*@private@*/ bool /*@alt void@*/ xllforceerror (char *p_srcFile, int p_srcLine, flagcode p_code, /*@only@*/ cstring p_s, fileloc p_fl) 
358      /*@modifies g_warningstream@*/ ; 
359
360 extern bool /*@alt void@*/ llforceerror (flagcode p_code, /*@only@*/ cstring p_s, fileloc p_fl) 
361      /*@modifies g_warningstream@*/ ; 
362 # define llforceerror(p_code, p_s, p_fl) \
363      (xllforceerror (__FILE__, __LINE__, p_code, p_s, p_fl))
364
365 extern /*@private@*/ bool xcppoptgenerror (char *p_srcFile, int p_srcLine, flagcode p_o,
366                              /*@only@*/ cstring p_s, cppReader *p_pfile)
367      /*@modifies g_warningstream, p_pfile@*/ ;
368
369 extern bool /*@alt void@*/
370 cppoptgenerror (flagcode p_code, /*@only@*/ cstring p_s, cppReader *p_pfile)
371      /*@modifies g_warningstream, p_pfile@*/ ;
372 # define cppoptgenerror(p_code, p_s, p_pfile) \
373     (xcppoptgenerror (__FILE__, __LINE__, p_code, p_s, p_pfile))
374
375 extern void llerrorlit (flagcode p_o, char *p_s);
376 # define llerrorlit(o, s)   ((void) llerror (o, cstring_makeLiteral (s)))
377
378 extern void llgenindentmsg (/*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_warningstream@*/ ;
379
380 extern /*@noreturn@*/ void llbugexitlit (char *p_s);
381 # define llbugexitlit(s)    (llbug (cstring_makeLiteral (s)))
382
383 extern void llbuglit (char *p_s);
384 # define llbuglit(s)        (llbug (cstring_makeLiteral (s)))
385
386 extern void llcontbuglit (char *p_s);
387 # define llcontbuglit(s)    (llbug (cstring_makeLiteral (s)))
388
389 extern void checkParseError (void);
390
391 extern void llmsglit (char *p_s);
392 # define llmsglit(s)        (llmsg (cstring_makeLiteral (s)))
393
394 extern void ppllerror (/*@only@*/ cstring p_s);
395
396 extern void genppllerrorhint (flagcode p_code, /*@only@*/ cstring p_s, 
397                               /*@only@*/ cstring p_hint);
398 extern void genppllerror (flagcode p_code, /*@only@*/ cstring p_s);
399 extern /*@unused@*/ void pplldiagmsg (/*@only@*/ cstring p_s);
400 extern void loadllmsg (/*@only@*/ cstring p_s);
401
402 extern void llgenindentmsgnoloc (/*@only@*/ cstring p_s);
403
404 extern /*@observer@*/ cstring lldecodeerror (int) /*@*/ ;
405
406 /*@i523@*/
407 /*
408 ** should be static, but used in cpperror (which shouldn't exist)
409 */
410
411 extern void prepareMessage (void)
412   /*@modifies internalState, g_messagestream@*/ ;
413
414 extern void closeMessage (void)
415   /*@modifies internalState, g_messagestream@*/ ;
416
417 extern void llflush (void) /*@modifies systemState@*/ ;
418
419 # else
420 # error "Multiple include"
421 # endif
422
This page took 1.19742 seconds and 5 git commands to generate.