OSDN Git Service

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