2 ** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2001.
3 ** See ../LICENSE for license information.
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__)
13 extern bool doCheck (bool p_x, cstring p_pred, cstring p_file, int p_line);
15 extern /*@noreturnwhenfalse@*/ void llassert (/*@sef@*/ bool p_test);
17 # define llassert(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); \
26 extern /*@noreturnwhenfalse@*/ void llassertretnull (/*@sef@*/ bool p_test);
27 # define llassertretnull(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); \
35 typedef void *tx_voidptr;
37 extern /*@noreturnwhenfalse@*/ void
38 llassertretval (/*@sef@*/ bool p_test, /*@sef@*/ /*@null@*/ tx_voidptr /*@alt anytype@*/ p_val);
39 # define llassertretval(tst,val) \
41 if (context_getFlag (FLG_TRYTORECOVER)) checkParseError (); \
42 lldiagmsg (message ("%s:%d: at source point", \
43 cstring_makeLiteralTemp (__FILE__), __LINE__)); \
44 llbuglit ("llassert failed: " #tst); \
45 /*@-type@*/ return (val); /*@=type@*/ \
49 ** Use this for assertions in error-generation code (that
50 ** might lead to infinite loops of failed assertions if
51 ** the normal error generation routines are used).
54 extern /*@noreturnwhenfalse@*/ void llassertprotect (/*@sef@*/ bool p_test);
55 # define llassertprotect(tst) \
57 fprintf (stderr, "%s:%d: at source point: ", __FILE__, __LINE__); \
58 fprintf (stderr, "protected fatal llassert failed: " #tst "\n"); \
59 llexit (EXIT_FAILURE); \
62 extern /*@noreturnwhenfalse@*/ void llassertfatal (/*@sef@*/ bool p_test);
63 # define llassertfatal(tst) \
65 llfatalbug (message("%s:%d: fatal llassert failed: " #tst, \
66 cstring_makeLiteralTemp (__FILE__), __LINE__)); \
70 ** llassertprint and llassertprintret are in splintMacros.nf
73 extern void llmsg (/*@only@*/ cstring p_s) /*@modifies g_warningstream@*/ ;
75 extern void lldiagmsg (/*@only@*/ cstring p_s) /*@modifies stderr@*/ ;
76 extern void llmsgplain (/*@only@*/ cstring p_s) /*@modifies g_warningstream@*/ ;
77 extern void llhint (/*@only@*/ cstring p_s)
78 /*@globals g_currentloc, g_warningstream;@*/
79 /*@modifies g_warningstream@*/ ;
81 extern /*@private@*/ /*@noreturn@*/ void
82 xllfatalbug (char *p_srcFile, int p_srcLine, /*@only@*/ cstring p_s)
83 /*@globals g_currentloc@*/
84 /*@modifies g_errorstream@*/ ;
86 extern /*@noreturn@*/ void llfatalbug (/*@only@*/ cstring p_s)
87 /*@globals g_currentloc@*/
88 /*@modifies g_errorstream@*/ ;
90 # define llfatalbug(p_s) \
91 xllfatalbug (__FILE__, __LINE__, p_s)
93 extern /*@private@*/ bool xllgenerror (char *p_srcFile, int p_srcLine, flagcode p_o,
94 /*@only@*/ cstring p_s, fileloc p_fl)
95 /*@modifies g_warningstream@*/ ;
97 extern bool llgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_fl)
98 /*@modifies g_warningstream@*/ ;
99 # define llgenerror(p_o, p_s, p_fl) \
100 xllgenerror (__FILE__, __LINE__, p_o, p_s, p_fl)
102 extern /*@private@*/ bool
103 xllgenhinterror (char *p_srcFile, int p_srcLine,
104 flagcode p_o, /*@only@*/ cstring p_s, /*@only@*/ cstring p_hint,
106 /*@modifies g_warningstream@*/ ;
108 extern bool llgenhinterror (flagcode p_o, /*@only@*/ cstring p_s, /*@only@*/ cstring p_hint,
109 fileloc p_fl) /*@modifies g_warningstream@*/ ;
111 # define llgenhinterror(p_o, p_s, p_hint, p_fl) \
112 xllgenhinterror (__FILE__, __LINE__, p_o, p_s, p_hint, p_fl)
115 extern void llerror (flagcode p_o, /*@only@*/ cstring p_s)
116 /*@globals g_warningstream, g_currentloc@*/
117 /*@modifies g_warningstream@*/ ;
118 # define llerror(p_o, p_s) \
119 ((void) llgenerror (p_o, p_s, g_currentloc))
121 extern void llgenmsg (/*@only@*/ cstring p_s, fileloc p_fl)
122 /*@modifies g_warningstream@*/ ;
124 extern /*@noreturn@*/ /*@private@*/
125 void xllfatalerror (char *p_srcFile, int p_srcLine, /*@only@*/ cstring p_s)
126 /*@modifies g_errorstream@*/ ;
128 extern /*@noreturn@*/ void llfatalerror (/*@only@*/ cstring p_s)
129 /*@modifies g_errorstream@*/ ;
130 # define llfatalerror(p_s) xllfatalerror (__FILE__, __LINE__, p_s)
132 extern /*@noreturn@*/ /*@private@*/ void
133 xllfatalerrorLoc (char *p_srcFile, int p_srcLine, /*@only@*/ cstring p_s)
134 /*@globals g_currentloc@*/
135 /*@modifies g_errorstream@*/ ;
137 extern /*@noreturn@*/ void llfatalerrorLoc (/*@only@*/ cstring p_s)
138 /*@globals g_currentloc@*/
139 /*@modifies g_errorstream@*/ ;
140 # define llfatalerrorLoc(p_s) xllfatalerrorLoc (__FILE__, __LINE__, p_s)
142 extern /*@private@*/ void
143 xllparseerror (char *p_srcFile, int p_srcLine, /*@only@*/ cstring p_s)
144 /*@globals g_currentloc@*/
145 /*@modifies g_warningstream@*/ ;
147 extern void llparseerror (/*@only@*/ cstring p_s)
148 /*@globals g_currentloc@*/
149 /*@modifies g_warningstream@*/ ;
151 # define llparseerror(p_s) xllparseerror (__FILE__, __LINE__, p_s)
153 extern /*@noreturn@*/ void lclplainfatalerror (/*@only@*/ cstring p_msg) /*@modifies g_warningstream@*/ ;
154 extern /*@noreturn@*/ void lclfatalbug (/*@temp@*/ char *p_msg) /*@modifies g_warningstream@*/ ;
155 extern int lclNumberErrors (void) /*@*/ ;
156 extern bool lclHadNewError (void) /*@modifies internalState@*/ ;
157 extern /*@noreturn@*/ void lclfatalerror (ltoken p_t, /*@only@*/ cstring p_msg);
159 extern void xlclerror (char *p_srcFile, int p_srcLine, ltoken p_t, /*@only@*/ cstring p_msg) ;
161 extern void lclerror (ltoken p_t, /*@only@*/ cstring p_msg);
162 # define lclerror(p_t,p_msg) \
163 xlclerror (__FILE__, __LINE__, p_t, p_msg)
165 extern void lclbug (/*@only@*/ cstring p_s);
166 extern void lclplainerror (/*@only@*/ cstring p_msg);
167 extern bool lclHadError (void);
168 extern void lclRedeclarationError (ltoken p_id);
171 extern void llerror_flagWarning (/*@only@*/ cstring p_s) /*@modifies g_warningstream@*/ ;
173 extern /*@noreturn@*/ void llbugaux (cstring p_file, int p_line, /*@only@*/ cstring p_s)
174 /*@globals g_warningstream, g_currentloc@*/
175 /*@modifies *g_warningstream@*/ ;
177 extern /*@noreturn@*/ void llbug (/*@only@*/ cstring p_s)
178 /*@globals g_warningstream, g_currentloc@*/
179 /*@modifies *g_warningstream@*/ ;
181 /* doesn't really exit, but don't mind errors if it doesn't */
182 # define llbug(s) llbugaux (cstring_makeLiteralTemp (__FILE__), __LINE__, s)
184 extern void llquietbugaux (/*@only@*/ cstring p_s, cstring, int) /*@modifies *g_warningstream@*/ ;
185 extern void llquietbug (/*@only@*/ cstring) /*@modifies *g_warningstream@*/ ;
186 # define llquietbug(s) llquietbugaux (s, cstring_makeLiteralTemp (__FILE__), __LINE__)
188 extern void llcontbug (/*@only@*/ cstring p_s) /*@modifies *g_warningstream@*/ ;
189 /* doesn't really exit, but don't mind errors if it doesn't */
190 # define llcontbug(s) (llbug (s))
192 extern void cleanupMessages (void)
193 /*@globals g_warningstream, g_currentloc;@*/
194 /*@modifies g_warningstream, internalState@*/ ;
196 extern void displayScan (/*@only@*/ cstring p_msg)
197 /*@modifies g_messagestream@*/ ;
199 extern void displayScanOpen (/*@only@*/ cstring p_msg)
200 /*@modifies g_messagestream@*/ ;
202 extern void displayScanContinue (/*@temp@*/ cstring p_msg)
203 /*@modifies g_messagestream@*/ ;
205 extern void displayScanClose (void)
206 /*@modifies g_messagestream@*/ ;
209 ** Report error iff f1 and f2 are set.
213 xoptgenerror2 (char *p_srcFile, int p_srcLine,
214 flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
215 /*@modifies *g_warningstream, internalState@*/ ;
218 optgenerror2 (flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
219 /*@modifies *g_warningstream, internalState@*/ ;
220 # define optgenerror2(p_f1, p_f2, p_s, p_loc) \
221 (xoptgenerror2 (__FILE__, __LINE__, p_f1, p_f2, p_s, p_loc))
224 ** Report error if f1 is set and f2 is not set.
228 xoptgenerror2n (char *p_srcFile, int p_srcLine,
229 flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
230 /*@modifies *g_warningstream, internalState@*/ ;
233 optgenerror2n (flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc)
234 /*@modifies *g_warningstream, internalState@*/ ;
235 # define optgenerror2n(p_f1, p_f2, p_s, p_loc) \
236 (xoptgenerror2n (__FILE__, __LINE__, p_f1, p_f2, p_s, p_loc))
238 extern /*@private@*/ bool xlloptgenerror (char *p_srcFile, int p_srcLine, flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
239 /*@modifies *g_warningstream, internalState@*/ ;
241 extern bool lloptgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
242 /*@modifies *g_warningstream, internalState@*/ ;
243 # define lloptgenerror(p_o, p_s, p_loc) \
244 (xlloptgenerror (__FILE__, __LINE__, p_o, p_s, p_loc))
246 extern bool xllnoptgenerror (char *p_srcFile, int p_srcLine,
247 flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
248 /*@modifies *g_warningstream, internalState@*/ ;
250 extern bool llnoptgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc)
251 /*@modifies *g_warningstream, internalState@*/ ;
252 # define llnoptgenerror(p_o, p_s, p_loc) \
253 (xllnoptgenerror (__FILE__, __LINE__, p_o, p_s, p_loc))
255 extern /*@private@*/ bool
256 xllgenformattypeerror (char *p_srcFile, int p_srcLine,
257 ctype p_t1, exprNode p_e1,
258 ctype p_t2, exprNode p_e2,
259 /*@only@*/ cstring p_s, fileloc p_fl)
260 /*@modifies *g_warningstream, internalState@*/ ;
262 extern bool llgenformattypeerror (ctype p_t1, exprNode p_e1,
263 ctype p_t2, exprNode p_e2,
264 /*@only@*/ cstring p_s, fileloc p_fl)
265 /*@modifies *g_warningstream, internalState@*/ ;
266 # define llgenformattypeerror(p_t1, p_e1, p_t2, p_e2, p_s, p_fl) \
267 xllgenformattypeerror (__FILE__, __LINE__, p_t1, p_e1, p_t2, p_e2, p_s, p_fl)
269 extern bool xllgentypeerror (char *p_srcFile, int p_srcLine,
270 ctype p_t1, exprNode p_e1,
271 ctype p_t2, exprNode p_e2,
272 /*@only@*/ cstring p_s,
274 /*@modifies *g_warningstream, internalState@*/ ;
276 extern bool llgentypeerror (ctype p_t1, exprNode p_e1,
277 ctype p_t2, exprNode p_e2,
278 /*@only@*/ cstring p_s,
280 /*@modifies *g_warningstream, internalState@*/ ;
281 # define llgentypeerror(p_t1, p_e1, p_t2, p_e2, p_s, p_fl) \
282 xllgentypeerror (__FILE__, __LINE__, p_t1, p_e1, p_t2, p_e2, p_s, p_fl)
284 extern bool gentypeerror (/*@sef@*/ ctype p_t1,
285 /*@sef@*/ exprNode p_e1,
286 /*@sef@*/ ctype p_t2,
287 /*@sef@*/ exprNode p_e2,
288 /*@sef@*/ /*@only@*/ cstring p_s,
289 /*@sef@*/ fileloc p_loc)
290 /*@modifies *g_warningstream, internalState@*/ ;
292 /*@-branchstate@*/ /* sef only s is freed on one branch */
293 #define gentypeerror(t1, e1, t2, e2, s, loc) \
294 (context_suppressFlagMsg (FLG_TYPE,loc) \
295 ? (flagcode_recordSuppressed (FLG_TYPE), FALSE) \
296 : llgentypeerror (t1, e1, t2, e2, s, loc))
300 ** These are macros to save evaluating s (which may be some expensive
301 ** message generation function).
305 optgenerror (/*@sef@*/ flagcode p_o, /*@sef@*/ /*@only@*/ cstring p_s,
306 /*@sef@*/ fileloc p_loc)
307 /*@modifies *g_warningstream, internalState@*/ ;
309 /*@-branchstate@*/ /* sef only s is freed on one branch */
310 #define optgenerror(o,s,loc) \
311 (context_suppressFlagMsg(o,loc) ? (flagcode_recordSuppressed(o), FALSE) \
312 : lloptgenerror (o, s, loc))
316 voptgenerror (/*@sef@*/ flagcode p_o, /*@sef@*/ /*@only@*/ cstring p_s,
317 /*@sef@*/ fileloc p_loc)
318 /*@modifies *g_warningstream, internalState@*/ ;
319 #define voptgenerror(o, s, loc) ((void) optgenerror(o,s,loc))
321 extern /*@private@*/ bool
322 xfsgenerror (char *p_srcFile, int p_srcLine,
323 flagSpec p_fs, /*@only@*/ cstring p_s, fileloc p_fl)
324 /*@modifies g_warningstream, internalState@*/ ;
326 extern bool fsgenerror (flagSpec p_fs, /*@only@*/ cstring p_s, fileloc p_fl)
327 /*@modifies g_warningstream, internalState@*/ ;
328 # define fsgenerror(p_fs, p_s, p_fl) \
329 xfsgenerror (__FILE__, __LINE__, p_fs, p_s, p_fl)
332 vfsgenerror (/*@sef@*/ flagSpec p_fs, /*@sef@*/ /*@only@*/ cstring p_s,
333 /*@sef@*/ fileloc p_loc)
334 /*@modifies *g_warningstream, internalState@*/ ;
335 #define vfsgenerror(fs, s, loc) ((void) fsgenerror(fs,s,loc))
338 ** Reports a warning when f1 is ON and f2 is ON
342 voptgenerror2 (/*@sef@*/ flagcode p_f1, /*@sef@*/ flagcode p_f2,
343 /*@sef@*/ /*@only@*/ cstring p_s, /*@sef@*/ fileloc p_loc);
344 #define voptgenerror2(f1, f2, s, loc) ((void) optgenerror2 (f1, f2, s, loc))
347 ** Reports a warning when f1 is ON and f2 is OFF
351 voptgenerror2n (/*@sef@*/ flagcode p_f1, /*@sef@*/ flagcode p_f2,
352 /*@sef@*/ /*@only@*/ cstring p_s, /*@sef@*/ fileloc p_loc);
353 #define voptgenerror2n(f1, f2, s, loc) ((void) optgenerror2n (f1, f2, s, loc))
355 extern void noptgenerror (/*@sef@*/ flagcode p_code,
356 /*@sef@*/ /*@only@*/ cstring p_s,
357 /*@sef@*/ fileloc p_loc);
358 /*@-branchstate@*/ /* sef only s is freed on one branch */
359 #define noptgenerror(o,s,loc) \
360 (context_suppressNotFlagMsg (o, loc) \
361 ? (flagcode_recordSuppressed(o), FALSE) \
362 : llnoptgenerror (o, s, loc))
366 vnoptgenerror (/*@sef@*/ flagcode p_code, /*@sef@*/ /*@only@*/ cstring p_msg,
367 /*@sef@*/ fileloc p_loc);
368 # define vnoptgenerror(o, s, loc) ((void) noptgenerror(o, s, loc))
371 vgenhinterror (flagcode p_code, /*@only@*/ cstring p_mst,
372 /*@only@*/ cstring p_hint, /*@sef@*/ fileloc p_loc);
373 # define vgenhinterror(o, s, h, loc) \
374 ((void) llgenhinterror(o, s, h, loc))
377 extern /*@private@*/ bool /*@alt void@*/ xllforceerror (char *p_srcFile, int p_srcLine, flagcode p_code, /*@only@*/ cstring p_s, fileloc p_fl)
378 /*@modifies g_warningstream@*/ ;
380 extern bool /*@alt void@*/ llforceerror (flagcode p_code, /*@only@*/ cstring p_s, fileloc p_fl)
381 /*@modifies g_warningstream@*/ ;
382 # define llforceerror(p_code, p_s, p_fl) \
383 (xllforceerror (__FILE__, __LINE__, p_code, p_s, p_fl))
385 extern /*@private@*/ bool xcppoptgenerror (char *p_srcFile, int p_srcLine, flagcode p_o,
386 /*@only@*/ cstring p_s, cppReader *p_pfile)
387 /*@modifies g_warningstream, p_pfile@*/ ;
389 extern bool /*@alt void@*/
390 cppoptgenerror (flagcode p_code, /*@only@*/ cstring p_s, cppReader *p_pfile)
391 /*@modifies g_warningstream, p_pfile@*/ ;
392 # define cppoptgenerror(p_code, p_s, p_pfile) \
393 (xcppoptgenerror (__FILE__, __LINE__, p_code, p_s, p_pfile))
395 extern void llerrorlit (flagcode p_o, char *p_s);
396 # define llerrorlit(o, s) ((void) llerror (o, cstring_makeLiteral (s)))
398 extern void llgenindentmsg (/*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_warningstream@*/ ;
400 extern /*@noreturn@*/ void llbugexitlit (char *p_s);
401 # define llbugexitlit(s) (llbug (cstring_makeLiteral (s)))
403 extern void llbuglit (char *p_s);
404 # define llbuglit(s) (llbug (cstring_makeLiteral (s)))
406 extern void llcontbuglit (char *p_s);
407 # define llcontbuglit(s) (llbug (cstring_makeLiteral (s)))
409 extern void checkParseError (void);
411 extern void llmsglit (char *p_s);
412 # define llmsglit(s) (llmsg (cstring_makeLiteral (s)))
414 extern void ppllerror (/*@only@*/ cstring p_s);
416 extern void genppllerrorhint (flagcode p_code, /*@only@*/ cstring p_s,
417 /*@only@*/ cstring p_hint);
418 extern void genppllerror (flagcode p_code, /*@only@*/ cstring p_s);
419 extern /*@unused@*/ void pplldiagmsg (/*@only@*/ cstring p_s);
420 extern void loadllmsg (/*@only@*/ cstring p_s);
422 extern void llgenindentmsgnoloc (/*@only@*/ cstring p_s);
424 extern /*@observer@*/ cstring lldecodeerror (int) /*@*/ ;
428 ** should be static, but used in cpperror (which shouldn't exist)
431 extern void prepareMessage (void)
432 /*@modifies internalState, g_messagestream@*/ ;
434 extern void closeMessage (void)
435 /*@modifies internalState, g_messagestream@*/ ;
437 extern void llflush (void) /*@modifies systemState@*/ ;
440 # error "Multiple include"