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