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