]>
Commit | Line | Data |
---|---|---|
885824d3 | 1 | /* Definitions for CPP library. |
2 | Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. | |
3 | Written by Per Bothner, 1994-95. | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify it | |
6 | under the terms of the GNU General Public License as published by the | |
7 | Free Software Foundation; either version 2, or (at your option) any | |
8 | later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program; if not, write to the Free Software | |
17 | Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 | ||
19 | In other words, you are welcome to use, share and improve this program. | |
20 | You are forbidden to forbid anyone else to use, share and improve | |
21 | what you give them. Help stamp out software-hoarding! */ | |
22 | ||
23 | #include <sys/types.h> | |
24 | #include <sys/stat.h> | |
25 | ||
26 | #ifdef __cplusplus | |
27 | extern "C" { | |
28 | #endif | |
29 | ||
885824d3 | 30 | typedef enum cpp_token (*parseUnderflow) (cppReader *); |
31 | typedef void (*parseCleanup) (cppBuffer *, cppReader *); | |
32 | ||
33 | /* A parse_marker indicates a previous position, | |
34 | which we can backtrack to. */ | |
35 | ||
36 | struct parse_marker { | |
37 | /*@dependent@*/ cppBuffer *buf; | |
38 | /*@dependent@*/ /*@null@*/ struct parse_marker *next; | |
39 | int position; | |
40 | }; | |
41 | ||
42 | /* The arglist structure is built by do_define to tell | |
43 | collect_definition where the argument names begin. That | |
44 | is, for a define like "#define f(x,y,z) foo+x-bar*y", the arglist | |
45 | would contain pointers to the strings x, y, and z. | |
46 | Collect_definition would then build a DEFINITION node, | |
47 | with reflist nodes pointing to the places x, y, and z had | |
48 | appeared. So the arglist is just convenience data passed | |
49 | between these two routines. It is not kept around after | |
50 | the current #define has been processed and entered into the | |
51 | hash table. */ | |
52 | ||
53 | struct arglist { | |
54 | /*@null@*/ struct arglist *next; | |
55 | /*@dependent@*/ char *name; | |
56 | int length; | |
57 | int argno; | |
58 | int rest_args; | |
59 | }; | |
60 | ||
61 | extern enum cpp_token cppGetToken (cppReader *); | |
62 | extern int /*@alt void@*/ cppSkipHspace (cppReader *); | |
63 | ||
64 | /* This frees resources used by PFILE. */ | |
65 | extern /*@unused@*/ void cppCleanup (cppReader *p_pfile); | |
66 | ||
67 | struct cppBuffer { | |
68 | /*@null@*/ /*@only@*/ char *buf; | |
69 | /*@null@*/ /*@exposed@*/ char *cur; | |
70 | /*@null@*/ /*@exposed@*/ char *rlimit; /* end of valid data */ | |
71 | /*@null@*/ /*@exposed@*/ char *alimit; /* end of allocated buffer */ | |
72 | /*@null@*/ /*@exposed@*/ char *prev; | |
73 | ||
74 | /*@dependent@*/ cstring fname; | |
75 | ||
76 | /* Filename specified with #line command. */ | |
77 | /*@exposed@*/ cstring nominal_fname; | |
78 | ||
79 | /* Record where in the search path this file was found. | |
80 | For #include_next. */ | |
81 | ||
82 | /*@dependent@*/ /*@null@*/ struct file_name_list *dir; | |
83 | ||
84 | long line_base; | |
85 | int lineno; /* Line number at CPP_LINE_BASE. */ | |
86 | int colno; /* Column number at CPP_LINE_BASE. */ | |
87 | parseUnderflow underflow; | |
88 | parseCleanup cleanup; | |
89 | ||
cd7d9b17 | 90 | /*@dependent@*/ hashNode hnode; |
885824d3 | 91 | /*@dependent@*/ /*@null@*/ struct parse_marker *marks; |
92 | /* Value of if_stack at start of this file. | |
93 | Used to prohibit unmatched #endif (etc) in an include file. */ | |
94 | /*@null@*/ /*@exposed@*/ struct if_stack *if_stack; | |
95 | ||
96 | /* True if this is a header file included using <FILENAME>. */ | |
97 | char system_header_p; | |
98 | char seen_eof; | |
99 | ||
100 | /* True if buffer contains escape sequences. | |
101 | Currently there are three kinds: | |
102 | "@-" means following identifier should not be macro-expanded. | |
103 | "@ " means a token-separator. This turns into " " in final output | |
104 | if not stringizing and needed to separate tokens; otherwise nothing. | |
105 | "@@" means a normal '@'. | |
106 | (An '@' inside a string stands for itself and is never an escape.) */ | |
107 | bool has_escapes; | |
108 | }; | |
109 | ||
110 | struct cpp_pending; /* Forward declaration - for C++. */ | |
111 | struct file_name_map_list; | |
112 | ||
113 | /* Maximum nesting of cppBuffers. We use a static limit, partly for | |
114 | efficiency, and partly to limit runaway recursion. */ | |
115 | ||
116 | /*@constant int CPP_STACK_MAX; @*/ | |
117 | # define CPP_STACK_MAX 200 | |
118 | ||
119 | /* A cppReader encapsulates the "state" of a pre-processor run. | |
120 | Applying cppGetToken repeatedly yields a stream of pre-processor | |
121 | tokens. Usually, there is only one cppReader object active. */ | |
122 | ||
123 | struct cppReader { | |
124 | parseUnderflow get_token; | |
125 | /*@dependent@*/ /*@null@*/ cppBuffer *buffer; | |
126 | cppBuffer buffer_stack[CPP_STACK_MAX]; | |
127 | ||
128 | int errors; /* Error counter for exit code */ | |
129 | cppOptions *opts; | |
130 | /* void *data; */ | |
131 | ||
132 | /* A buffer used for both for cppGetToken's output, and also internally. */ | |
133 | /*@relnull@*/ char *token_buffer; | |
134 | ||
135 | /* Alocated size of token_buffer. cppReader_reserve allocates space. */ | |
136 | size_t token_buffer_size; | |
137 | /* End of the written part of token_buffer. */ | |
138 | /*@exposed@*/ char *limit; | |
139 | ||
140 | /* Line where a newline was first seen in a string constant. */ | |
141 | int multiline_string_line; | |
142 | ||
143 | /* Current depth in #include directives that use <...>. */ | |
144 | int system_include_depth; | |
145 | ||
146 | /* List of other included files. | |
147 | If ->control_macro if nonzero, the file had a #ifndef | |
148 | around the entire contents, and ->control_macro gives the macro name. */ | |
149 | /*@owned@*/ /*@null@*/ struct file_name_list *all_include_files; | |
150 | ||
151 | /* Current maximum length of directory names in the search path | |
152 | for include files. (Altered as we get more of them.) */ | |
153 | int max_include_len; | |
154 | ||
155 | /*@null@*/ struct if_stack *if_stack; | |
156 | ||
157 | /* Nonzero means we are inside an IF during a -pcp run. In this mode | |
158 | macro expansion is done, and preconditions are output for all macro | |
159 | uses requiring them. */ | |
160 | char pcp_inside_if; | |
161 | ||
162 | /* Nonzero means we have printed (while error reporting) a list of | |
163 | containing files that matches the current status. */ | |
164 | char input_stack_listing_current; | |
165 | ||
166 | /* If non-zero, macros are not expanded. */ | |
167 | bool no_macro_expand; | |
168 | ||
169 | /* Print column number in error messages. */ | |
170 | bool show_column; | |
171 | ||
172 | /* If true, character between '<' and '>' are a single (string) token. */ | |
173 | char parsing_include_directive; | |
174 | ||
175 | /* True if escape sequences (as described for has_escapes in | |
176 | parse_buffer) should be emitted. */ | |
177 | char output_escapes; | |
178 | ||
179 | /* 0: Have seen non-white-space on this line. | |
180 | 1: Only seen white space so far on this line. | |
181 | 2: Only seen white space so far in this file. */ | |
182 | char only_seen_white; | |
183 | ||
184 | int lineno; | |
185 | ||
186 | /*@null@*/ /*@observer@*/ struct tm *timebuf; | |
187 | ||
188 | #ifdef __cplusplus | |
189 | ~cppReader () { cppCleanup (this); } | |
190 | #endif | |
191 | }; | |
192 | ||
193 | /*@constant int cppReader_fatalErrorLimit; @*/ | |
194 | #define cppReader_fatalErrorLimit 1000 | |
195 | ||
196 | /* True if we have seen a "fatal" error. */ | |
197 | extern bool cppFatalErrors (cppReader *) /*@*/ ; | |
198 | #define cppFatalErrors(READER) ((READER)->errors >= cppReader_fatalErrorLimit) | |
199 | ||
200 | extern int cppBufPeek (cppBuffer *) /*@*/ ; | |
201 | ||
202 | /* Macros for manipulating the token_buffer. */ | |
203 | ||
204 | /*@notfunction@*/ | |
205 | #define CPP_OUT_BUFFER(PFILE) ((PFILE)->token_buffer) | |
206 | ||
207 | /* Number of characters currently in PFILE's output buffer. */ | |
208 | ||
209 | extern size_t cppReader_getWritten (/*@sef@*/ cppReader *) /*@*/ ; | |
210 | # define cppReader_getWritten(PFILE) \ | |
211 | (size_fromInt ((PFILE)->limit - (PFILE)->token_buffer)) | |
212 | ||
213 | extern /*@exposed@*/ char *cppReader_getPWritten (cppReader *) /*@*/ ; | |
214 | # define cppReader_getPWritten(PFILE) ((PFILE)->limit) | |
215 | ||
216 | /* Make sure PFILE->token_buffer has space for at least N more characters. */ | |
217 | ||
218 | extern void cppReader_reserve (/*@sef@*/ cppReader *, /*@sef@*/ size_t); | |
219 | #define cppReader_reserve(PFILE, N) \ | |
220 | (cppReader_getWritten (PFILE) + (N) > (PFILE)->token_buffer_size \ | |
221 | && (cppReader_growBuffer (PFILE, (N)), 0)) | |
222 | ||
223 | /* Append string STR (of length N) to PFILE's output buffer. | |
224 | Assume there is enough space. */ | |
225 | ||
226 | extern void cppReader_putStrN (/*@sef@*/ cppReader *p_file, | |
227 | /*@unique@*/ char *p_str, /*@sef@*/ size_t p_n) | |
228 | /*@modifies *p_file; @*/; | |
229 | ||
230 | #define cppReader_putStrN(PFILE, STR, N) \ | |
231 | (memcpy ((PFILE)->limit, STR, (N)), (PFILE)->limit += (N)) | |
232 | ||
233 | extern void cppReader_setWritten (/*@sef@*/ /*@special@*/ cppReader *p_file, size_t) | |
234 | /*@uses p_file, *p_file, p_file->token_buffer;@*/ | |
235 | /*@sets p_file->limit;@*/ | |
236 | /*@modifies *p_file@*/ ; | |
237 | ||
238 | # define cppReader_setWritten(PFILE,N) \ | |
239 | ((PFILE)->limit = (PFILE)->token_buffer + (N)) | |
240 | ||
241 | extern /*@dependent@*/ /*@exposed@*/ cppOptions *CPPOPTIONS (/*@special@*/ cppReader *p_pfile) | |
242 | /*@uses p_pfile->opts@*/ ; | |
243 | #define CPPOPTIONS(PFILE) ((PFILE)->opts) | |
244 | ||
245 | /*@notfunction@*/ | |
246 | #define CPPBUFFER(PFILE) ((PFILE)->buffer) | |
247 | ||
248 | /* Checks for null */ | |
249 | extern /*@exposed@*/ cppBuffer * | |
250 | cppReader_getBufferSafe (/*@special@*/ cppReader *p_pfile) | |
251 | /*@uses p_pfile->buffer@*/ | |
252 | /*@modifies nothing@*/ ; | |
253 | ||
254 | extern /*@exposed@*/ cppBuffer *cppBuffer_prevBuffer (cppBuffer *) /*@*/ ; | |
255 | ||
256 | /* The bottom of the buffer stack. */ | |
257 | extern /*@exposed@*/ cppBuffer *cppReader_nullBuffer (/*@special@*/ cppReader *p_pfile) /*@uses p_pfile->buffer_stack@*/ /*@*/ ; | |
258 | # define cppReader_nullBuffer(PFILE) (&(PFILE)->buffer_stack[CPP_STACK_MAX]) | |
259 | ||
260 | /* Pointed to by cppReader::data. */ | |
261 | struct cppOptions { | |
262 | /*@dependent@*/ cstring in_fname; | |
263 | ||
264 | /* Name of output file, for error messages. */ | |
265 | /*@dependent@*/ cstring out_fname; | |
266 | ||
267 | struct file_name_map_list *map_list; | |
268 | ||
269 | /* Non-0 means -v, so print the full set of include dirs. */ | |
270 | bool verbose; | |
271 | ||
272 | /* Nonzero means use extra default include directories for C++. */ | |
273 | ||
274 | bool cplusplus; | |
275 | ||
276 | /* Nonzero means handle cplusplus style comments */ | |
277 | ||
278 | bool cplusplus_comments; | |
279 | ||
280 | /* Nonzero means this is an assembly file, and allow | |
281 | unknown directives, which could be comments. */ | |
282 | ||
283 | int lang_asm; | |
284 | ||
285 | /* Nonzero means turn NOTREACHED into #pragma NOTREACHED etc */ | |
286 | ||
287 | bool for_lint; | |
288 | ||
289 | /* Nonzero means handle CHILL comment syntax | |
290 | and output CHILL string delimiter for __DATE___ etc. */ | |
291 | ||
292 | bool chill; | |
293 | ||
294 | /* Nonzero means copy comments into the output file. */ | |
295 | ||
296 | bool put_out_comments; | |
297 | ||
298 | /* Nonzero means don't process the ANSI trigraph sequences. */ | |
299 | ||
300 | bool no_trigraphs; | |
301 | ||
302 | /* Nonzero means print names of header files (-H). */ | |
303 | ||
304 | bool print_include_names; | |
305 | ||
306 | /* Nonzero means try to make failure to fit ANSI C an error. */ | |
307 | ||
308 | bool pedantic_errors; | |
309 | ||
310 | /* Nonzero means don't print warning messages. -w. */ | |
b072092f | 311 | /* bool inhibit_warnings; -- removed evans 2001-07-19 */ |
885824d3 | 312 | |
313 | /* Nonzero means warn if slash-star appears in a comment. */ | |
885824d3 | 314 | bool warn_comments; |
315 | ||
316 | /* Nonzero means warn if a macro argument is (or would be) | |
317 | stringified with -traditional. */ | |
318 | ||
319 | bool warn_stringify; | |
320 | bool warnings_are_errors; | |
321 | bool no_output; | |
322 | ||
323 | /* Nonzero means don't output line number information. */ | |
324 | ||
325 | bool no_line_commands; | |
326 | ||
327 | /* Nonzero means output the text in failing conditionals, | |
328 | inside #failed ... #endfailed. */ | |
329 | ||
330 | char output_conditionals; | |
331 | ||
332 | char ignore_srcdir; | |
333 | ||
334 | /* Zero means dollar signs are punctuation. | |
335 | This used to be needed for conformance to the C Standard, | |
336 | before the C Standard was corrected. */ | |
337 | bool dollars_in_ident; | |
338 | ||
339 | /* Nonzero means try to imitate old fashioned non-ANSI preprocessor. */ | |
340 | bool traditional; | |
341 | ||
342 | /* Nonzero for the 1989 C Standard, including corrigenda and amendments. */ | |
343 | bool c89; | |
344 | ||
345 | /* Nonzero means give all the error messages the ANSI standard requires. */ | |
346 | bool pedantic; | |
347 | ||
348 | bool done_initializing; | |
349 | ||
350 | /* First dir to search */ | |
351 | /*@owned@*/ struct file_name_list *include; | |
352 | /* First dir to search for <file> */ | |
353 | /* This is the first element to use for #include <...>. | |
354 | If it is 0, use the entire chain for such includes. */ | |
355 | /*@dependent@*/ struct file_name_list *first_bracket_include; | |
356 | /* This is the first element in the chain that corresponds to | |
357 | a directory of system header files. */ | |
358 | /*@dependent@*/ struct file_name_list *first_system_include; | |
359 | /*@exposed@*/ struct file_name_list *last_include; /* Last in chain */ | |
360 | ||
361 | /* Chain of include directories to put at the end of the other chain. */ | |
362 | struct file_name_list *after_include; | |
363 | /*@exposed@*/ struct file_name_list *last_after_include; /* Last in chain */ | |
364 | ||
365 | /* Chain to put at the start of the system include files. */ | |
366 | struct file_name_list *before_system; | |
367 | /*@exposed@*/ struct file_name_list *last_before_system; /* Last in chain */ | |
368 | ||
369 | /* Directory prefix that should replace `/usr' in the standard | |
370 | include file directories. */ | |
371 | char *include_prefix; | |
372 | ||
373 | char inhibit_predefs; | |
374 | char no_standard_includes; | |
375 | char no_standard_cplusplus_includes; | |
376 | ||
377 | /* | |
378 | ** DUMP_NAMES means pass #define and the macro name through to output. | |
379 | ** DUMP_DEFINITIONS means pass the whole definition (plus #define) through | |
380 | */ | |
381 | ||
382 | /*@-enummemuse@*/ | |
383 | enum { DUMP_NONE = 0, DUMP_NAMES, DUMP_DEFINITIONS } | |
384 | dump_macros; | |
385 | /*@=enummemuse@*/ | |
386 | ||
387 | /* Nonzero means pass all #define and #undef directives which we actually | |
388 | process through to the output stream. This feature is used primarily | |
389 | to allow cc1 to record the #defines and #undefs for the sake of | |
390 | debuggers which understand about preprocessor macros, but it may | |
391 | also be useful with -E to figure out how symbols are defined, and | |
392 | where they are defined. */ | |
393 | int debug_output; | |
394 | }; | |
395 | ||
396 | extern bool cppReader_isTraditional (/*@special@*/ cppReader *p_pfile) | |
397 | /*@uses p_pfile->opts@*/ | |
398 | /*@modifies nothing@*/ ; | |
399 | ||
400 | #define cppReader_isTraditional(PFILE) (CPPOPTIONS(PFILE)-> traditional) | |
401 | ||
402 | extern bool cppReader_isPedantic (cppReader *) /*@*/; | |
403 | #define cppReader_isPedantic(PFILE) (CPPOPTIONS (PFILE)->pedantic) | |
404 | ||
405 | /* The structure of a node in the hash table. The hash table | |
406 | has entries for all tokens defined by #define commands (type T_MACRO), | |
407 | plus some special tokens like __LINE__ (these each have their own | |
408 | type, and the appropriate code is run when that type of node is seen. | |
409 | It does not contain control words like "#define", which are recognized | |
410 | by a separate piece of code. */ | |
411 | ||
412 | /* different flavors of hash nodes --- also used in keyword table */ | |
413 | enum node_type { | |
414 | T_NONE = 0, | |
415 | T_DEFINE = 1, /* the `#define' keyword */ | |
416 | T_INCLUDE, /* the `#include' keyword */ | |
417 | T_INCLUDE_NEXT, /* the `#include_next' keyword */ | |
418 | T_IFDEF, /* the `#ifdef' keyword */ | |
419 | T_IFNDEF, /* the `#ifndef' keyword */ | |
420 | T_IF, /* the `#if' keyword */ | |
421 | T_ELSE, /* `#else' */ | |
422 | T_PRAGMA, /* `#pragma' */ | |
423 | T_ELIF, /* `#elif' */ | |
424 | T_UNDEF, /* `#undef' */ | |
425 | T_LINE, /* `#line' */ | |
426 | T_ERROR, /* `#error' */ | |
427 | T_WARNING, /* `#warning' */ | |
428 | T_ENDIF, /* `#endif' */ | |
429 | T_IDENT, /* `#ident', used on system V. */ | |
430 | T_SPECLINE, /* special symbol `__LINE__' */ | |
431 | T_DATE, /* `__DATE__' */ | |
432 | T_FILE, /* `__FILE__' */ | |
433 | T_BASE_FILE, /* `__BASE_FILE__' */ | |
434 | T_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */ | |
435 | T_VERSION, /* `__VERSION__' */ | |
436 | T_SIZE_TYPE, /* `__SIZE_TYPE__' */ | |
437 | T_PTRDIFF_TYPE, /* `__PTRDIFF_TYPE__' */ | |
438 | T_WCHAR_TYPE, /* `__WCHAR_TYPE__' */ | |
439 | T_USER_LABEL_PREFIX_TYPE, /* `__USER_LABEL_PREFIX__' */ | |
440 | T_REGISTER_PREFIX_TYPE, /* `__REGISTER_PREFIX__' */ | |
441 | T_TIME, /* `__TIME__' */ | |
442 | T_CONST, /* Constant value, used by `__STDC__' */ | |
443 | T_MACRO, /* macro defined by `#define' */ | |
444 | T_DISABLED, /* macro temporarily turned off for rescan */ | |
445 | T_SPEC_DEFINED, /* special `defined' macro for use in #if statements */ | |
446 | T_PCSTRING, /* precompiled string (hashval is KEYDEF *) */ | |
447 | T_UNUSED /* Used for something not defined. */ | |
448 | } ; | |
449 | ||
450 | /* Structure returned by create_definition */ | |
451 | typedef struct macrodef MACRODEF; | |
452 | struct macrodef | |
453 | { | |
454 | /*@null@*/ struct definition *defn; | |
455 | /*@relnull@*/ /*@dependent@*/ char *symnam; /* null if defn is null */ | |
456 | int symlen; | |
457 | }; | |
458 | ||
459 | /* Structure allocated for every #define. For a simple replacement | |
460 | such as | |
461 | #define foo bar , | |
462 | nargs = -1, the `pattern' list is null, and the expansion is just | |
463 | the replacement text. Nargs = 0 means a functionlike macro with no args, | |
464 | e.g., | |
465 | #define getchar() getc (stdin) . | |
466 | When there are args, the expansion is the replacement text with the | |
467 | args squashed out, and the reflist is a list describing how to | |
468 | build the output from the input: e.g., "3 chars, then the 1st arg, | |
469 | then 9 chars, then the 3rd arg, then 0 chars, then the 2nd arg". | |
470 | The chars here come from the expansion. Whatever is left of the | |
471 | expansion after the last arg-occurrence is copied after that arg. | |
472 | Note that the reflist can be arbitrarily long--- | |
473 | its length depends on the number of times the arguments appear in | |
474 | the replacement text, not how many args there are. Example: | |
475 | #define f(x) x+x+x+x+x+x+x would have replacement text "++++++" and | |
476 | pattern list | |
477 | { (0, 1), (1, 1), (1, 1), ..., (1, 1), NULL } | |
478 | where (x, y) means (nchars, argno). */ | |
479 | ||
480 | typedef struct definition DEFINITION; | |
481 | ||
482 | struct definition { | |
483 | int nargs; | |
484 | size_t length; /* length of expansion string */ | |
485 | bool predefined; /* True if the macro was builtin or */ | |
486 | /* came from the command line */ | |
487 | /*@dependent@*/ char *expansion; | |
488 | long line; /* Line number of definition */ | |
489 | /*@exposed@*/ cstring file; /* File of definition */ | |
490 | ||
491 | bool noExpand; /* True if macro should not be expanded in code. */ | |
492 | bool rest_args; /* Nonzero if last arg. absorbs the rest */ | |
493 | ||
494 | /*@null@*/ struct reflist { | |
495 | /*@null@*/ /*@dependent@*/ struct reflist *next; | |
496 | bool stringify; /* nonzero if this arg was preceded by a | |
497 | # operator. */ | |
498 | bool raw_before; /* Nonzero if a ## operator before arg. */ | |
499 | bool raw_after; /* Nonzero if a ## operator after arg. */ | |
500 | bool rest_args; /* Nonzero if this arg. absorbs the rest */ | |
501 | int nchars; /* Number of literal chars to copy before | |
502 | this arg occurrence. */ | |
503 | int argno; /* Number of arg to substitute (origin-0) */ | |
504 | } *pattern; | |
505 | ||
506 | union { | |
507 | /* Names of macro args, concatenated in reverse order | |
508 | with comma-space between them. | |
509 | The only use of this is that we warn on redefinition | |
510 | if this differs between the old and new definitions. */ | |
511 | /*@null@*/ char *argnames; | |
512 | } args; | |
513 | }; | |
514 | ||
515 | /* Stack of conditionals currently in progress | |
516 | (including both successful and failing conditionals). */ | |
517 | ||
518 | struct if_stack { | |
519 | /*@null@*/ struct if_stack *next; /* for chaining to the next stack frame */ | |
520 | /*@observer@*/ cstring fname; /* copied from input when frame is made */ | |
521 | int lineno; /* similarly */ | |
522 | int if_succeeded; /* true if a leg of this if-group | |
523 | has been passed through rescan */ | |
524 | ||
525 | /* For #ifndef at start of file, this is the macro name tested. */ | |
526 | /*@null@*/ /*@dependent@*/ char *control_macro; | |
527 | ||
528 | ||
529 | enum node_type type; /* type of last directive seen in this group */ | |
530 | }; | |
531 | typedef struct if_stack cppIfStackFrame; | |
532 | ||
533 | extern void cppBuffer_lineAndColumn (/*@null@*/ cppBuffer *, /*@out@*/ int *, | |
534 | /*@out@*/ /*@null@*/ int *); | |
535 | extern /*@exposed@*/ /*@null@*/ cppBuffer *cppReader_fileBuffer (cppReader *); | |
536 | ||
537 | extern void cppReader_growBuffer (cppReader *, size_t); | |
538 | extern int cppReader_parseEscape (cppReader *, char **); | |
539 | ||
540 | extern /*@exposed@*/ cppBuffer *cppReader_popBuffer (cppReader *p_pfile) | |
541 | /*@modifies p_pfile@*/ ; | |
542 | ||
543 | #ifdef __cplusplus | |
544 | } | |
545 | #endif | |
546 | ||
547 | extern void cppReader_skipRestOfLine (cppReader *p_pfile); | |
548 | ||
549 | # include <stdlib.h> | |
550 | ||
551 | # ifdef WIN32 | |
552 | /*@constant observer char *GCC_INCLUDE_DIR;@*/ | |
553 | # define GCC_INCLUDE_DIR NULL | |
554 | # else | |
555 | /*@constant observer char *GCC_INCLUDE_DIR;@*/ | |
556 | # define GCC_INCLUDE_DIR "/usr/lib/gcc-lib/i386-linux/2.7.2.1/include" | |
557 | # endif | |
558 | ||
559 | # ifdef WIN32 | |
560 | /*@constant observer char *GCC_INCLUDE_DIR2@*/ | |
561 | # define GCC_INCLUDE_DIR2 NULL | |
562 | # else | |
563 | /*@constant observer char *GCC_INCLUDE_DIR2@*/ | |
564 | # define GCC_INCLUDE_DIR2 "/usr/include" | |
565 | # endif | |
566 | ||
567 | struct file_name_list | |
568 | { | |
569 | /*@owned@*/ /*@null@*/ struct file_name_list *next; | |
570 | /*@dependent@*/ cstring fname; | |
571 | ||
572 | /* If the following is nonzero, it is a macro name. | |
573 | Don't include the file again if that macro is defined. */ | |
574 | ||
575 | /*@dependent@*/ /*@null@*/ char *control_macro; | |
576 | /* If the following is nonzero, it is a C-language system include | |
577 | directory. */ | |
578 | ||
579 | bool c_system_include_path; | |
580 | ||
581 | /* Mapping of file names for this directory. */ | |
582 | /*@exposed@*/ /*@relnull@*/ /*@reldef@*/ struct file_name_map *name_map; | |
583 | ||
584 | /* Non-zero if name_map is valid. */ | |
585 | bool got_name_map; | |
586 | }; | |
587 | ||
588 | extern void cppReader_addIncludeChain (/*@special@*/ cppReader *p_pfile, | |
589 | /*@keep@*/ struct file_name_list *p_dir) | |
590 | /*@uses p_pfile->opts, p_pfile->max_include_len@*/ | |
591 | /*@modifies p_pfile, p_dir@*/ ; | |
592 | ||
593 | extern void cppReader_define (cppReader *p_pfile, char *p_str); | |
594 | extern void cppReader_finish (cppReader *p_pfile); | |
595 | extern void cppReader_init (/*@out@*/ cppReader *p_pfile) ; | |
596 | extern void cppOptions_init (/*@out@*/ cppOptions *p_opts); | |
597 | extern void cppReader_initializeReader (cppReader *p_pfile) /*@modifies p_pfile@*/ ; | |
598 | ||
599 | extern int cppReader_startProcess (cppReader *p_pfile, cstring p_fname); | |
600 | ||
601 | extern bool isIdentifierChar (char) /*@*/ ; | |
602 | ||
603 | /* Find the largest host integer type and set its size and type. */ | |
604 | ||
605 | #ifndef HOST_BITS_PER_WIDE_INT | |
606 | ||
607 | #if HOST_BITS_PER_LONG > HOST_BITS_PER_INT | |
608 | /*@notfunction@*/ | |
609 | #define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG | |
610 | /*@notfunction@*/ | |
611 | #define HOST_WIDE_INT long | |
612 | #else | |
613 | /*@notfunction@*/ | |
614 | #define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT | |
615 | /*@notfunction@*/ | |
616 | #define HOST_WIDE_INT long | |
617 | /* was int */ | |
618 | #endif | |
619 | ||
620 | #endif | |
621 | ||
622 | #ifndef S_ISREG | |
623 | /*@-macrounrecog@*/ | |
624 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) | |
625 | /*@=macrounrecog@*/ | |
626 | #endif | |
627 | ||
628 | #ifndef S_ISDIR | |
629 | /*@-macrounrecog@*/ | |
630 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) | |
631 | /*@=macrounrecog@*/ | |
632 | #endif | |
633 | ||
634 | #ifndef INCLUDE_LEN_FUDGE | |
635 | /*@constant int INCLUDE_LEN_FUDGE@*/ | |
636 | #define INCLUDE_LEN_FUDGE 0 | |
637 | #endif | |
638 | ||
639 | extern int cppReader_checkMacroName (cppReader *p_pfile, char *p_symname, | |
640 | cstring p_usage); | |
641 | ||
642 | extern struct operation cppReader_parseNumber (cppReader *, char *, int); | |
643 |