]>
Commit | Line | Data |
---|---|---|
885824d3 | 1 | /* |
2 | ** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2000. | |
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 | # define llassert(tst) \ | |
17 | do { if (!(tst)) { \ | |
18 | if (context_getFlag (FLG_TRYTORECOVER)) checkParseError (); \ | |
19 | lldiagmsg (message ("%s:%d: at source point", \ | |
20 | cstring_makeLiteralTemp (__FILE__), __LINE__)); \ | |
21 | llbuglit ("llassert failed: " #tst); \ | |
22 | }} while (FALSE) | |
23 | ||
24 | extern /*@falseexit@*/ void llassertfatal (/*@sef@*/ bool p_test); | |
25 | # define llassertfatal(tst) \ | |
26 | do { if (!(tst)) \ | |
27 | llfatalbug (message("%s:%d: fatal llassert failed: " #tst, \ | |
28 | cstring_makeLiteralTemp (__FILE__), __LINE__)); \ | |
29 | } while (FALSE) | |
30 | ||
31 | /* | |
32 | ** llassertprint and llassertprintret are in lclintMacros.nf | |
33 | */ | |
34 | ||
35 | extern void llmsg (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ; | |
36 | extern void lldiagmsg (/*@only@*/ cstring p_s) /*@modifies stderr@*/ ; | |
37 | extern void llmsgplain (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ; | |
38 | extern void llhint (/*@only@*/ cstring p_s) | |
39 | /*@globals g_currentloc, g_msgstream;@*/ | |
40 | /*@modifies g_msgstream@*/ ; | |
41 | extern /*@exits@*/ void llfatalbug (/*@only@*/ cstring p_s) | |
42 | /*@globals g_currentloc@*/ | |
43 | /*@modifies stderr@*/ ; | |
44 | extern void llgloberror (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ; | |
45 | extern bool llgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_msgstream@*/ ; | |
46 | extern bool llgenhinterror (flagcode p_o, /*@only@*/ cstring p_s, /*@only@*/ cstring p_hint, | |
47 | fileloc p_fl) /*@modifies g_msgstream@*/ ; | |
48 | extern void llerror (flagcode p_o, /*@only@*/ cstring p_s) | |
49 | /*@globals g_msgstream, g_currentloc@*/ | |
50 | /*@modifies g_msgstream@*/ ; | |
51 | extern void llgenmsg (/*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_msgstream@*/ ; | |
52 | extern /*@exits@*/ void llfatalerror (/*@only@*/ cstring p_s) /*@modifies g_msgstream@*/ ; | |
53 | extern /*@exits@*/ void llfatalerrorLoc (/*@only@*/ cstring p_s) | |
54 | /*@globals g_currentloc@*/ | |
55 | /*@modifies stderr@*/ ; | |
56 | extern void llparseerror (/*@only@*/ cstring p_s) | |
57 | /*@globals g_msgstream, g_currentloc@*/ | |
58 | /*@modifies g_msgstream@*/ ; | |
59 | ||
60 | # ifndef NOLCL | |
61 | extern /*@exits@*/ void lclplainfatalerror (/*@only@*/ cstring p_msg) /*@modifies g_msgstream@*/ ; | |
62 | extern /*@exits@*/ void lclfatalbug (/*@temp@*/ char *p_msg) /*@modifies g_msgstream@*/ ; | |
63 | extern int lclNumberErrors (void) /*@*/ ; | |
64 | extern bool lclHadNewError (void) /*@modifies internalState@*/ ; | |
65 | extern /*@exits@*/ void lclfatalerror (ltoken p_t, /*@only@*/ cstring p_msg); | |
66 | extern void lclerror (ltoken p_t, /*@only@*/ cstring p_msg); | |
67 | ||
68 | extern void lclbug (/*@only@*/ cstring p_s); | |
69 | extern void lclplainerror (/*@only@*/ cstring p_msg); | |
70 | extern bool lclHadError (void); | |
71 | extern void lclRedeclarationError (ltoken p_id); | |
72 | # endif | |
73 | ||
74 | extern void flagWarning (/*@observer@*/ cstring p_s) /*@modifies g_msgstream@*/ ; | |
75 | ||
76 | extern /*@exits@*/ void llbugaux (cstring p_file, int p_line, /*@only@*/ cstring p_s) | |
77 | /*@globals g_msgstream, g_currentloc@*/ | |
78 | /*@modifies *g_msgstream@*/ ; | |
79 | ||
80 | extern /*@exits@*/ void llbug (/*@only@*/ cstring p_s) | |
81 | /*@globals g_msgstream, g_currentloc@*/ | |
82 | /*@modifies *g_msgstream@*/ ; | |
83 | ||
84 | /* doesn't really exit, but don't mind errors if it doesn't */ | |
85 | # define llbug(s) llbugaux (cstring_makeLiteralTemp (__FILE__), __LINE__, s) | |
86 | ||
87 | extern void llquietbugaux (/*@only@*/ cstring p_s, cstring, int) /*@modifies *g_msgstream@*/ ; | |
88 | extern void llquietbug (/*@only@*/ cstring) /*@modifies *g_msgstream@*/ ; | |
89 | # define llquietbug(s) llquietbugaux (s, cstring_makeLiteralTemp (__FILE__), __LINE__) | |
90 | ||
91 | extern void llcontbug (/*@only@*/ cstring p_s) /*@modifies *g_msgstream@*/ ; | |
92 | /* doesn't really exit, but don't mind errors if it doesn't */ | |
93 | # define llcontbug(s) (llbug (s)) | |
94 | ||
95 | extern void cleanupMessages (void) | |
96 | /*@globals g_msgstream, g_currentloc;@*/ | |
97 | /*@modifies g_msgstream, internalState@*/ ; | |
98 | ||
99 | /* | |
100 | ** Report error iff f1 and f2 are set. | |
101 | */ | |
102 | ||
103 | extern bool | |
104 | optgenerror2 (flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc) | |
105 | /*@modifies *g_msgstream, internalState@*/ ; | |
106 | ||
107 | /* | |
108 | ** Report error if f1 is set and f2 is not set. | |
109 | */ | |
110 | ||
111 | extern bool | |
112 | optgenerror2n (flagcode p_f1, flagcode p_f2, /*@only@*/ cstring p_s, fileloc p_loc) | |
113 | /*@modifies *g_msgstream, internalState@*/ ; | |
114 | ||
115 | extern bool lloptgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc) | |
116 | /*@modifies *g_msgstream, internalState@*/ ; | |
117 | ||
118 | extern bool llnoptgenerror (flagcode p_o, /*@only@*/ cstring p_s, fileloc p_loc) | |
119 | /*@modifies *g_msgstream, internalState@*/ ; | |
120 | ||
121 | extern bool llgenformattypeerror (ctype p_t1, exprNode p_e1, | |
122 | ctype p_t2, exprNode p_e2, | |
123 | /*@only@*/ cstring p_s, fileloc p_fl) | |
124 | /*@modifies *g_msgstream, internalState@*/ ; | |
125 | ||
126 | extern bool llgentypeerror (ctype p_t1, exprNode p_e1, | |
127 | ctype p_t2, exprNode p_e2, | |
128 | /*@only@*/ cstring p_s, | |
129 | fileloc p_fl) | |
130 | /*@modifies *g_msgstream, internalState@*/ ; | |
131 | ||
132 | extern bool gentypeerror (/*@sef@*/ ctype p_t1, | |
133 | /*@sef@*/ exprNode p_e1, | |
134 | /*@sef@*/ ctype p_t2, | |
135 | /*@sef@*/ exprNode p_e2, | |
136 | /*@sef@*/ /*@only@*/ cstring p_s, | |
137 | /*@sef@*/ fileloc p_loc) | |
138 | /*@modifies *g_msgstream, internalState@*/ ; | |
139 | ||
140 | /*@-branchstate@*/ /* sef only s is freed on one branch */ | |
141 | #define gentypeerror(t1, e1, t2, e2, s, loc) \ | |
142 | (context_suppressFlagMsg (FLG_TYPE,loc) \ | |
143 | ? (flagcode_recordSuppressed (FLG_TYPE), FALSE) \ | |
144 | : llgentypeerror (t1, e1, t2, e2, s, loc)) | |
145 | /*@=branchstate@*/ | |
146 | ||
147 | /* | |
148 | ** These are macros to save evaluating s (which may be some expensive | |
149 | ** message generation function). | |
150 | */ | |
151 | ||
152 | extern bool | |
153 | optgenerror (/*@sef@*/ flagcode p_o, /*@sef@*/ /*@only@*/ cstring p_s, | |
154 | /*@sef@*/ fileloc p_loc) | |
155 | /*@modifies *g_msgstream, internalState@*/ ; | |
156 | ||
157 | /*@-branchstate@*/ /* sef only s is freed on one branch */ | |
158 | #define optgenerror(o,s,loc) \ | |
159 | (context_suppressFlagMsg(o,loc) ? (flagcode_recordSuppressed(o), FALSE) \ | |
160 | : lloptgenerror (o, s, loc)) | |
161 | /*@=branchstate@*/ | |
162 | ||
163 | extern void | |
164 | voptgenerror (/*@sef@*/ flagcode p_o, /*@sef@*/ /*@only@*/ cstring p_s, | |
165 | /*@sef@*/ fileloc p_loc) | |
166 | /*@modifies *g_msgstream, internalState@*/ ; | |
167 | #define voptgenerror(o, s, loc) ((void) optgenerror(o,s,loc)) | |
168 | ||
169 | extern void | |
170 | voptgenerror2 (/*@sef@*/ flagcode p_f1, /*@sef@*/ flagcode p_f2, | |
171 | /*@sef@*/ /*@only@*/ cstring p_s, /*@sef@*/ fileloc p_loc); | |
172 | #define voptgenerror2(f1, f2, s, loc) ((void) optgenerror2 (f1, f2, s, loc)) | |
173 | ||
174 | extern void | |
175 | voptgenerror2n (/*@sef@*/ flagcode p_f1, /*@sef@*/ flagcode p_f2, | |
176 | /*@sef@*/ /*@only@*/ cstring p_s, /*@sef@*/ fileloc p_loc); | |
177 | #define voptgenerror2n(f1, f2, s, loc) ((void) optgenerror2n (f1, f2, s, loc)) | |
178 | ||
179 | extern void noptgenerror (/*@sef@*/ flagcode p_code, | |
180 | /*@sef@*/ /*@only@*/ cstring p_s, | |
181 | /*@sef@*/ fileloc p_loc); | |
182 | /*@-branchstate@*/ /* sef only s is freed on one branch */ | |
183 | #define noptgenerror(o,s,loc) \ | |
184 | (context_suppressNotFlagMsg (o, loc) \ | |
185 | ? (flagcode_recordSuppressed(o), FALSE) \ | |
186 | : llnoptgenerror (o, s, loc)) | |
187 | /*@=branchstate@*/ | |
188 | ||
189 | extern void | |
190 | vnoptgenerror (/*@sef@*/ flagcode p_code, /*@sef@*/ /*@only@*/ cstring p_msg, | |
191 | /*@sef@*/ fileloc p_loc); | |
192 | # define vnoptgenerror(o, s, loc) ((void) noptgenerror(o, s, loc)) | |
193 | ||
194 | extern void | |
195 | vgenhinterror (flagcode p_code, /*@only@*/ cstring p_mst, | |
196 | /*@only@*/ cstring p_hint, /*@sef@*/ fileloc p_loc); | |
197 | # define vgenhinterror(o, s, h, loc) \ | |
198 | ((void) llgenhinterror(o, s, h, loc)) | |
199 | ||
200 | extern void llforceerror (flagcode p_code, /*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_msgstream@*/ ; | |
201 | ||
202 | extern void llerrorlit (flagcode p_o, char *p_s); | |
203 | extern void llgenindentmsg (/*@only@*/ cstring p_s, fileloc p_fl) /*@modifies g_msgstream@*/ ; | |
204 | ||
205 | extern /*@exits@*/ void llbugexitlit (char *p_s); | |
206 | extern void llbuglit (char *p_s); | |
207 | extern void llcontbuglit (char *p_s); | |
208 | ||
209 | # define llerror(o, s) ((void) llgenerror (o, s, g_currentloc)) | |
210 | # define llerrorlit(o, s) ((void) llerror (o, cstring_makeLiteral (s))) | |
211 | # define llbuglit(s) (llbug (cstring_makeLiteral (s))) | |
212 | # define llcontbuglit(s) (llbug (cstring_makeLiteral (s))) | |
213 | # define llbugexitlit(s) (llbug (cstring_makeLiteral (s))) | |
214 | ||
215 | extern void checkParseError (void); | |
216 | ||
217 | extern void llmsglit (char *p_s); | |
218 | # define llmsglit(s) (llmsg (cstring_makeLiteral (s))) | |
219 | ||
220 | extern void ppllerror (/*@only@*/ cstring p_s); | |
221 | extern void genppllerrorhint (flagcode p_code, /*@only@*/ cstring p_s, | |
222 | /*@only@*/ cstring p_hint); | |
223 | extern void genppllerror (flagcode p_code, /*@only@*/ cstring p_s); | |
224 | extern /*@unused@*/ void pplldiagmsg (/*@only@*/ cstring p_s); | |
225 | extern void loadllmsg (/*@only@*/ cstring p_s); | |
226 | ||
227 | extern void llgenindentmsgnoloc (/*@only@*/ cstring p_s); | |
228 | ||
229 | extern /*@observer@*/ cstring lldecodeerror (int) /*@*/ ; | |
230 | ||
231 | extern void prepareMessage (void) /*@modifies internalState, g_msgstream@*/ ; | |
232 | extern void closeMessage (void) /*@modifies internalState, g_msgstream@*/ ; | |
233 | ||
234 | extern void llflush (void) /*@modifies systemState@*/ ; | |
235 | ||
236 | # else | |
237 | # error "Multiple include" | |
238 | # endif | |
239 |