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 extern /*@noreturnwhenfalse@*/ void llassertretval (/*@sef@*/ bool p_test, /*@sef@*/ void *p_val);
36 # define llassertretval(tst,val) \
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@*/ \
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).
51 extern /*@noreturnwhenfalse@*/ void llassertprotect (/*@sef@*/ bool p_test);
52 # define llassertprotect(tst) \
54 fprintf (stderr, "%s:%d: at source point: ", __FILE__, __LINE__); \
55 fprintf (stderr, "protected fatal llassert failed: " #tst "\n"); \
56 llexit (EXIT_FAILURE); \
59 extern /*@noreturnwhenfalse@*/ void llassertfatal (/*@sef@*/ bool p_test);
60 # define llassertfatal(tst) \
62 llfatalbug (message("%s:%d: fatal llassert failed: " #tst, \
63 cstring_makeLiteralTemp (__FILE__), __LINE__)); \
67 ** llassertprint and llassertprintret are in splintMacros.nf
70 extern void llmsg (/*@only@*/ cstring p_s) /*@modifies g_warningstream@*/ ;
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@*/ ;
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@*/ ;
83 extern /*@noreturn@*/ void llfatalbug (/*@only@*/ cstring p_s)
84 /*@globals g_currentloc@*/
85 /*@modifies g_errorstream@*/ ;
87 # define llfatalbug(p_s) \
88 xllfatalbug (__FILE__, __LINE__, p_s)
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@*/ ;
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)
99 extern /*@private@*/ bool
100 xllgenhinterror (char *p_srcFile, int p_srcLine,
101 flagcode p_o, /*@only@*/ cstring p_s, /*@only@*/ cstring p_hint,
103 /*@modifies g_warningstream@*/ ;
105 extern bool llgenhinterror (flagcode p_o, /*@only@*/ cstring p_s, /*@only@*/ cstring p_hint,
106 fileloc p_fl) /*@modifies g_warningstream@*/ ;
108 # define llgenhinterror(p_o, p_s, p_hint, p_fl) \
109 xllgenhinterror (__FILE__, __LINE__, p_o, p_s, p_hint, p_fl)
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))
118 extern void llgenmsg (/*@only@*/ cstring p_s, fileloc p_fl)
119 /*@modifies g_warningstream@*/ ;
121 extern /*@noreturn@*/ void llfatalerror (/*@only@*/ cstring p_s)
122 /*@modifies g_errorstream@*/ ;
124 extern /*@noreturn@*/ void llfatalerrorLoc (/*@only@*/ cstring p_s)
125 /*@globals g_currentloc@*/
126 /*@modifies g_errorstream@*/ ;
128 extern void llparseerror (/*@only@*/ cstring p_s)
129 /*@globals g_errorstream, g_currentloc@*/
130 /*@modifies g_errorstream@*/ ;
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);
139 extern void xlclerror (char *p_srcFile, int p_srcLine, ltoken p_t, /*@only@*/ cstring p_msg) ;
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)
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);
151 extern void llerror_flagWarning (/*@only@*/ cstring p_s) /*@modifies g_warningstream@*/ ;
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@*/ ;
157 extern /*@noreturn@*/ void llbug (/*@only@*/ cstring p_s)
158 /*@globals g_warningstream, g_currentloc@*/
159 /*@modifies *g_warningstream@*/ ;
161 /* doesn't really exit, but don't mind errors if it doesn't */
162 # define llbug(s) llbugaux (cstring_makeLiteralTemp (__FILE__), __LINE__, s)
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__)
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))
172 extern void cleanupMessages (void)
173 /*@globals g_warningstream, g_currentloc;@*/
174 /*@modifies g_warningstream, internalState@*/ ;
176 extern void displayScan (/*@only@*/ cstring p_msg)
177 /*@modifies g_messagestream@*/ ;
179 extern void displayScanOpen (/*@only@*/ cstring p_msg)
180 /*@modifies g_messagestream@*/ ;
182 extern void displayScanContinue (/*@temp@*/ cstring p_msg)
183 /*@modifies g_messagestream@*/ ;
185 extern void displayScanClose (void)
186 /*@modifies g_messagestream@*/ ;
189 ** Report error iff f1 and f2 are set.
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@*/ ;
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))
204 ** Report error if f1 is set and f2 is not set.
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@*/ ;
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))
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@*/ ;
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))
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@*/ ;
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))
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@*/ ;
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)
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,
254 /*@modifies *g_warningstream, internalState@*/ ;
256 extern bool llgentypeerror (ctype p_t1, exprNode p_e1,
257 ctype p_t2, exprNode p_e2,
258 /*@only@*/ cstring p_s,
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)
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@*/ ;
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))
280 ** These are macros to save evaluating s (which may be some expensive
281 ** message generation function).
285 optgenerror (/*@sef@*/ flagcode p_o, /*@sef@*/ /*@only@*/ cstring p_s,
286 /*@sef@*/ fileloc p_loc)
287 /*@modifies *g_warningstream, internalState@*/ ;
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))
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))
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@*/ ;
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)
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))
318 ** Reports a warning when f1 is ON and f2 is ON
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))
327 ** Reports a warning when f1 is ON and f2 is OFF
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))
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))
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))
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))
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@*/ ;
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))
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@*/ ;
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))
375 extern void llerrorlit (flagcode p_o, char *p_s);
376 # define llerrorlit(o, s) ((void) llerror (o, cstring_makeLiteral (s)))
378 extern void llgenindentmsg (/*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_warningstream@*/ ;
380 extern /*@noreturn@*/ void llbugexitlit (char *p_s);
381 # define llbugexitlit(s) (llbug (cstring_makeLiteral (s)))
383 extern void llbuglit (char *p_s);
384 # define llbuglit(s) (llbug (cstring_makeLiteral (s)))
386 extern void llcontbuglit (char *p_s);
387 # define llcontbuglit(s) (llbug (cstring_makeLiteral (s)))
389 extern void checkParseError (void);
391 extern void llmsglit (char *p_s);
392 # define llmsglit(s) (llmsg (cstring_makeLiteral (s)))
394 extern void ppllerror (/*@only@*/ cstring p_s);
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);
402 extern void llgenindentmsgnoloc (/*@only@*/ cstring p_s);
404 extern /*@observer@*/ cstring lldecodeerror (int) /*@*/ ;
408 ** should be static, but used in cpperror (which shouldn't exist)
411 extern void prepareMessage (void)
412 /*@modifies internalState, g_messagestream@*/ ;
414 extern void closeMessage (void)
415 /*@modifies internalState, g_messagestream@*/ ;
417 extern void llflush (void) /*@modifies systemState@*/ ;
420 # error "Multiple include"