OSDN Git Service

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