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_msgstream@*/ ;
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@*/ ;
78 extern /*@private@*/ /*@noreturn@*/ void xllfatalbug (char *p_srcFile, int p_srcLine,
79 /*@only@*/ cstring p_s)
80 /*@globals g_currentloc@*/
81 /*@modifies stderr@*/ ;
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)
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@*/ ;
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)
98 extern /*@private@*/ bool
99 xllgenhinterror (char *p_srcFile, int p_srcLine,
100 flagcode p_o, /*@only@*/ cstring p_s, /*@only@*/ cstring p_hint,
102 /*@modifies g_msgstream@*/ ;
104 extern bool llgenhinterror (flagcode p_o, /*@only@*/ cstring p_s, /*@only@*/ cstring p_hint,
105 fileloc p_fl) /*@modifies g_msgstream@*/ ;
107 # define llgenhinterror(p_o, p_s, p_hint, p_fl) \
108 xllgenhinterror (__FILE__, __LINE__, p_o, p_s, p_hint, p_fl)
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))
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@*/ ;
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);
133 extern void xlclerror (char *p_srcFile, int p_srcLine, ltoken p_t, /*@only@*/ cstring p_msg) ;
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)
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);
145 extern void llerror_flagWarning (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ;
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@*/ ;
151 extern /*@noreturn@*/ void llbug (/*@only@*/ cstring p_s)
152 /*@globals g_msgstream, g_currentloc@*/
153 /*@modifies *g_msgstream@*/ ;
155 /* doesn't really exit, but don't mind errors if it doesn't */
156 # define llbug(s) llbugaux (cstring_makeLiteralTemp (__FILE__), __LINE__, s)
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__)
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))
166 extern void cleanupMessages (void)
167 /*@globals g_msgstream, g_currentloc;@*/
168 /*@modifies g_msgstream, internalState@*/ ;
171 ** Report error iff f1 and f2 are set.
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@*/ ;
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))
186 ** Report error if f1 is set and f2 is not set.
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@*/ ;
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))
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@*/ ;
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))
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@*/ ;
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))
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@*/ ;
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)
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,
236 /*@modifies *g_msgstream, internalState@*/ ;
238 extern bool llgentypeerror (ctype p_t1, exprNode p_e1,
239 ctype p_t2, exprNode p_e2,
240 /*@only@*/ cstring p_s,
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)
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@*/ ;
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))
262 ** These are macros to save evaluating s (which may be some expensive
263 ** message generation function).
267 optgenerror (/*@sef@*/ flagcode p_o, /*@sef@*/ /*@only@*/ cstring p_s,
268 /*@sef@*/ fileloc p_loc)
269 /*@modifies *g_msgstream, internalState@*/ ;
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))
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))
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@*/ ;
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)
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))
300 ** Reports a warning when f1 is ON and f2 is ON
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))
309 ** Reports a warning when f1 is ON and f2 is OFF
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))
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))
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))
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))
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@*/ ;
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))
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@*/ ;
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))
356 extern void llerrorlit (flagcode p_o, char *p_s);
357 # define llerrorlit(o, s) ((void) llerror (o, cstring_makeLiteral (s)))
359 extern void llgenindentmsg (/*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_msgstream@*/ ;
361 extern /*@noreturn@*/ void llbugexitlit (char *p_s);
362 # define llbugexitlit(s) (llbug (cstring_makeLiteral (s)))
364 extern void llbuglit (char *p_s);
365 # define llbuglit(s) (llbug (cstring_makeLiteral (s)))
367 extern void llcontbuglit (char *p_s);
368 # define llcontbuglit(s) (llbug (cstring_makeLiteral (s)))
370 extern void checkParseError (void);
372 extern void llmsglit (char *p_s);
373 # define llmsglit(s) (llmsg (cstring_makeLiteral (s)))
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);
382 extern void llgenindentmsgnoloc (/*@only@*/ cstring p_s);
384 extern /*@observer@*/ cstring lldecodeerror (int) /*@*/ ;
386 extern void prepareMessage (void) /*@modifies internalState, g_msgstream@*/ ;
387 extern void closeMessage (void) /*@modifies internalState, g_msgstream@*/ ;
389 extern void llflush (void) /*@modifies systemState@*/ ;
392 # error "Multiple include"