OSDN Git Service

* cppfiles.c: Include splay-tree.h, not hashtab.h.
[pf3gnuchains/gcc-fork.git] / gcc / cpplib.h
1 /* Definitions for CPP library.
2    Copyright (C) 1995, 96-99, 2000 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 #ifndef __GCC_CPPLIB__
23 #define __GCC_CPPLIB__
24
25 #include <sys/types.h>
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 typedef struct cpp_reader cpp_reader;
32 typedef struct cpp_buffer cpp_buffer;
33 typedef struct cpp_options cpp_options;
34 typedef struct cpp_printer cpp_printer;
35 typedef struct cpp_token cpp_token;
36 typedef struct cpp_toklist cpp_toklist;
37 typedef struct cpp_name cpp_name;
38 typedef struct cpp_hashnode cpp_hashnode;
39
40 /* The first two groups, apart from '=', can appear in preprocessor
41    expressions.  This allows a lookup table to be implemented in
42    _cpp_parse_expr.
43
44    The first group, to CPP_LAST_EQ, can be immediately followed by an
45    '='.  The lexer needs operators ending in '=', like ">>=", to be in
46    the same order as their counterparts without the '=', like ">>".  */
47
48 /* Positions in the table.  */
49 #define CPP_LAST_EQ CPP_LSHIFT
50 #define CPP_FIRST_DIGRAPH CPP_HASH
51
52 #define TTYPE_TABLE                             \
53   T(CPP_EQ = 0,         "=")                    \
54   T(CPP_NOT,            "!")                    \
55   T(CPP_GREATER,        ">")    /* compare */   \
56   T(CPP_LESS,           "<")                    \
57   T(CPP_PLUS,           "+")    /* math */      \
58   T(CPP_MINUS,          "-")                    \
59   T(CPP_MULT,           "*")                    \
60   T(CPP_DIV,            "/")                    \
61   T(CPP_MOD,            "%")                    \
62   T(CPP_AND,            "&")    /* bit ops */   \
63   T(CPP_OR,             "|")                    \
64   T(CPP_XOR,            "^")                    \
65   T(CPP_RSHIFT,         ">>")                   \
66   T(CPP_LSHIFT,         "<<")                   \
67 \
68   T(CPP_COMPL,          "~")                    \
69   T(CPP_AND_AND,        "&&")   /* logical */   \
70   T(CPP_OR_OR,          "||")                   \
71   T(CPP_QUERY,          "?")                    \
72   T(CPP_COLON,          ":")                    \
73   T(CPP_COMMA,          ",")    /* grouping */  \
74   T(CPP_OPEN_PAREN,     "(")                    \
75   T(CPP_CLOSE_PAREN,    ")")                    \
76   T(CPP_EQ_EQ,          "==")   /* compare */   \
77   T(CPP_NOT_EQ,         "!=")                   \
78   T(CPP_GREATER_EQ,     ">=")                   \
79   T(CPP_LESS_EQ,        "<=")                   \
80 \
81   T(CPP_PLUS_EQ,        "+=")   /* math */      \
82   T(CPP_MINUS_EQ,       "-=")                   \
83   T(CPP_MULT_EQ,        "*=")                   \
84   T(CPP_DIV_EQ,         "/=")                   \
85   T(CPP_MOD_EQ,         "%=")                   \
86   T(CPP_AND_EQ,         "&=")   /* bit ops */   \
87   T(CPP_OR_EQ,          "|=")                   \
88   T(CPP_XOR_EQ,         "^=")                   \
89   T(CPP_RSHIFT_EQ,      ">>=")                  \
90   T(CPP_LSHIFT_EQ,      "<<=")                  \
91   /* Digraphs together, beginning with CPP_FIRST_DIGRAPH.  */   \
92   T(CPP_HASH,           "#")    /* digraphs */  \
93   T(CPP_PASTE,          "##")                   \
94   T(CPP_OPEN_SQUARE,    "[")                    \
95   T(CPP_CLOSE_SQUARE,   "]")                    \
96   T(CPP_OPEN_BRACE,     "{")                    \
97   T(CPP_CLOSE_BRACE,    "}")                    \
98   /* The remainder of the punctuation.  Order is not significant. */    \
99   T(CPP_SEMICOLON,      ";")    /* structure */ \
100   T(CPP_ELLIPSIS,       "...")                  \
101   T(CPP_BACKSLASH,      "\\")                   \
102   T(CPP_PLUS_PLUS,      "++")   /* increment */ \
103   T(CPP_MINUS_MINUS,    "--")                   \
104   T(CPP_DEREF,          "->")   /* accessors */ \
105   T(CPP_DOT,            ".")                    \
106   T(CPP_SCOPE,          "::")                   \
107   T(CPP_DEREF_STAR,     "->*")                  \
108   T(CPP_DOT_STAR,       ".*")                   \
109   T(CPP_MIN,            "<?")   /* extension */ \
110   T(CPP_MAX,            ">?")                   \
111   C(CPP_OTHER,          0)      /* stray punctuation */ \
112 \
113   I(CPP_NAME,           0)      /* word */      \
114   I(CPP_INT,            0)      /* 23 */        \
115   I(CPP_FLOAT,          0)      /* 3.14159 */   \
116   I(CPP_NUMBER,         0)      /* 34_be+ta  */ \
117   S(CPP_CHAR,           0)      /* 'char' */    \
118   S(CPP_WCHAR,          0)      /* L'char' */   \
119   S(CPP_STRING,         0)      /* "string" */  \
120   S(CPP_WSTRING,        0)      /* L"string" */ \
121 \
122   I(CPP_COMMENT,        0)      /* Only if output comments.  */ \
123   N(CPP_MACRO_ARG,      0)      /* Macro argument.  */          \
124   N(CPP_SUBLIST,        0)      /* Sublist.  */                 \
125   N(CPP_EOF,            0)      /* End of file.  */             \
126   N(CPP_HEADER_NAME,    0)      /* <stdio.h> in #include */     \
127 \
128   /* Obsolete - will be removed when no code uses them still.  */       \
129   T(CPP_VSPACE,         "\n")   /* End of line.  */             \
130   N(CPP_HSPACE,         0)      /* Horizontal white space.  */  \
131   N(CPP_DIRECTIVE,      0)      /* #define and the like */      \
132   N(CPP_MACRO,          0)      /* Like a NAME, but expanded.  */
133
134 #define T(e, s) e,
135 #define I(e, s) e,
136 #define S(e, s) e,
137 #define C(e, s) e,
138 #define N(e, s) e,
139 enum cpp_ttype
140 {
141   TTYPE_TABLE
142   N_TTYPES
143 };
144 #undef T
145 #undef I
146 #undef S
147 #undef C
148 #undef N
149
150 /* Payload of a NAME, NUMBER, FLOAT, STRING, or COMMENT token.  */
151 struct cpp_name
152 {
153   unsigned int len;
154   const unsigned char *text;
155 };
156
157 /* Accessor macros for token lists - all expect you have a
158    list and an index.  */
159
160 #define TOK_TYPE(l_, i_)   ((l_)->tokens[i_].type)
161 #define TOK_FLAGS(l_, i_)  ((l_)->tokens[i_].flags)
162 #define TOK_AUX(l_, i_)    ((l_)->tokens[i_].aux)
163 #define TOK_COL(l_, i_)    ((l_)->tokens[i_].col)
164 #define TOK_INT(l_, i_)    ((l_)->tokens[i_].val.integer)
165 #define TOK_NAME(l_, i_)   ((l_)->tokens[i_].val.name.text)
166 #define TOK_LEN(l_, i_)    ((l_)->tokens[i_].val.name.len)
167
168 #define TOK_PREV_WHITE(l_, i_) (TOK_FLAGS(l_, i_) & PREV_WHITESPACE)
169
170 /* Flags for the cpp_token structure.  */
171 #define PREV_WHITESPACE     1   /* If whitespace before this token.  */
172 #define BOL                 2   /* Beginning of line.  */
173 #define DIGRAPH             4   /* If it was a digraph.  */
174 #define UNSIGNED_INT        8   /* If int preprocessing token unsigned.  */
175
176 /* A preprocessing token.  This has been carefully packed and should
177    occupy 16 bytes on both 32- and 64-bit hosts.  */
178 struct cpp_token
179 {
180   unsigned short col;                   /* starting column of this token */
181   ENUM_BITFIELD(cpp_ttype) type : CHAR_BIT;  /* node type */
182   unsigned char flags;                  /* flags - see above */
183   unsigned int aux;                     /* CPP_OTHER character.  Hash of a
184                                            NAME, or something - see uses
185                                            in the code */
186   union
187   {
188     struct cpp_name name;               /* a string */
189     HOST_WIDEST_INT integer;            /* an integer */
190   } val;
191 };
192
193 /* General flags.  */
194 #define LIST_OFFSET    (1 << 0)
195
196 /* Directive flags.  */
197 #define SYNTAX_INCLUDE (1 << 8)
198
199 typedef int (*directive_handler) PARAMS ((cpp_reader *));
200
201 struct cpp_toklist
202 {
203   cpp_token *tokens;            /* actual tokens as an array */
204   unsigned int tokens_used;     /* tokens used */
205   unsigned int tokens_cap;      /* tokens allocated */
206
207   unsigned char *namebuf;       /* names buffer */
208   unsigned int name_used;       /* _bytes_ used */
209   unsigned int name_cap;        /* _bytes_ allocated */
210
211   unsigned int line;            /* starting line number */
212
213   /* The handler to call after lexing the rest of this line.
214      -1 for none */
215   short dirno;
216
217   /* Per-list flags, see above */
218   unsigned short flags;
219 };
220
221 struct cpp_buffer
222 {
223   const unsigned char *cur;      /* current position */
224   const unsigned char *rlimit; /* end of valid data */
225   const unsigned char *buf;      /* entire buffer */
226   const unsigned char *line_base; /* start of current line */
227   const unsigned char *mark;  /* Saved position for lengthy backtrack. */
228
229   struct cpp_buffer *prev;
230
231   /* Filename specified with #line command.  */
232   const char *nominal_fname;
233   /* Actual directory of this file, used only for "" includes */
234   struct file_name_list *actual_dir;
235
236   /* Pointer into the include table.  Used for include_next and
237      to record control macros. */
238   struct include_file *inc;
239
240   /* If the buffer is the expansion of a macro, this points to the
241      macro's hash table entry.  */
242   struct cpp_hashnode *macro;
243
244   /* Value of if_stack at start of this file.
245      Used to prohibit unmatched #endif (etc) in an include file.  */
246   struct if_stack *if_stack;
247
248   /* Line number at line_base (above). */
249   unsigned int lineno;
250
251   /* True if buffer contains escape sequences.
252      Currently there are two kinds:
253      "\r-" means following identifier should not be macro-expanded.
254      "\r " means a token-separator.  This turns into " " in final output
255           if not stringizing and needed to separate tokens; otherwise nothing.
256      Any other two-character sequence beginning with \r is an error.
257
258      If this is NOT set, then \r is a one-character escape meaning backslash
259      newline.  This is guaranteed not to occur in the middle of a token.
260      The two interpretations of \r do not conflict, because the two-character
261      escapes are used only in macro buffers, and backslash-newline is removed
262      from macro expansion text in collect_expansion and/or macarg.  */
263   char has_escapes;
264
265   /* True if we have already warned about C++ comments in this file.
266      The warning happens only for C89 extended mode with -pedantic on,
267      or for -Wtraditional, and only once per file (otherwise it would
268      be far too noisy).  */
269   char warned_cplusplus_comments;
270
271   /* In a file buffer, true if this buffer's data is mmapped
272      (currently never the case).  In a macro buffer, true if this
273      buffer's data must be freed.  */
274   char mapped;
275 };
276
277 struct file_name_map_list;
278 struct htab;
279
280 /* Maximum nesting of cpp_buffers.  We use a static limit, partly for
281    efficiency, and partly to limit runaway recursion.  */
282 #define CPP_STACK_MAX 200
283
284 /* Values for opts.dump_macros.
285   dump_only means inhibit output of the preprocessed text
286              and instead output the definitions of all user-defined
287              macros in a form suitable for use as input to cpp.
288    dump_names means pass #define and the macro name through to output.
289    dump_definitions means pass the whole definition (plus #define) through
290 */
291 enum { dump_none = 0, dump_only, dump_names, dump_definitions };
292
293 /* This structure is nested inside struct cpp_reader, and
294    carries all the options visible to the command line.  */
295 struct cpp_options
296 {
297   /* Name of input and output files.  */
298   const char *in_fname;
299   const char *out_fname;
300
301   /* Characters between tab stops.  */
302   unsigned int tabstop;
303
304   /* Pending options - -D, -U, -A, -I, -ixxx. */
305   struct cpp_pending *pending;
306
307   /* File name which deps are being written to.  This is 0 if deps are
308      being written to stdout.  */
309   const char *deps_file;
310
311   /* Target-name to write with the dependency information.  */
312   char *deps_target;
313
314   /* Search paths for include files.  */
315   struct file_name_list *quote_include;  /* First dir to search for "file" */
316   struct file_name_list *bracket_include;/* First dir to search for <file> */
317
318   /* Map between header names and file names, used only on DOS where
319      file names are limited in length.  */
320   struct file_name_map_list *map_list;
321
322   /* Directory prefix that should replace `/usr/lib/gcc-lib/TARGET/VERSION'
323      in the standard include file directories.  */
324   const char *include_prefix;
325   unsigned int include_prefix_len;
326
327   /* Non-0 means -v, so print the full set of include dirs.  */
328   unsigned char verbose;
329
330   /* Nonzero means use extra default include directories for C++.  */
331   unsigned char cplusplus;
332
333   /* Nonzero means handle cplusplus style comments */
334   unsigned char cplusplus_comments;
335
336   /* Nonzero means handle #import, for objective C.  */
337   unsigned char objc;
338
339   /* Nonzero means this is an assembly file, so ignore unrecognized
340      directives and the "# 33" form of #line, both of which are
341      probably comments.  Also, permit unbalanced ' strings (again,
342      likely to be in comments).  */
343   unsigned char lang_asm;
344
345   /* Nonzero means this is Fortran, and we don't know where the
346      comments are, so permit unbalanced ' strings.  Unlike lang_asm,
347      this does not ignore unrecognized directives.  */
348   unsigned char lang_fortran;
349
350   /* Nonzero means handle CHILL comment syntax and output CHILL string
351      delimiters for __DATE__ etc. */
352   unsigned char chill;
353
354   /* Nonzero means don't copy comments into the output file.  */
355   unsigned char discard_comments;
356
357   /* Nonzero means process the ANSI trigraph sequences.  */
358   unsigned char trigraphs;
359
360   /* Nonzero means print the names of included files rather than the
361      preprocessed output.  1 means just the #include "...", 2 means
362      #include <...> as well.  */
363   unsigned char print_deps;
364
365   /* Nonzero if missing .h files in -M output are assumed to be
366      generated files and not errors.  */
367   unsigned char print_deps_missing_files;
368
369   /* If true, fopen (deps_file, "a") else fopen (deps_file, "w"). */
370   unsigned char print_deps_append;
371
372   /* Nonzero means print names of header files (-H).  */
373   unsigned char print_include_names;
374
375   /* Nonzero means cpp_pedwarn causes a hard error.  */
376   unsigned char pedantic_errors;
377
378   /* Nonzero means don't print warning messages.  */
379   unsigned char inhibit_warnings;
380
381   /* Nonzero means don't print error messages.  Has no option to
382      select it, but can be set by a user of cpplib (e.g. fix-header).  */
383   unsigned char inhibit_errors;
384
385   /* Nonzero means warn if slash-star appears in a comment.  */
386   unsigned char warn_comments;
387
388   /* Nonzero means warn if there are any trigraphs.  */
389   unsigned char warn_trigraphs;
390
391   /* Nonzero means warn if #import is used.  */
392   unsigned char warn_import;
393
394   /* Nonzero means warn if a macro argument is (or would be)
395      stringified with -traditional, and warn about directives
396      with the # indented from the beginning of the line.  */
397   unsigned char warn_traditional;
398
399   /* Nonzero means turn warnings into errors.  */
400   unsigned char warnings_are_errors;
401
402   /* Nonzero causes output not to be done, but directives such as
403      #define that have side effects are still obeyed.  */
404   unsigned char no_output;
405
406   /* Nonzero means we should look for header.gcc files that remap file
407      names.  */
408   unsigned char remap;
409
410   /* Nonzero means don't output line number information.  */
411   unsigned char no_line_commands;
412
413   /* Nonzero means -I- has been seen, so don't look for #include "foo"
414      the source-file directory.  */
415   unsigned char ignore_srcdir;
416
417   /* Zero means dollar signs are punctuation. */
418   unsigned char dollars_in_ident;
419
420   /* Nonzero means try to imitate old fashioned non-ANSI preprocessor.  */
421   unsigned char traditional;
422
423   /* Nonzero means warn if undefined identifiers are evaluated in an #if.  */
424   unsigned char warn_undef;
425
426   /* Nonzero for the 1989 C Standard, including corrigenda and amendments.  */
427   unsigned char c89;
428
429   /* Nonzero for the 1999 C Standard, including corrigenda and amendments.  */
430   unsigned char c99;
431
432   /* Nonzero means give all the error messages the ANSI standard requires.  */
433   unsigned char pedantic;
434
435   /* Nonzero means we're looking at already preprocessed code, so don't
436      bother trying to do macro expansion and whatnot.  */
437   unsigned char preprocessed;
438
439   /* Nonzero disables all the standard directories for headers.  */
440   unsigned char no_standard_includes;
441
442   /* Nonzero disables the C++-specific standard directories for headers.  */
443   unsigned char no_standard_cplusplus_includes;
444
445   /* Nonzero means dump macros in some fashion - see above.  */
446   unsigned char dump_macros;
447
448   /* Nonzero means pass all #define and #undef directives which we
449      actually process through to the output stream.  This feature is
450      used primarily to allow cc1 to record the #defines and #undefs
451      for the sake of debuggers which understand about preprocessor
452      macros, but it may also be useful with -E to figure out how
453      symbols are defined, and where they are defined.  */
454   unsigned char debug_output;
455
456   /* Nonzero means pass #include lines through to the output.  */
457   unsigned char dump_includes;
458
459   /* Print column number in error messages.  */
460   unsigned char show_column;
461 };
462
463
464 /* A cpp_reader encapsulates the "state" of a pre-processor run.
465    Applying cpp_get_token repeatedly yields a stream of pre-processor
466    tokens.  Usually, there is only one cpp_reader object active. */
467
468 struct cpp_reader
469 {
470   /* Top of buffer stack.  */
471   cpp_buffer *buffer;
472
473   /* Token list used by get_directive_token.  */
474   cpp_toklist directbuf;
475
476   /* A buffer used for both for cpp_get_token's output, and also internally. */
477   unsigned char *token_buffer;
478   /* Allocated size of token_buffer.  CPP_RESERVE allocates space.  */
479   unsigned int token_buffer_size;
480   /* End of the written part of token_buffer. */
481   unsigned char *limit;
482
483   /* Error counter for exit code */
484   unsigned int errors;
485
486   /* Line where a newline was first seen in a string constant.  */
487   unsigned int multiline_string_line;
488
489   /* Current depth in #include directives that use <...>.  */
490   unsigned int system_include_depth;
491
492   /* Current depth of buffer stack. */
493   unsigned int buffer_stack_depth;
494
495   /* Hash table of macros and assertions.  See cpphash.c */
496   struct htab *hashtab;
497
498   /* Hash table of other included files.  See cppfiles.c */
499   struct splay_tree_s *all_include_files;
500
501   /* Chain of `actual directory' file_name_list entries,
502      for "" inclusion. */
503   struct file_name_list *actual_dirs;
504
505   /* Current maximum length of directory names in the search path
506      for include files.  (Altered as we get more of them.)  */
507   unsigned int max_include_len;
508
509   const cpp_hashnode *potential_control_macro;
510
511   /* Token column position adjustment owing to tabs in whitespace.  */
512   unsigned int col_adjust;
513
514   /* Buffer of -M output.  */
515   struct deps *deps;
516
517   /* A buffer used only by read_and_prescan (in cppfiles.c), which is
518      allocated once per cpp_reader object to keep it off the stack.  */
519   unsigned char *input_buffer;
520   size_t input_buffer_len;
521
522   /* User visible options.  */
523   struct cpp_options opts;
524
525   /* Nonzero means we have printed (while error reporting) a list of
526      containing files that matches the current status.  */
527   unsigned char input_stack_listing_current;
528
529   /* If non-zero, macros are not expanded.  */
530   unsigned char no_macro_expand;
531
532   /* If non-zero, directives cause a hard error.  Used when parsing
533      macro arguments.  */
534   unsigned char no_directives;
535
536   /* We're printed a warning recommending against using #import.  */
537   unsigned char import_warning;
538
539   /* If true, characters between '<' and '>' are a single (string) token.  */
540   unsigned char parsing_include_directive;
541
542   /* True if escape sequences (as described for has_escapes in
543      parse_buffer) should be emitted.  */
544   unsigned char output_escapes;
545
546   /* 0: Have seen non-white-space on this line.
547      1: Only seen white space so far on this line.
548      2: Only seen white space so far in this file.  */
549   unsigned char only_seen_white;
550
551   /* True after cpp_start_read completes.  Used to inhibit some
552      warnings while parsing the command line.  */
553   unsigned char done_initializing;
554
555   /* True if we are skipping a failed conditional group.  */
556   unsigned char skipping;
557 };
558
559 /* struct cpp_printer encapsulates state used to convert the stream of
560    tokens coming from cpp_get_token back into a text file.  Not
561    everyone wants to do that, hence we separate the function.  */
562
563 struct cpp_printer
564 {
565   FILE *outf;                   /* stream to write to */
566   const char *last_fname;       /* previous file name */
567   unsigned int last_bsd;        /* did we just push? */
568   unsigned int lineno;          /* line currently being written */
569   unsigned int written;         /* low water mark in token buffer */
570 };
571
572 #define CPP_FATAL_LIMIT 1000
573 /* True if we have seen a "fatal" error. */
574 #define CPP_FATAL_ERRORS(READER) ((READER)->errors >= CPP_FATAL_LIMIT)
575
576 /* Macros for manipulating the token_buffer. */
577
578 /* Number of characters currently in PFILE's output buffer. */
579 #define CPP_WRITTEN(PFILE) ((size_t)((PFILE)->limit - (PFILE)->token_buffer))
580 #define CPP_PWRITTEN(PFILE) ((PFILE)->limit)
581 #define CPP_ADJUST_WRITTEN(PFILE,DELTA) ((PFILE)->limit += (DELTA))
582 #define CPP_SET_WRITTEN(PFILE,N) ((PFILE)->limit = (PFILE)->token_buffer + (N))
583
584 #define CPP_OPTION(PFILE, OPTION) ((PFILE)->opts.OPTION)
585 #define CPP_BUFFER(PFILE) ((PFILE)->buffer)
586 #define CPP_BUF_LINE(BUF) ((BUF)->lineno)
587 #define CPP_BUF_COLUMN(BUF, CUR) ((CUR) - (BUF)->line_base + pfile->col_adjust)
588 #define CPP_BUF_COL(BUF) CPP_BUF_COLUMN(BUF, (BUF)->cur)
589
590 /* Name under which this program was invoked.  */
591 extern const char *progname;
592
593 /* The structure of a node in the hash table.  The hash table
594    has entries for all tokens defined by #define commands (type T_MACRO),
595    plus some special tokens like __LINE__ (these each have their own
596    type, and the appropriate code is run when that type of node is seen.
597    It does not contain control words like "#define", which are recognized
598    by a separate piece of code. */
599
600 /* different flavors of hash nodes */
601 enum node_type
602 {
603   T_VOID = 0,      /* no definition yet */
604   T_SPECLINE,      /* `__LINE__' */
605   T_DATE,          /* `__DATE__' */
606   T_FILE,          /* `__FILE__' */
607   T_BASE_FILE,     /* `__BASE_FILE__' */
608   T_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */
609   T_TIME,          /* `__TIME__' */
610   T_STDC,          /* `__STDC__' */
611   T_CONST,         /* Constant string, used by `__SIZE_TYPE__' etc */
612   T_XCONST,        /* Ditto, but the string is malloced memory */
613   T_POISON,        /* poisoned identifier */
614   T_MACRO,         /* object-like macro */
615   T_FMACRO,        /* function-like macro */
616   T_IDENTITY,      /* macro defined to itself */
617   T_EMPTY,         /* macro defined to nothing */
618   T_ASSERTION      /* predicate for #assert */
619 };
620
621 /* There is a slot in the hashnode for use by front ends when integrated
622    with cpplib.  It holds a tree (see tree.h) but we mustn't drag that
623    header into every user of cpplib.h.  cpplib does not do anything with
624    this slot except clear it when a new node is created.  */
625 union tree_node;
626
627 struct cpp_hashnode
628 {
629   unsigned int hash;                    /* cached hash value */
630   unsigned short length;                /* length of name */
631   ENUM_BITFIELD(node_type) type : 8;    /* node type */
632   char disabled;                        /* macro turned off for rescan? */
633
634   union {
635     const unsigned char *cpval;         /* some predefined macros */
636     const struct object_defn *odefn;    /* #define foo bar */
637     const struct funct_defn *fdefn;     /* #define foo(x) bar(x) */
638     struct predicate *pred;             /* #assert */
639   } value;
640
641   union tree_node *fe_value;            /* front end value */
642
643   const unsigned char name[1];          /* name[length] */
644 };
645
646
647
648 extern void _cpp_lex_file PARAMS((cpp_reader *));
649 extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
650 extern enum cpp_ttype cpp_get_token PARAMS ((cpp_reader *));
651 extern enum cpp_ttype cpp_get_non_space_token PARAMS ((cpp_reader *));
652
653 extern void cpp_reader_init PARAMS ((cpp_reader *));
654 extern cpp_printer *cpp_printer_init PARAMS ((cpp_reader *, cpp_printer *));
655 extern int cpp_start_read PARAMS ((cpp_reader *, cpp_printer *, const char *));
656 extern void cpp_output_tokens PARAMS ((cpp_reader *, cpp_printer *));
657 extern void cpp_output_list PARAMS ((cpp_reader *, cpp_printer *,
658                                      const cpp_toklist *));
659 extern void cpp_finish PARAMS ((cpp_reader *, cpp_printer *));
660 extern void cpp_cleanup PARAMS ((cpp_reader *));
661
662 extern cpp_buffer *cpp_file_buffer PARAMS((cpp_reader *));
663 extern void cpp_define PARAMS ((cpp_reader *, const char *));
664 extern void cpp_assert PARAMS ((cpp_reader *, const char *));
665 extern void cpp_undef  PARAMS ((cpp_reader *, const char *));
666 extern void cpp_unassert PARAMS ((cpp_reader *, const char *));
667
668 extern void cpp_free_token_list PARAMS ((cpp_toklist *));
669
670 /* N.B. The error-message-printer prototypes have not been nicely
671    formatted because exgettext needs to see 'msgid' on the same line
672    as the name of the function in order to work properly.  Only the
673    string argument gets a name in an effort to keep the lines from
674    getting ridiculously oversized.  */
675
676 extern void cpp_ice PARAMS ((cpp_reader *, const char *msgid, ...))
677   ATTRIBUTE_PRINTF_2;
678 extern void cpp_fatal PARAMS ((cpp_reader *, const char *msgid, ...))
679   ATTRIBUTE_PRINTF_2;
680 extern void cpp_error PARAMS ((cpp_reader *, const char *msgid, ...))
681   ATTRIBUTE_PRINTF_2;
682 extern void cpp_warning PARAMS ((cpp_reader *, const char *msgid, ...))
683   ATTRIBUTE_PRINTF_2;
684 extern void cpp_pedwarn PARAMS ((cpp_reader *, const char *msgid, ...))
685   ATTRIBUTE_PRINTF_2;
686 extern void cpp_notice PARAMS ((cpp_reader *, const char *msgid, ...))
687   ATTRIBUTE_PRINTF_2;
688 extern void cpp_error_with_line PARAMS ((cpp_reader *, int, int, const char *msgid, ...))
689   ATTRIBUTE_PRINTF_4;
690 extern void cpp_warning_with_line PARAMS ((cpp_reader *, int, int, const char *msgid, ...))
691   ATTRIBUTE_PRINTF_4;
692 extern void cpp_pedwarn_with_line PARAMS ((cpp_reader *, int, int, const char *msgid, ...))
693   ATTRIBUTE_PRINTF_4;
694 extern void cpp_pedwarn_with_file_and_line PARAMS ((cpp_reader *, const char *, int, int, const char *msgid, ...))
695   ATTRIBUTE_PRINTF_5;
696 extern void cpp_error_from_errno        PARAMS ((cpp_reader *, const char *));
697 extern void cpp_notice_from_errno       PARAMS ((cpp_reader *, const char *));
698
699 /* In cpplex.c */
700 extern cpp_buffer *cpp_push_buffer      PARAMS ((cpp_reader *,
701                                                  const unsigned char *, long));
702 extern cpp_buffer *cpp_pop_buffer       PARAMS ((cpp_reader *));
703 extern void cpp_scan_buffer             PARAMS ((cpp_reader *, cpp_printer *));
704 extern void cpp_scan_buffer_nooutput    PARAMS ((cpp_reader *));
705 extern int cpp_idcmp                    PARAMS ((const unsigned char *,
706                                                  size_t, const char *));
707
708 /* In cpphash.c */
709 extern int cpp_defined                  PARAMS ((cpp_reader *,
710                                                  const unsigned char *, int));
711 extern cpp_hashnode *cpp_lookup         PARAMS ((cpp_reader *,
712                                                  const unsigned char *, int));
713
714 /* In cppfiles.c */
715 extern int cpp_included                 PARAMS ((cpp_reader *, const char *));
716 extern int cpp_read_file                PARAMS ((cpp_reader *, const char *));
717
718 #ifdef __cplusplus
719 }
720 #endif
721 #endif /* __GCC_CPPLIB__ */