]> andersk Git - splint.git/blob - src/Headers/llerror.h
*** empty log message ***
[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 /*@falseexit@*/ 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 /*@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
42 extern /*@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)
49
50 extern /*@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
61 extern void llmsg (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ;
62
63 extern void lldiagmsg (/*@only@*/ cstring p_s) /*@modifies stderr@*/ ;
64 extern void llmsgplain (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ;
65 extern void llhint (/*@only@*/ cstring p_s) 
66    /*@globals g_currentloc, g_msgstream;@*/ 
67    /*@modifies g_msgstream@*/ ;
68
69 extern /*@private@*/ /*@exits@*/ void xllfatalbug (char *p_srcFile, int p_srcLine,
70                                                   /*@only@*/ cstring p_s) 
71    /*@globals g_currentloc@*/
72    /*@modifies stderr@*/ ;
73
74 extern /*@exits@*/ void llfatalbug (/*@only@*/ cstring p_s) 
75    /*@globals g_currentloc@*/
76    /*@modifies stderr@*/ ;
77 # define llfatalbug(p_s) \
78      xllfatalbug (__FILE__, __LINE__, p_s)
79
80 extern /*@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
84 extern 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
89 extern /*@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
95 extern bool llgenhinterror (flagcode p_o, /*@only@*/ cstring p_s, /*@only@*/ cstring p_hint, 
96                             fileloc p_fl) /*@modifies g_msgstream@*/ ;
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
102 extern void llerror (flagcode p_o, /*@only@*/ cstring p_s) 
103    /*@globals g_msgstream, g_currentloc@*/ 
104    /*@modifies g_msgstream@*/ ;
105 # define llerror(p_o, p_s) \
106    ((void) llgenerror (p_o, p_s, g_currentloc))
107
108 extern void llgenmsg (/*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_msgstream@*/ ;
109 extern /*@exits@*/ void llfatalerror (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ;
110 extern /*@exits@*/ void llfatalerrorLoc (/*@only@*/ cstring p_s) 
111    /*@globals g_currentloc@*/ 
112    /*@modifies stderr@*/ ;
113 extern void llparseerror (/*@only@*/ cstring p_s) 
114    /*@globals g_msgstream, g_currentloc@*/ 
115    /*@modifies g_msgstream@*/ ;
116
117 # ifndef NOLCL
118 extern /*@exits@*/ void lclplainfatalerror (/*@only@*/ cstring p_msg) /*@modifies g_msgstream@*/ ;
119 extern /*@exits@*/ void lclfatalbug (/*@temp@*/ char *p_msg) /*@modifies g_msgstream@*/ ;
120 extern int lclNumberErrors (void) /*@*/ ;
121 extern bool lclHadNewError (void) /*@modifies internalState@*/ ;
122 extern /*@exits@*/ void lclfatalerror (ltoken p_t, /*@only@*/ cstring p_msg);
123
124 extern void xlclerror (char *p_srcFile, int p_srcLine, ltoken p_t, /*@only@*/ cstring p_msg) ;
125
126 extern void lclerror (ltoken p_t, /*@only@*/ cstring p_msg);
127 # define lclerror(p_t,p_msg) \
128    xlclerror (__FILE__, __LINE__, p_t, p_msg)
129
130 extern void lclbug (/*@only@*/ cstring p_s);
131 extern void lclplainerror (/*@only@*/ cstring p_msg);
132 extern bool lclHadError (void);
133 extern void lclRedeclarationError (ltoken p_id);
134 # endif
135
136 extern void llerror_flagWarning (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ;
137
138 extern /*@exits@*/ void llbugaux (cstring p_file, int p_line, /*@only@*/ cstring p_s) 
139    /*@globals g_msgstream, g_currentloc@*/
140    /*@modifies *g_msgstream@*/ ; 
141
142 extern /*@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
149 extern void llquietbugaux (/*@only@*/ cstring p_s, cstring, int) /*@modifies *g_msgstream@*/ ; 
150 extern void llquietbug (/*@only@*/ cstring) /*@modifies *g_msgstream@*/ ; 
151 # define llquietbug(s) llquietbugaux (s, cstring_makeLiteralTemp (__FILE__), __LINE__)
152
153 extern 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
157 extern 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
165 extern bool 
166 xoptgenerror2 (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
170 extern bool 
171 optgenerror2 (flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
172   /*@modifies *g_msgstream, internalState@*/ ;
173 # define optgenerror2(p_f1, p_f2, p_s, p_loc) \
174   (xoptgenerror2 (__FILE__, __LINE__, p_f1, p_f2, p_s, p_loc))
175
176 /*
177 ** Report error if f1 is set and f2 is not set.
178 */
179
180 extern bool 
181 xoptgenerror2n (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
185 extern bool 
186 optgenerror2n (flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
187   /*@modifies *g_msgstream, internalState@*/ ;
188 # define optgenerror2n(p_f1, p_f2, p_s, p_loc) \
189   (xoptgenerror2n (__FILE__, __LINE__, p_f1, p_f2, p_s, p_loc))
190
191 extern /*@private@*/ bool xlloptgenerror (char *p_srcFile, int p_srcLine, flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
192   /*@modifies *g_msgstream, internalState@*/ ;
193
194 extern bool lloptgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
195   /*@modifies *g_msgstream, internalState@*/ ;
196 # define lloptgenerror(p_o, p_s, p_loc) \
197    (xlloptgenerror (__FILE__, __LINE__, p_o, p_s, p_loc))
198
199 extern bool xllnoptgenerror (char *p_srcFile, int p_srcLine,
200                              flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
201   /*@modifies *g_msgstream, internalState@*/ ;
202
203 extern bool llnoptgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
204   /*@modifies *g_msgstream, internalState@*/ ;
205 # define llnoptgenerror(p_o, p_s, p_loc) \
206    (xllnoptgenerror (__FILE__, __LINE__, p_o, p_s, p_loc))
207
208 extern /*@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@*/ ;
214
215 extern 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@*/ ;
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
222 extern 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@*/ ;
228
229 extern 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@*/ ;
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)
236
237 extern 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
257 extern 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
268 extern 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
274 extern /*@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
279 extern 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
284 extern void 
285 vfsgenerror (/*@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
294 extern void 
295   voptgenerror2 (/*@sef@*/ flagcode p_f1, /*@sef@*/ flagcode p_f2, 
296                   /*@sef@*/ /*@only@*/ cstring p_s, /*@sef@*/ fileloc p_loc);
297 #define voptgenerror2(f1, f2, s, loc)   ((void) optgenerror2 (f1, f2, s, loc))
298
299 /*
300 ** Reports a warning when f1 is ON and f2 is OFF
301 */
302
303 extern 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
308 extern 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
318 extern 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
323 extern 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
329
330 extern /*@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
333 extern 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))
337
338 extern /*@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
342 extern 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
347 extern void llerrorlit (flagcode p_o, char *p_s);
348 # define llerrorlit(o, s)   ((void) llerror (o, cstring_makeLiteral (s)))
349
350 extern void llgenindentmsg (/*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_msgstream@*/ ;
351
352 extern /*@exits@*/ void llbugexitlit (char *p_s);
353 # define llbugexitlit(s)    (llbug (cstring_makeLiteral (s)))
354
355 extern void llbuglit (char *p_s);
356 # define llbuglit(s)        (llbug (cstring_makeLiteral (s)))
357
358 extern void llcontbuglit (char *p_s);
359 # define llcontbuglit(s)    (llbug (cstring_makeLiteral (s)))
360
361 extern void checkParseError (void);
362
363 extern void llmsglit (char *p_s);
364 # define llmsglit(s)        (llmsg (cstring_makeLiteral (s)))
365
366 extern void ppllerror (/*@only@*/ cstring p_s);
367 extern void genppllerrorhint (flagcode p_code, /*@only@*/ cstring p_s, 
368                               /*@only@*/ cstring p_hint);
369 extern void genppllerror (flagcode p_code, /*@only@*/ cstring p_s);
370 extern /*@unused@*/ void pplldiagmsg (/*@only@*/ cstring p_s);
371 extern void loadllmsg (/*@only@*/ cstring p_s);
372
373 extern void llgenindentmsgnoloc (/*@only@*/ cstring p_s);
374
375 extern /*@observer@*/ cstring lldecodeerror (int) /*@*/ ;
376
377 extern void prepareMessage (void) /*@modifies internalState, g_msgstream@*/ ;
378 extern void closeMessage (void) /*@modifies internalState, g_msgstream@*/ ;
379
380 extern void llflush (void) /*@modifies systemState@*/ ;
381
382 # else
383 # error "Multiple include"
384 # endif
385
This page took 0.077879 seconds and 5 git commands to generate.