]> git.ipfire.org Git - thirdparty/gcc.git/blame - libcpp/include/cpplib.h
Implement -Wimplicit-fallthrough.
[thirdparty/gcc.git] / libcpp / include / cpplib.h
CommitLineData
7f2935c7 1/* Definitions for CPP library.
818ab71a 2 Copyright (C) 1995-2016 Free Software Foundation, Inc.
7f2935c7
PB
3 Written by Per Bothner, 1994-95.
4
5This program is free software; you can redistribute it and/or modify it
6under the terms of the GNU General Public License as published by the
748086b7 7Free Software Foundation; either version 3, or (at your option) any
7f2935c7
PB
8later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
748086b7
JJ
16along with this program; see the file COPYING3. If not see
17<http://www.gnu.org/licenses/>.
7f2935c7
PB
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! */
4f4e53dd
PB
22#ifndef LIBCPP_CPPLIB_H
23#define LIBCPP_CPPLIB_H
7f2935c7
PB
24
25#include <sys/types.h>
4f4e53dd 26#include "symtab.h"
d82fc108 27#include "line-map.h"
7f2935c7 28
7f2935c7
PB
29typedef struct cpp_reader cpp_reader;
30typedef struct cpp_buffer cpp_buffer;
31typedef struct cpp_options cpp_options;
1368ee70 32typedef struct cpp_token cpp_token;
bfb9dc7f 33typedef struct cpp_string cpp_string;
a50882dc 34typedef struct cpp_hashnode cpp_hashnode;
93c80368 35typedef struct cpp_macro cpp_macro;
7e96d768 36typedef struct cpp_callbacks cpp_callbacks;
8f9b4009 37typedef struct cpp_dir cpp_dir;
93c80368 38
93c80368 39struct answer;
94d1613b 40struct _cpp_file;
c5a04734 41
f8b954fc
NB
42/* The first three groups, apart from '=', can appear in preprocessor
43 expressions (+= and -= are used to indicate unary + and - resp.).
44 This allows a lookup table to be implemented in _cpp_parse_expr.
c5a04734
ZW
45
46 The first group, to CPP_LAST_EQ, can be immediately followed by an
47 '='. The lexer needs operators ending in '=', like ">>=", to be in
b52dbbf8
SE
48 the same order as their counterparts without the '=', like ">>".
49
50 See the cpp_operator table optab in expr.c if you change the order or
51 add or remove anything in the first group. */
c5a04734 52
21b11495
ZW
53#define TTYPE_TABLE \
54 OP(EQ, "=") \
55 OP(NOT, "!") \
56 OP(GREATER, ">") /* compare */ \
57 OP(LESS, "<") \
58 OP(PLUS, "+") /* math */ \
59 OP(MINUS, "-") \
60 OP(MULT, "*") \
61 OP(DIV, "/") \
62 OP(MOD, "%") \
63 OP(AND, "&") /* bit ops */ \
64 OP(OR, "|") \
65 OP(XOR, "^") \
66 OP(RSHIFT, ">>") \
67 OP(LSHIFT, "<<") \
21b11495
ZW
68 \
69 OP(COMPL, "~") \
70 OP(AND_AND, "&&") /* logical */ \
71 OP(OR_OR, "||") \
72 OP(QUERY, "?") \
73 OP(COLON, ":") \
74 OP(COMMA, ",") /* grouping */ \
75 OP(OPEN_PAREN, "(") \
76 OP(CLOSE_PAREN, ")") \
77 TK(EOF, NONE) \
78 OP(EQ_EQ, "==") /* compare */ \
79 OP(NOT_EQ, "!=") \
80 OP(GREATER_EQ, ">=") \
81 OP(LESS_EQ, "<=") \
82 \
83 /* These two are unary + / - in preprocessor expressions. */ \
84 OP(PLUS_EQ, "+=") /* math */ \
85 OP(MINUS_EQ, "-=") \
86 \
87 OP(MULT_EQ, "*=") \
88 OP(DIV_EQ, "/=") \
89 OP(MOD_EQ, "%=") \
90 OP(AND_EQ, "&=") /* bit ops */ \
91 OP(OR_EQ, "|=") \
92 OP(XOR_EQ, "^=") \
93 OP(RSHIFT_EQ, ">>=") \
94 OP(LSHIFT_EQ, "<<=") \
21b11495
ZW
95 /* Digraphs together, beginning with CPP_FIRST_DIGRAPH. */ \
96 OP(HASH, "#") /* digraphs */ \
97 OP(PASTE, "##") \
98 OP(OPEN_SQUARE, "[") \
99 OP(CLOSE_SQUARE, "]") \
100 OP(OPEN_BRACE, "{") \
101 OP(CLOSE_BRACE, "}") \
102 /* The remainder of the punctuation. Order is not significant. */ \
103 OP(SEMICOLON, ";") /* structure */ \
104 OP(ELLIPSIS, "...") \
105 OP(PLUS_PLUS, "++") /* increment */ \
106 OP(MINUS_MINUS, "--") \
107 OP(DEREF, "->") /* accessors */ \
108 OP(DOT, ".") \
109 OP(SCOPE, "::") \
110 OP(DEREF_STAR, "->*") \
111 OP(DOT_STAR, ".*") \
112 OP(ATSIGN, "@") /* used in Objective-C */ \
113 \
114 TK(NAME, IDENT) /* word */ \
115 TK(AT_NAME, IDENT) /* @word - Objective-C */ \
116 TK(NUMBER, LITERAL) /* 34_be+ta */ \
117 \
118 TK(CHAR, LITERAL) /* 'char' */ \
119 TK(WCHAR, LITERAL) /* L'char' */ \
b6baa67d
KVH
120 TK(CHAR16, LITERAL) /* u'char' */ \
121 TK(CHAR32, LITERAL) /* U'char' */ \
fe95b036 122 TK(UTF8CHAR, LITERAL) /* u8'char' */ \
21b11495
ZW
123 TK(OTHER, LITERAL) /* stray punctuation */ \
124 \
125 TK(STRING, LITERAL) /* "string" */ \
126 TK(WSTRING, LITERAL) /* L"string" */ \
b6baa67d
KVH
127 TK(STRING16, LITERAL) /* u"string" */ \
128 TK(STRING32, LITERAL) /* U"string" */ \
2c6e3f55 129 TK(UTF8STRING, LITERAL) /* u8"string" */ \
21b11495
ZW
130 TK(OBJC_STRING, LITERAL) /* @"string" - Objective-C */ \
131 TK(HEADER_NAME, LITERAL) /* <stdio.h> in #include */ \
132 \
3ce4f9e4
ESR
133 TK(CHAR_USERDEF, LITERAL) /* 'char'_suffix - C++-0x */ \
134 TK(WCHAR_USERDEF, LITERAL) /* L'char'_suffix - C++-0x */ \
135 TK(CHAR16_USERDEF, LITERAL) /* u'char'_suffix - C++-0x */ \
136 TK(CHAR32_USERDEF, LITERAL) /* U'char'_suffix - C++-0x */ \
fe95b036 137 TK(UTF8CHAR_USERDEF, LITERAL) /* u8'char'_suffix - C++-0x */ \
3ce4f9e4
ESR
138 TK(STRING_USERDEF, LITERAL) /* "string"_suffix - C++-0x */ \
139 TK(WSTRING_USERDEF, LITERAL) /* L"string"_suffix - C++-0x */ \
140 TK(STRING16_USERDEF, LITERAL) /* u"string"_suffix - C++-0x */ \
141 TK(STRING32_USERDEF, LITERAL) /* U"string"_suffix - C++-0x */ \
142 TK(UTF8STRING_USERDEF,LITERAL) /* u8"string"_suffix - C++-0x */ \
143 \
21b11495
ZW
144 TK(COMMENT, LITERAL) /* Only if output comments. */ \
145 /* SPELL_LITERAL happens to DTRT. */ \
146 TK(MACRO_ARG, NONE) /* Macro argument. */ \
bc4071dd
RH
147 TK(PRAGMA, NONE) /* Only for deferred pragmas. */ \
148 TK(PRAGMA_EOL, NONE) /* End-of-line for deferred pragmas. */ \
21b11495
ZW
149 TK(PADDING, NONE) /* Whitespace for -E. */
150
151#define OP(e, s) CPP_ ## e,
152#define TK(e, s) CPP_ ## e,
3a2b2c7a 153enum cpp_ttype
c45da1ca 154{
1368ee70 155 TTYPE_TABLE
21b11495
ZW
156 N_TTYPES,
157
083e891e
MP
158 /* A token type for keywords, as opposed to ordinary identifiers. */
159 CPP_KEYWORD,
160
21b11495 161 /* Positions in the table. */
b52dbbf8 162 CPP_LAST_EQ = CPP_LSHIFT,
21b11495 163 CPP_FIRST_DIGRAPH = CPP_HASH,
b52dbbf8 164 CPP_LAST_PUNCTUATOR= CPP_ATSIGN,
21b11495 165 CPP_LAST_CPP_OP = CPP_LESS_EQ
1368ee70 166};
96be6998
ZW
167#undef OP
168#undef TK
1368ee70 169
ecfd72e7 170/* C language kind, used when calling cpp_create_reader. */
48b0b196
JM
171enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11,
172 CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_STDC11,
61949153 173 CLK_GNUCXX, CLK_CXX98, CLK_GNUCXX11, CLK_CXX11,
e4276ba5 174 CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX1Z, CLK_CXX1Z, CLK_ASM};
dd07b884 175
5d8ebbd8 176/* Payload of a NUMBER, STRING, CHAR or COMMENT token. */
d1b38208 177struct GTY(()) cpp_string {
1368ee70 178 unsigned int len;
f617b8e2 179 const unsigned char *text;
1368ee70
ZW
180};
181
c5a04734 182/* Flags for the cpp_token structure. */
041c3194 183#define PREV_WHITE (1 << 0) /* If whitespace before this token. */
93c80368
NB
184#define DIGRAPH (1 << 1) /* If it was a digraph. */
185#define STRINGIFY_ARG (1 << 2) /* If macro argument to be stringified. */
186#define PASTE_LEFT (1 << 3) /* If on LHS of a ## operator. */
dd07b884 187#define NAMED_OP (1 << 4) /* C++ named operators. */
81fea426
MP
188#define PREV_FALLTHROUGH (1 << 5) /* On a token preceeded by FALLTHROUGH
189 comment. */
4ed5bcfb 190#define BOL (1 << 6) /* Token at beginning of line. */
ab84748a
VR
191#define PURE_ZERO (1 << 7) /* Single 0 digit, used by the C++ frontend,
192 set in c-lex.c. */
aa508502
JM
193#define SP_DIGRAPH (1 << 8) /* # or ## token was a digraph. */
194#define SP_PREV_WHITE (1 << 9) /* If whitespace before a ##
195 operator, or before this token
196 after a # operator. */
81fea426 197#define NO_EXPAND (1 << 10) /* Do not macro-expand this token. */
9e62c811 198
d8044160
GK
199/* Specify which field, if any, of the cpp_token union is used. */
200
201enum cpp_token_fld_kind {
202 CPP_TOKEN_FLD_NODE,
203 CPP_TOKEN_FLD_SOURCE,
204 CPP_TOKEN_FLD_STR,
205 CPP_TOKEN_FLD_ARG_NO,
9a0c6187 206 CPP_TOKEN_FLD_TOKEN_NO,
bc4071dd 207 CPP_TOKEN_FLD_PRAGMA,
d8044160
GK
208 CPP_TOKEN_FLD_NONE
209};
210
9a0c6187
JM
211/* A macro argument in the cpp_token union. */
212struct GTY(()) cpp_macro_arg {
213 /* Argument number. */
214 unsigned int arg_no;
be5ffc59
JM
215 /* The original spelling of the macro argument token. */
216 cpp_hashnode *
217 GTY ((nested_ptr (union tree_node,
218 "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
219 "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL")))
220 spelling;
9a0c6187
JM
221};
222
223/* An identifier in the cpp_token union. */
224struct GTY(()) cpp_identifier {
225 /* The canonical (UTF-8) spelling of the identifier. */
226 cpp_hashnode *
227 GTY ((nested_ptr (union tree_node,
228 "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
229 "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL")))
230 node;
be5ffc59
JM
231 /* The original spelling of the identifier. */
232 cpp_hashnode *
233 GTY ((nested_ptr (union tree_node,
234 "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
235 "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL")))
236 spelling;
9a0c6187
JM
237};
238
1920de47 239/* A preprocessing token. This has been carefully packed and should
644eddaa 240 occupy 16 bytes on 32-bit hosts and 24 bytes on 64-bit hosts. */
d1b38208 241struct GTY(()) cpp_token {
ebedc9a3
DM
242 source_location src_loc; /* Location of first char of token,
243 together with range of full token. */
041c3194 244 ENUM_BITFIELD(cpp_ttype) type : CHAR_BIT; /* token type */
aa508502 245 unsigned short flags; /* flags - see above */
041c3194 246
d8044160 247 union cpp_token_u
1368ee70 248 {
d8044160 249 /* An identifier. */
9a0c6187 250 struct cpp_identifier GTY ((tag ("CPP_TOKEN_FLD_NODE"))) node;
d8044160
GK
251
252 /* Inherit padding from this token. */
253 cpp_token * GTY ((tag ("CPP_TOKEN_FLD_SOURCE"))) source;
254
255 /* A string, or number. */
256 struct cpp_string GTY ((tag ("CPP_TOKEN_FLD_STR"))) str;
257
be5ffc59 258 /* Argument no. (and original spelling) for a CPP_MACRO_ARG. */
9a0c6187
JM
259 struct cpp_macro_arg GTY ((tag ("CPP_TOKEN_FLD_ARG_NO"))) macro_arg;
260
261 /* Original token no. for a CPP_PASTE (from a sequence of
262 consecutive paste tokens in a macro expansion). */
263 unsigned int GTY ((tag ("CPP_TOKEN_FLD_TOKEN_NO"))) token_no;
bc4071dd
RH
264
265 /* Caller-supplied identifier for a CPP_PRAGMA. */
266 unsigned int GTY ((tag ("CPP_TOKEN_FLD_PRAGMA"))) pragma;
d8044160 267 } GTY ((desc ("cpp_token_val_index (&%1)"))) val;
7f2935c7
PB
268};
269
d8044160 270/* Say which field is in use. */
c26302d5 271extern enum cpp_token_fld_kind cpp_token_val_index (const cpp_token *tok);
d8044160 272
4268e8bb 273/* A type wide enough to hold any multibyte source character.
625458d0 274 cpplib's character constant interpreter requires an unsigned type.
43839642
ZW
275 Also, a typedef for the signed equivalent.
276 The width of this type is capped at 32 bits; there do exist targets
277 where wchar_t is 64 bits, but only in a non-default mode, and there
278 would be no meaningful interpretation for a wchar_t value greater
279 than 2^32 anyway -- the widest wide-character encoding around is
280 ISO 10646, which stops at 2^31. */
281#if CHAR_BIT * SIZEOF_INT >= 32
625458d0 282# define CPPCHAR_SIGNED_T int
43839642
ZW
283#elif CHAR_BIT * SIZEOF_LONG >= 32
284# define CPPCHAR_SIGNED_T long
625458d0 285#else
43839642 286# error "Cannot find a least-32-bit signed integer type"
625458d0
NB
287#endif
288typedef unsigned CPPCHAR_SIGNED_T cppchar_t;
289typedef CPPCHAR_SIGNED_T cppchar_signed_t;
0d9f234d 290
72bb2c39
BI
291/* Style of header dependencies to generate. */
292enum cpp_deps_style { DEPS_NONE = 0, DEPS_USER, DEPS_SYSTEM };
293
50668cf6
GK
294/* The possible normalization levels, from most restrictive to least. */
295enum cpp_normalize_level {
296 /* In NFKC. */
297 normalized_KC = 0,
298 /* In NFC. */
299 normalized_C,
300 /* In NFC, except for subsequences where being in NFC would make
301 the identifier invalid. */
302 normalized_identifier_C,
303 /* Not normalized at all. */
304 normalized_none
305};
306
ae79697b
ZW
307/* This structure is nested inside struct cpp_reader, and
308 carries all the options visible to the command line. */
309struct cpp_options
c50bca08 310{
6ab3e7dd
NB
311 /* Characters between tab stops. */
312 unsigned int tabstop;
313
bdb05a7b
NB
314 /* The language we're preprocessing. */
315 enum c_lang lang;
316
7f2935c7 317 /* Nonzero means use extra default include directories for C++. */
ae79697b 318 unsigned char cplusplus;
7f2935c7 319
6614fd40 320 /* Nonzero means handle cplusplus style comments. */
ae79697b 321 unsigned char cplusplus_comments;
7f2935c7 322
899015a0
TT
323 /* Nonzero means define __OBJC__, treat @ as a special token, use
324 the OBJC[PLUS]_INCLUDE_PATH environment variable, and allow
325 "#import". */
ae79697b 326 unsigned char objc;
7f2935c7 327
564ad5f4 328 /* Nonzero means don't copy comments into the output file. */
ae79697b 329 unsigned char discard_comments;
7f2935c7 330
477cdac7
JT
331 /* Nonzero means don't copy comments into the output file during
332 macro expansion. */
333 unsigned char discard_comments_in_macro_exp;
334
041c3194 335 /* Nonzero means process the ISO trigraph sequences. */
ae79697b 336 unsigned char trigraphs;
7f2935c7 337
9b55f29a
NB
338 /* Nonzero means process the ISO digraph sequences. */
339 unsigned char digraphs;
340
bdb05a7b
NB
341 /* Nonzero means to allow hexadecimal floats and LL suffixes. */
342 unsigned char extended_numbers;
343
b6baa67d
KVH
344 /* Nonzero means process u/U prefix literals (UTF-16/32). */
345 unsigned char uliterals;
346
fe95b036
ESR
347 /* Nonzero means process u8 prefixed character literals (UTF-8). */
348 unsigned char utf8_char_literals;
349
7c1ffff9 350 /* Nonzero means process r/R raw strings. If this is set, uliterals
a48e3dd1
JM
351 must be set as well. */
352 unsigned char rliterals;
353
7f2935c7 354 /* Nonzero means print names of header files (-H). */
ae79697b 355 unsigned char print_include_names;
7f2935c7 356
9fbd3e41 357 /* Nonzero means complain about deprecated features. */
e3339d0f 358 unsigned char cpp_warn_deprecated;
9fbd3e41 359
7f2935c7 360 /* Nonzero means warn if slash-star appears in a comment. */
ae79697b 361 unsigned char warn_comments;
7f2935c7 362
e8ff5196
TB
363 /* Nonzero means to warn about __DATA__, __TIME__ and __TIMESTAMP__ usage. */
364 unsigned char warn_date_time;
365
b02398bd
BE
366 /* Nonzero means warn if a user-supplied include directory does not
367 exist. */
368 unsigned char warn_missing_include_dirs;
369
7f2935c7 370 /* Nonzero means warn if there are any trigraphs. */
ae79697b 371 unsigned char warn_trigraphs;
7f2935c7 372
a5a49440
NB
373 /* Nonzero means warn about multicharacter charconsts. */
374 unsigned char warn_multichar;
375
f9a0e96c
ZW
376 /* Nonzero means warn about various incompatibilities with
377 traditional C. */
e3339d0f 378 unsigned char cpp_warn_traditional;
7f2935c7 379
cd7ab83f 380 /* Nonzero means warn about long long numeric constants. */
e3339d0f 381 unsigned char cpp_warn_long_long;
cd7ab83f 382
909de5da
PE
383 /* Nonzero means warn about text after an #endif (or #else). */
384 unsigned char warn_endif_labels;
385
68e65275
NB
386 /* Nonzero means warn about implicit sign changes owing to integer
387 promotions. */
388 unsigned char warn_num_sign_change;
389
e5b79219
RH
390 /* Zero means don't warn about __VA_ARGS__ usage in c89 pedantic mode.
391 Presumably the usage is protected by the appropriate #ifdef. */
392 unsigned char warn_variadic_macros;
393
c047ce93
SB
394 /* Nonzero means warn about builtin macros that are redefined or
395 explicitly undefined. */
396 unsigned char warn_builtin_macro_redefined;
397
31031edd
JL
398 /* Nonzero means we should look for header.gcc files that remap file
399 names. */
ae79697b 400 unsigned char remap;
31031edd 401
eebedaa5 402 /* Zero means dollar signs are punctuation. */
ae79697b 403 unsigned char dollars_in_ident;
7f2935c7 404
af15a2fe
JM
405 /* Nonzero means UCNs are accepted in identifiers. */
406 unsigned char extended_identifiers;
407
78b8811a
HPN
408 /* True if we should warn about dollars in identifiers or numbers
409 for this translation unit. */
410 unsigned char warn_dollars;
411
6ac34fdc 412 /* Nonzero means warn if undefined identifiers are evaluated in an #if. */
ae79697b 413 unsigned char warn_undef;
6ac34fdc 414
a69cbaac
NB
415 /* Nonzero means warn of unused macros from the main file. */
416 unsigned char warn_unused_macros;
417
31948547 418 /* Nonzero for the 1999 C Standard, including corrigenda and amendments. */
ae79697b 419 unsigned char c99;
31948547 420
58551c23
NB
421 /* Nonzero if we are conforming to a specific C or C++ standard. */
422 unsigned char std;
423
7f2935c7 424 /* Nonzero means give all the error messages the ANSI standard requires. */
e3339d0f 425 unsigned char cpp_pedantic;
7f2935c7 426
3773a46b
JM
427 /* Nonzero means we're looking at already preprocessed code, so don't
428 bother trying to do macro expansion and whatnot. */
ae79697b 429 unsigned char preprocessed;
847e697a
TT
430
431 /* Nonzero means we are going to emit debugging logs during
432 preprocessing. */
433 unsigned char debug;
3773a46b 434
92582b75
TT
435 /* Nonzero means we are tracking locations of tokens involved in
436 macro expansion. 1 Means we track the location in degraded mode
437 where we do not track locations of tokens resulting from the
438 expansion of arguments of function-like macro. 2 Means we do
439 track all macro expansions. This last option is the one that
440 consumes the highest amount of memory. */
441 unsigned char track_macro_expansion;
442
644eddaa 443 /* Nonzero means handle C++ alternate operator names. */
be768055 444 unsigned char operator_names;
7e96d768 445
3d8b2a98
ILT
446 /* Nonzero means warn about use of C++ alternate operator names. */
447 unsigned char warn_cxx_operator_names;
448
004cb263
NB
449 /* True for traditional preprocessing. */
450 unsigned char traditional;
451
01187df0 452 /* Nonzero for C++ 2011 Standard user-defined literals. */
3ce4f9e4
ESR
453 unsigned char user_literals;
454
7f5f5f98
OW
455 /* Nonzero means warn when a string or character literal is followed by a
456 ud-suffix which does not beging with an underscore. */
457 unsigned char warn_literal_suffix;
458
a4a0016d
ESR
459 /* Nonzero means interpret imaginary, fixed-point, or other gnu extension
460 literal number suffixes as user-defined literal number suffixes. */
461 unsigned char ext_numeric_literals;
462
d3f4ff8b
JM
463 /* Nonzero means extended identifiers allow the characters specified
464 in C11 and C++11. */
465 unsigned char c11_identifiers;
466
01187df0
JJ
467 /* Nonzero for C++ 2014 Standard binary constants. */
468 unsigned char binary_constants;
469
7057e645
ESR
470 /* Nonzero for C++ 2014 Standard digit separators. */
471 unsigned char digit_separators;
472
e6cc3a24
ZW
473 /* Holds the name of the target (execution) character set. */
474 const char *narrow_charset;
475
476 /* Holds the name of the target wide character set. */
477 const char *wide_charset;
478
cf551fba
EC
479 /* Holds the name of the input character set. */
480 const char *input_charset;
481
50668cf6 482 /* The minimum permitted level of normalization before a warning
1ef33fd4
MLI
483 is generated. See enum cpp_normalize_level. */
484 int warn_normalize;
50668cf6 485
783e2989
NB
486 /* True to warn about precompiled header files we couldn't use. */
487 bool warn_invalid_pch;
488
489 /* True if dependencies should be restored from a precompiled header. */
490 bool restore_pch_deps;
491
f3bede71 492 /* True if warn about differences between C90 and C99. */
dd3ff077 493 signed char cpp_warn_c90_c99_compat;
f3bede71 494
fe191308
JM
495 /* True if warn about differences between C++98 and C++11. */
496 bool cpp_warn_cxx11_compat;
497
f4ff5a69
NB
498 /* Dependency generation. */
499 struct
500 {
501 /* Style of header dependencies to generate. */
72bb2c39 502 enum cpp_deps_style style;
f4ff5a69
NB
503
504 /* Assume missing files are generated files. */
505 bool missing_files;
506
507 /* Generate phony targets for each dependency apart from the first
508 one. */
509 bool phony_targets;
182d89a3
NB
510
511 /* If true, no dependency is generated on the main file. */
512 bool ignore_main_file;
74dc6a11
CD
513
514 /* If true, intend to use the preprocessor output (e.g., for compilation)
515 in addition to the dependency info. */
516 bool need_preprocessor_output;
f4ff5a69
NB
517 } deps;
518
44a147ad
NB
519 /* Target-specific features set by the front end or client. */
520
521 /* Precision for target CPP arithmetic, target characters, target
522 ints and target wide characters, respectively. */
523 size_t precision, char_precision, int_precision, wchar_precision;
524
23ff0223
NB
525 /* True means chars (wide chars) are unsigned. */
526 bool unsigned_char, unsigned_wchar;
5279d739 527
e6cc3a24
ZW
528 /* True if the most significant byte in a word has the lowest
529 address in memory. */
530 bool bytes_big_endian;
783e2989 531
5279d739
ZW
532 /* Nonzero means __STDC__ should have the value 0 in system headers. */
533 unsigned char stdc_0_in_system_headers;
21b11495 534
ccfc4c91
OW
535 /* True disables tokenization outside of preprocessing directives. */
536 bool directives_only;
5dc99c46
SB
537
538 /* True enables canonicalization of system header file paths. */
539 bool canonical_system_headers;
ae79697b 540};
7f2935c7 541
94d1613b
MS
542/* Callback for header lookup for HEADER, which is the name of a
543 source file. It is used as a method of last resort to find headers
544 that are not otherwise found during the normal include processing.
545 The return value is the malloced name of a header to try and open,
546 if any, or NULL otherwise. This callback is called only if the
547 header is otherwise unfound. */
e3c287c9 548typedef const char *(*missing_header_cb)(cpp_reader *, const char *header, cpp_dir **);
94d1613b 549
48c4721e 550/* Call backs to cpplib client. */
7e96d768
NB
551struct cpp_callbacks
552{
97293897 553 /* Called when a new line of preprocessed output is started. */
6cf87ca4 554 void (*line_change) (cpp_reader *, const cpp_token *, int);
4dc299fb
PB
555
556 /* Called when switching to/from a new file.
557 The line_map is for the new file. It is NULL if there is no new file.
558 (In C this happens when done with <built-in>+<command line> and also
559 when done with a main file.) This can be used for resource cleanup. */
0e50b624 560 void (*file_change) (cpp_reader *, const line_map_ordinary *);
4dc299fb 561
b20d9f0c 562 void (*dir_change) (cpp_reader *, const char *);
d0a9fbe1 563 void (*include) (cpp_reader *, source_location, const unsigned char *,
cbc43ae0 564 const char *, int, const cpp_token **);
d0a9fbe1
DS
565 void (*define) (cpp_reader *, source_location, cpp_hashnode *);
566 void (*undef) (cpp_reader *, source_location, cpp_hashnode *);
567 void (*ident) (cpp_reader *, source_location, const cpp_string *);
568 void (*def_pragma) (cpp_reader *, source_location);
6cf87ca4
ZW
569 int (*valid_pch) (cpp_reader *, const char *, int);
570 void (*read_pch) (cpp_reader *, const char *, int, const char *);
94d1613b 571 missing_header_cb missing_header;
178b58b5 572
5950c3c9
BE
573 /* Context-sensitive macro support. Returns macro (if any) that should
574 be expanded. */
575 cpp_hashnode * (*macro_to_expand) (cpp_reader *, const cpp_token *);
576
148e4216
JM
577 /* Called to emit a diagnostic. This callback receives the
578 translated message. */
8a645150 579 bool (*error) (cpp_reader *, int, int, rich_location *,
148e4216 580 const char *, va_list *)
8a645150 581 ATTRIBUTE_FPTR_PRINTF(5,0);
93d45d9e
JM
582
583 /* Callbacks for when a macro is expanded, or tested (whether
584 defined or not at the time) in #ifdef, #ifndef or "defined". */
d0a9fbe1
DS
585 void (*used_define) (cpp_reader *, source_location, cpp_hashnode *);
586 void (*used_undef) (cpp_reader *, source_location, cpp_hashnode *);
93d45d9e
JM
587 /* Called before #define and #undef or other macro definition
588 changes are processed. */
589 void (*before_define) (cpp_reader *);
3de8a540
AC
590 /* Called whenever a macro is expanded or tested.
591 Second argument is the location of the start of the current expansion. */
592 void (*used) (cpp_reader *, source_location, cpp_hashnode *);
8e680db5 593
42fd12b1
ESR
594 /* Callback to identify whether an attribute exists. */
595 int (*has_attribute) (cpp_reader *);
596
8e680db5
JJ
597 /* Callback that can change a user builtin into normal macro. */
598 bool (*user_builtin_macro) (cpp_reader *, cpp_hashnode *);
15c98b2e
ES
599
600 /* Callback to parse SOURCE_DATE_EPOCH from environment. */
601 time_t (*get_source_date_epoch) (cpp_reader *);
cb18fd07
DM
602
603 /* Callback for providing suggestions for misspelled directives. */
604 const char *(*get_suggestion) (cpp_reader *, const char *, const char *const *);
7e96d768
NB
605};
606
0c539b47
DR
607#ifdef VMS
608#define INO_T_CPP ino_t ino[3]
609#else
610#define INO_T_CPP ino_t ino
611#endif
612
5793b276 613/* Chain of directories to look for include files in. */
8f9b4009 614struct cpp_dir
5793b276
NB
615{
616 /* NULL-terminated singly-linked list. */
8f9b4009 617 struct cpp_dir *next;
5793b276 618
8f9b4009 619 /* NAME of the directory, NUL-terminated. */
5793b276
NB
620 char *name;
621 unsigned int len;
622
623 /* One if a system header, two if a system header that has extern
624 "C" guards for C++. */
625 unsigned char sysp;
626
8f5929e1
JJ
627 /* Is this a user-supplied directory? */
628 bool user_supplied_p;
629
630 /* The canonicalized NAME as determined by lrealpath. This field
631 is only used by hosts that lack reliable inode numbers. */
632 char *canonical_name;
633
8f9b4009
NB
634 /* Mapping of file names for this directory for MS-DOS and related
635 platforms. A NULL-terminated array of (from, to) pairs. */
636 const char **name_map;
cf551fba 637
94d1613b
MS
638 /* Routine to construct pathname, given the search path name and the
639 HEADER we are trying to find, return a constructed pathname to
640 try and open. If this is NULL, the constructed pathname is as
641 constructed by append_file_to_dir. */
642 char *(*construct) (const char *header, cpp_dir *dir);
643
5793b276
NB
644 /* The C front end uses these to recognize duplicated
645 directories in the search path. */
0c539b47 646 INO_T_CPP;
5793b276
NB
647 dev_t dev;
648};
649
93c80368
NB
650/* The structure of a node in the hash table. The hash table has
651 entries for all identifiers: either macros defined by #define
652 commands (type NT_MACRO), assertions created with #assert
653 (NT_ASSERTION), or neither of the above (NT_VOID). Builtin macros
95bd1dd7 654 like __LINE__ are flagged NODE_BUILTIN. Poisoned identifiers are
93c80368
NB
655 flagged NODE_POISONED. NODE_OPERATOR (C++ only) indicates an
656 identifier that behaves like an operator such as "xor".
657 NODE_DIAGNOSTIC is for speed in lex_token: it indicates a
658 diagnostic may be required for this node. Currently this only
3d8b2a98
ILT
659 applies to __VA_ARGS__, poisoned identifiers, and -Wc++-compat
660 warnings about NODE_OPERATOR. */
93c80368
NB
661
662/* Hash node flags. */
663#define NODE_OPERATOR (1 << 0) /* C++ named operator. */
664#define NODE_POISONED (1 << 1) /* Poisoned identifier. */
665#define NODE_BUILTIN (1 << 2) /* Builtin macro. */
666#define NODE_DIAGNOSTIC (1 << 3) /* Possible diagnostic when lexed. */
618cdda7 667#define NODE_WARN (1 << 4) /* Warn if redefined or undefined. */
644eddaa 668#define NODE_DISABLED (1 << 5) /* A disabled macro. */
71c0e7fc 669#define NODE_MACRO_ARG (1 << 6) /* Used during #define processing. */
93d45d9e 670#define NODE_USED (1 << 7) /* Dumped with -dU. */
5950c3c9 671#define NODE_CONDITIONAL (1 << 8) /* Conditional macro */
3d8b2a98 672#define NODE_WARN_OPERATOR (1 << 9) /* Warn about C++ named operator. */
93c80368
NB
673
674/* Different flavors of hash node. */
f8f769ea
ZW
675enum node_type
676{
93c80368
NB
677 NT_VOID = 0, /* No definition yet. */
678 NT_MACRO, /* A macro of some form. */
679 NT_ASSERTION /* Predicate for #assert. */
680};
681
644eddaa
NB
682/* Different flavors of builtin macro. _Pragma is an operator, but we
683 handle it with the builtin code for efficiency reasons. */
7e5487a2 684enum cpp_builtin_type
93c80368
NB
685{
686 BT_SPECLINE = 0, /* `__LINE__' */
687 BT_DATE, /* `__DATE__' */
688 BT_FILE, /* `__FILE__' */
689 BT_BASE_FILE, /* `__BASE_FILE__' */
690 BT_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */
691 BT_TIME, /* `__TIME__' */
644eddaa 692 BT_STDC, /* `__STDC__' */
be8ac3e2 693 BT_PRAGMA, /* `_Pragma' operator */
a702045a 694 BT_TIMESTAMP, /* `__TIMESTAMP__' */
8e680db5 695 BT_COUNTER, /* `__COUNTER__' */
1f8d3e84 696 BT_HAS_ATTRIBUTE, /* `__has_attribute__(x)' */
8e680db5
JJ
697 BT_FIRST_USER, /* User defined builtin macros. */
698 BT_LAST_USER = BT_FIRST_USER + 31
f8f769ea
ZW
699};
700
2a967f3d
NB
701#define CPP_HASHNODE(HNODE) ((cpp_hashnode *) (HNODE))
702#define HT_NODE(NODE) ((ht_identifier *) (NODE))
703#define NODE_LEN(NODE) HT_LEN (&(NODE)->ident)
704#define NODE_NAME(NODE) HT_STR (&(NODE)->ident)
f8f769ea 705
d8044160
GK
706/* Specify which field, if any, of the union is used. */
707
708enum {
709 NTV_MACRO,
710 NTV_ANSWER,
711 NTV_BUILTIN,
712 NTV_ARGUMENT,
713 NTV_NONE
714};
715
716#define CPP_HASHNODE_VALUE_IDX(HNODE) \
717 ((HNODE.flags & NODE_MACRO_ARG) ? NTV_ARGUMENT \
718 : HNODE.type == NT_MACRO ? ((HNODE.flags & NODE_BUILTIN) \
719 ? NTV_BUILTIN : NTV_MACRO) \
720 : HNODE.type == NT_ASSERTION ? NTV_ANSWER \
721 : NTV_NONE)
722
2a967f3d
NB
723/* The common part of an identifier node shared amongst all 3 C front
724 ends. Also used to store CPP identifiers, which are a superset of
725 identifiers in the grammatical sense. */
c3f829c1 726
d1b38208 727union GTY(()) _cpp_hashnode_value {
c3f829c1
GDR
728 /* If a macro. */
729 cpp_macro * GTY((tag ("NTV_MACRO"))) macro;
730 /* Answers to an assertion. */
731 struct answer * GTY ((tag ("NTV_ANSWER"))) answers;
732 /* Code for a builtin macro. */
7e5487a2 733 enum cpp_builtin_type GTY ((tag ("NTV_BUILTIN"))) builtin;
c3f829c1
GDR
734 /* Macro argument index. */
735 unsigned short GTY ((tag ("NTV_ARGUMENT"))) arg_index;
736};
737
d1b38208 738struct GTY(()) cpp_hashnode {
2a967f3d 739 struct ht_identifier ident;
4977bab6 740 unsigned int is_directive : 1;
cf551fba 741 unsigned int directive_index : 7; /* If is_directive,
4977bab6 742 then index into directive table.
71c0e7fc 743 Otherwise, a NODE_OPERATOR. */
2a967f3d 744 unsigned char rid_code; /* Rid code - for front ends. */
3d8b2a98
ILT
745 ENUM_BITFIELD(node_type) type : 6; /* CPP node type. */
746 unsigned int flags : 10; /* CPP flags. */
f8f769ea 747
c3f829c1 748 union _cpp_hashnode_value GTY ((desc ("CPP_HASHNODE_VALUE_IDX (%1)"))) value;
f8f769ea
ZW
749};
750
88fa5555
DM
751/* A class for iterating through the source locations within a
752 string token (before escapes are interpreted, and before
753 concatenation). */
754
755class cpp_string_location_reader {
756 public:
757 cpp_string_location_reader (source_location src_loc,
758 line_maps *line_table);
759
760 source_range get_next ();
761
762 private:
763 source_location m_loc;
764 int m_offset_per_column;
765 line_maps *m_line_table;
766};
767
768/* A class for storing the source ranges of all of the characters within
769 a string literal, after escapes are interpreted, and after
770 concatenation.
771
772 This is not GTY-marked, as instances are intended to be temporary. */
773
774class cpp_substring_ranges
775{
776 public:
777 cpp_substring_ranges ();
778 ~cpp_substring_ranges ();
779
780 int get_num_ranges () const { return m_num_ranges; }
781 source_range get_range (int idx) const
782 {
783 linemap_assert (idx < m_num_ranges);
784 return m_ranges[idx];
785 }
786
787 void add_range (source_range range);
788 void add_n_ranges (int num, cpp_string_location_reader &loc_reader);
789
790 private:
791 source_range *m_ranges;
792 int m_num_ranges;
793 int m_alloc_ranges;
794};
795
b4e46cea
PB
796/* Call this first to get a handle to pass to other functions.
797
798 If you want cpplib to manage its own hashtable, pass in a NULL
799 pointer. Otherwise you should pass in an initialized hash table
800 that cpplib will share; this technique is used by the C front
801 ends. */
50f59cd7
PB
802extern cpp_reader *cpp_create_reader (enum c_lang, struct ht *,
803 struct line_maps *);
400023a3 804
5ffeb913
TT
805/* Reset the cpp_reader's line_map. This is only used after reading a
806 PCH file. */
807extern void cpp_set_line_map (cpp_reader *, struct line_maps *);
808
f749a36b
NB
809/* Call this to change the selected language standard (e.g. because of
810 command line options). */
6cf87ca4 811extern void cpp_set_lang (cpp_reader *, enum c_lang);
f749a36b 812
5793b276 813/* Set the include paths. */
8f9b4009 814extern void cpp_set_include_chains (cpp_reader *, cpp_dir *, cpp_dir *, int);
5793b276 815
c6e83800
ZW
816/* Call these to get pointers to the options, callback, and deps
817 structures for a given reader. These pointers are good until you
818 call cpp_finish on that reader. You can either edit the callbacks
7e96d768
NB
819 through the pointer returned from cpp_get_callbacks, or set them
820 with cpp_set_callbacks. */
6cf87ca4 821extern cpp_options *cpp_get_options (cpp_reader *);
6cf87ca4
ZW
822extern cpp_callbacks *cpp_get_callbacks (cpp_reader *);
823extern void cpp_set_callbacks (cpp_reader *, cpp_callbacks *);
c6e83800 824extern struct deps *cpp_get_deps (cpp_reader *);
7e96d768 825
8e9ea4d7
PB
826/* This function reads the file, but does not start preprocessing. It
827 returns the name of the original file; this is the same as the
828 input file, except for preprocessed input. This will generate at
829 least one file change callback, and possibly a line change callback
9ac97460 830 too. If there was an error opening the file, it returns NULL. */
8e9ea4d7 831extern const char *cpp_read_main_file (cpp_reader *, const char *);
f5e99456 832
ccfc4c91
OW
833/* Set up built-ins with special behavior. Use cpp_init_builtins()
834 instead unless your know what you are doing. */
835extern void cpp_init_special_builtins (cpp_reader *);
836
c1bad961 837/* Set up built-ins like __FILE__. */
6cf87ca4 838extern void cpp_init_builtins (cpp_reader *, int);
f5e99456 839
4169c321 840/* This is called after options have been parsed, and partially
59e4e217 841 processed. */
4169c321
PB
842extern void cpp_post_options (cpp_reader *);
843
e6cc3a24
ZW
844/* Set up translation to the target character set. */
845extern void cpp_init_iconv (cpp_reader *);
846
f4ff5a69
NB
847/* Call this to finish preprocessing. If you requested dependency
848 generation, pass an open stream to write the information to,
148e4216
JM
849 otherwise NULL. It is your responsibility to close the stream. */
850extern void cpp_finish (cpp_reader *, FILE *deps_stream);
f4ff5a69 851
f5e99456 852/* Call this to release the handle at the end of preprocessing. Any
148e4216 853 use of the handle after this function returns is invalid. */
6cf87ca4 854extern void cpp_destroy (cpp_reader *);
f5e99456 855
6cf87ca4
ZW
856extern unsigned int cpp_token_len (const cpp_token *);
857extern unsigned char *cpp_token_as_text (cpp_reader *, const cpp_token *);
858extern unsigned char *cpp_spell_token (cpp_reader *, const cpp_token *,
47e20491 859 unsigned char *, bool);
6cf87ca4 860extern void cpp_register_pragma (cpp_reader *, const char *, const char *,
b5b3e36a 861 void (*) (cpp_reader *), bool);
bc4071dd
RH
862extern void cpp_register_deferred_pragma (cpp_reader *, const char *,
863 const char *, unsigned, bool, bool);
6cf87ca4
ZW
864extern int cpp_avoid_paste (cpp_reader *, const cpp_token *,
865 const cpp_token *);
866extern const cpp_token *cpp_get_token (cpp_reader *);
5ffeb913
TT
867extern const cpp_token *cpp_get_token_with_location (cpp_reader *,
868 source_location *);
6b366948 869extern bool cpp_fun_like_macro_p (cpp_hashnode *);
6cf87ca4 870extern const unsigned char *cpp_macro_definition (cpp_reader *,
8e680db5 871 cpp_hashnode *);
6cf87ca4 872extern void _cpp_backup_tokens (cpp_reader *, unsigned int);
5950c3c9 873extern const cpp_token *cpp_peek_token (cpp_reader *, int);
041c3194 874
2c6e3f55 875/* Evaluate a CPP_*CHAR* token. */
6cf87ca4
ZW
876extern cppchar_t cpp_interpret_charconst (cpp_reader *, const cpp_token *,
877 unsigned int *, int *);
2c6e3f55 878/* Evaluate a vector of CPP_*STRING* tokens. */
e6cc3a24
ZW
879extern bool cpp_interpret_string (cpp_reader *,
880 const cpp_string *, size_t,
b6baa67d 881 cpp_string *, enum cpp_ttype);
88fa5555
DM
882extern const char *cpp_interpret_string_ranges (cpp_reader *pfile,
883 const cpp_string *from,
884 cpp_string_location_reader *,
885 size_t count,
886 cpp_substring_ranges *out,
887 enum cpp_ttype type);
423e95e2
EC
888extern bool cpp_interpret_string_notranslate (cpp_reader *,
889 const cpp_string *, size_t,
b6baa67d 890 cpp_string *, enum cpp_ttype);
c8a96070 891
c5ff069d
ZW
892/* Convert a host character constant to the execution character set. */
893extern cppchar_t cpp_host_to_exec_charset (cpp_reader *, cppchar_t);
894
c1bad961 895/* Used to register macros and assertions, perhaps from the command line.
3d90d290 896 The text is the same as the command line argument. */
6cf87ca4 897extern void cpp_define (cpp_reader *, const char *);
28f68625
DF
898extern void cpp_define_formatted (cpp_reader *pfile,
899 const char *fmt, ...) ATTRIBUTE_PRINTF_2;
6cf87ca4
ZW
900extern void cpp_assert (cpp_reader *, const char *);
901extern void cpp_undef (cpp_reader *, const char *);
902extern void cpp_unassert (cpp_reader *, const char *);
7f2935c7 903
d1bd0ded
GK
904/* Undefine all macros and assertions. */
905extern void cpp_undef_all (cpp_reader *);
906
6cf87ca4 907extern cpp_buffer *cpp_push_buffer (cpp_reader *, const unsigned char *,
4dc299fb 908 size_t, int);
6cf87ca4 909extern int cpp_defined (cpp_reader *, const unsigned char *, int);
c5a04734 910
cd7ab83f
NB
911/* A preprocessing number. Code assumes that any unused high bits of
912 the double integer are set to zero. */
54da09ee 913
edf6ddf6 914/* This type has to be equal to unsigned HOST_WIDE_INT, see
54da09ee 915 gcc/c-family/c-lex.c. */
edf6ddf6 916typedef uint64_t cpp_num_part;
cd7ab83f
NB
917typedef struct cpp_num cpp_num;
918struct cpp_num
919{
920 cpp_num_part high;
921 cpp_num_part low;
922 bool unsignedp; /* True if value should be treated as unsigned. */
923 bool overflow; /* True if the most recent calculation overflowed. */
924};
925
926/* cpplib provides two interfaces for interpretation of preprocessing
927 numbers.
928
929 cpp_classify_number categorizes numeric constants according to
930 their field (integer, floating point, or invalid), radix (decimal,
931 octal, hexadecimal), and type suffixes. */
932
933#define CPP_N_CATEGORY 0x000F
934#define CPP_N_INVALID 0x0000
935#define CPP_N_INTEGER 0x0001
936#define CPP_N_FLOATING 0x0002
937
938#define CPP_N_WIDTH 0x00F0
8204be6c 939#define CPP_N_SMALL 0x0010 /* int, float, short _Fract/Accum */
ac6b1c67
CF
940#define CPP_N_MEDIUM 0x0020 /* long, double, long _Fract/_Accum. */
941#define CPP_N_LARGE 0x0040 /* long long, long double,
942 long long _Fract/Accum. */
cd7ab83f 943
c77cd3d1
UB
944#define CPP_N_WIDTH_MD 0xF0000 /* machine defined. */
945#define CPP_N_MD_W 0x10000
946#define CPP_N_MD_Q 0x20000
947
cd7ab83f
NB
948#define CPP_N_RADIX 0x0F00
949#define CPP_N_DECIMAL 0x0100
950#define CPP_N_HEX 0x0200
951#define CPP_N_OCTAL 0x0400
f7fd775f 952#define CPP_N_BINARY 0x0800
cd7ab83f
NB
953
954#define CPP_N_UNSIGNED 0x1000 /* Properties. */
955#define CPP_N_IMAGINARY 0x2000
ad6ed77e 956#define CPP_N_DFLOAT 0x4000
839a3b8a 957#define CPP_N_DEFAULT 0x8000
cd7ab83f 958
ac6b1c67
CF
959#define CPP_N_FRACT 0x100000 /* Fract types. */
960#define CPP_N_ACCUM 0x200000 /* Accum types. */
c65699ef
JM
961#define CPP_N_FLOATN 0x400000 /* _FloatN types. */
962#define CPP_N_FLOATNX 0x800000 /* _FloatNx types. */
ac6b1c67 963
3ce4f9e4
ESR
964#define CPP_N_USERDEF 0x1000000 /* C++0x user-defined literal. */
965
c65699ef
JM
966#define CPP_N_WIDTH_FLOATN_NX 0xF0000000 /* _FloatN / _FloatNx value
967 of N, divided by 16. */
968#define CPP_FLOATN_SHIFT 24
969#define CPP_FLOATN_MAX 0xF0
970
cd7ab83f
NB
971/* Classify a CPP_NUMBER token. The return value is a combination of
972 the flags from the above sets. */
3ce4f9e4 973extern unsigned cpp_classify_number (cpp_reader *, const cpp_token *,
0b2c4be5 974 const char **, source_location);
3ce4f9e4
ESR
975
976/* Return the classification flags for a float suffix. */
a4a0016d
ESR
977extern unsigned int cpp_interpret_float_suffix (cpp_reader *, const char *,
978 size_t);
3ce4f9e4
ESR
979
980/* Return the classification flags for an int suffix. */
a4a0016d
ESR
981extern unsigned int cpp_interpret_int_suffix (cpp_reader *, const char *,
982 size_t);
cd7ab83f
NB
983
984/* Evaluate a token classified as category CPP_N_INTEGER. */
6cf87ca4 985extern cpp_num cpp_interpret_integer (cpp_reader *, const cpp_token *,
3ce4f9e4 986 unsigned int);
cd7ab83f 987
ceeedfc1
NB
988/* Sign extend a number, with PRECISION significant bits and all
989 others assumed clear, to fill out a cpp_num structure. */
6cf87ca4 990cpp_num cpp_num_sign_extend (cpp_num, size_t);
ceeedfc1 991
95bd1dd7 992/* Diagnostic levels. To get a diagnostic without associating a
ebef4e8c
NB
993 position in the translation unit with it, use cpp_error_with_line
994 with a line number of zero. */
995
87cf0651
SB
996enum {
997 /* Warning, an error with -Werror. */
998 CPP_DL_WARNING = 0,
999 /* Same as CPP_DL_WARNING, except it is not suppressed in system headers. */
1000 CPP_DL_WARNING_SYSHDR,
1001 /* Warning, an error with -pedantic-errors or -Werror. */
1002 CPP_DL_PEDWARN,
1003 /* An error. */
1004 CPP_DL_ERROR,
1005 /* An internal consistency check failed. Prints "internal error: ",
1006 otherwise the same as CPP_DL_ERROR. */
1007 CPP_DL_ICE,
1008 /* An informative note following a warning. */
1009 CPP_DL_NOTE,
1010 /* A fatal error. */
1011 CPP_DL_FATAL
1012};
1013
1014/* Warning reason codes. Use a reason code of zero for unclassified warnings
1015 and errors that are not warnings. */
1016enum {
1017 CPP_W_NONE = 0,
1018 CPP_W_DEPRECATED,
1019 CPP_W_COMMENTS,
1020 CPP_W_MISSING_INCLUDE_DIRS,
1021 CPP_W_TRIGRAPHS,
1022 CPP_W_MULTICHAR,
1023 CPP_W_TRADITIONAL,
1024 CPP_W_LONG_LONG,
1025 CPP_W_ENDIF_LABELS,
1026 CPP_W_NUM_SIGN_CHANGE,
1027 CPP_W_VARIADIC_MACROS,
1028 CPP_W_BUILTIN_MACRO_REDEFINED,
1029 CPP_W_DOLLARS,
1030 CPP_W_UNDEF,
1031 CPP_W_UNUSED_MACROS,
1032 CPP_W_CXX_OPERATOR_NAMES,
1033 CPP_W_NORMALIZE,
1034 CPP_W_INVALID_PCH,
7f5f5f98 1035 CPP_W_WARNING_DIRECTIVE,
e8ff5196 1036 CPP_W_LITERAL_SUFFIX,
2b71f4a4
MLI
1037 CPP_W_DATE_TIME,
1038 CPP_W_PEDANTIC,
fe191308
JM
1039 CPP_W_C90_C99_COMPAT,
1040 CPP_W_CXX11_COMPAT
87cf0651 1041};
ebef4e8c 1042
ebef4e8c 1043/* Output a diagnostic of some kind. */
148e4216 1044extern bool cpp_error (cpp_reader *, int, const char *msgid, ...)
ebef4e8c 1045 ATTRIBUTE_PRINTF_3;
87cf0651
SB
1046extern bool cpp_warning (cpp_reader *, int, const char *msgid, ...)
1047 ATTRIBUTE_PRINTF_3;
1048extern bool cpp_pedwarning (cpp_reader *, int, const char *msgid, ...)
1049 ATTRIBUTE_PRINTF_3;
1050extern bool cpp_warning_syshdr (cpp_reader *, int, const char *msgid, ...)
1051 ATTRIBUTE_PRINTF_3;
ebef4e8c 1052
6cf87ca4 1053/* Output a diagnostic with "MSGID: " preceding the
ebef4e8c 1054 error string of errno. No location is printed. */
148e4216 1055extern bool cpp_errno (cpp_reader *, int, const char *msgid);
46ce03de
JJ
1056/* Similarly, but with "FILENAME: " instead of "MSGID: ", where
1057 the filename is not localized. */
ac81cf0b
DM
1058extern bool cpp_errno_filename (cpp_reader *, int, const char *filename,
1059 source_location loc);
ebef4e8c
NB
1060
1061/* Same as cpp_error, except additionally specifies a position as a
1062 (translation unit) physical line and physical column. If the line is
1063 zero, then no location is printed. */
87cf0651
SB
1064extern bool cpp_error_with_line (cpp_reader *, int, source_location,
1065 unsigned, const char *msgid, ...)
1066 ATTRIBUTE_PRINTF_5;
1067extern bool cpp_warning_with_line (cpp_reader *, int, source_location,
1068 unsigned, const char *msgid, ...)
1069 ATTRIBUTE_PRINTF_5;
1070extern bool cpp_pedwarning_with_line (cpp_reader *, int, source_location,
1071 unsigned, const char *msgid, ...)
1072 ATTRIBUTE_PRINTF_5;
1073extern bool cpp_warning_with_line_syshdr (cpp_reader *, int, source_location,
1074 unsigned, const char *msgid, ...)
1075 ATTRIBUTE_PRINTF_5;
f2d5f0cc 1076
ac81cf0b
DM
1077extern bool cpp_error_at (cpp_reader * pfile, int level,
1078 source_location src_loc, const char *msgid, ...)
1079 ATTRIBUTE_PRINTF_4;
1080
cb18fd07
DM
1081extern bool cpp_error_at_richloc (cpp_reader * pfile, int level,
1082 rich_location *richloc, const char *msgid,
1083 ...)
1084 ATTRIBUTE_PRINTF_4;
1085
28f68625 1086/* In lex.c */
6cf87ca4
ZW
1087extern int cpp_ideq (const cpp_token *, const char *);
1088extern void cpp_output_line (cpp_reader *, FILE *);
5d6342eb
TT
1089extern unsigned char *cpp_output_line_to_string (cpp_reader *,
1090 const unsigned char *);
6cf87ca4 1091extern void cpp_output_token (const cpp_token *, FILE *);
cfc93532 1092extern const char *cpp_type2name (enum cpp_ttype, unsigned char flags);
4268e8bb
NB
1093/* Returns the value of an escape sequence, truncated to the correct
1094 target precision. PSTR points to the input pointer, which is just
1095 after the backslash. LIMIT is how much text we have. WIDE is true
1096 if the escape sequence is part of a wide character constant or
1097 string literal. Handles all relevant diagnostics. */
6cf87ca4
ZW
1098extern cppchar_t cpp_parse_escape (cpp_reader *, const unsigned char ** pstr,
1099 const unsigned char *limit, int wide);
1368ee70 1100
631d0d36
MG
1101/* Structure used to hold a comment block at a given location in the
1102 source code. */
1103
1104typedef struct
1105{
1106 /* Text of the comment including the terminators. */
1107 char *comment;
1108
1109 /* source location for the given comment. */
1110 source_location sloc;
1111} cpp_comment;
1112
1113/* Structure holding all comments for a given cpp_reader. */
1114
1115typedef struct
1116{
1117 /* table of comment entries. */
1118 cpp_comment *entries;
1119
1120 /* number of actual entries entered in the table. */
1121 int count;
1122
1123 /* number of entries allocated currently. */
1124 int allocated;
1125} cpp_comment_table;
1126
1127/* Returns the table of comments encountered by the preprocessor. This
1128 table is only populated when pfile->state.save_comments is true. */
1129extern cpp_comment_table *cpp_get_comments (cpp_reader *);
1130
28f68625 1131/* In hash.c */
2a967f3d
NB
1132
1133/* Lookup an identifier in the hashtable. Puts the identifier in the
1134 table if it is not already there. */
6cf87ca4
ZW
1135extern cpp_hashnode *cpp_lookup (cpp_reader *, const unsigned char *,
1136 unsigned int);
2a967f3d 1137
6cf87ca4
ZW
1138typedef int (*cpp_cb) (cpp_reader *, cpp_hashnode *, void *);
1139extern void cpp_forall_identifiers (cpp_reader *, cpp_cb, void *);
926c5678 1140
28f68625 1141/* In macro.c */
6cf87ca4
ZW
1142extern void cpp_scan_nooutput (cpp_reader *);
1143extern int cpp_sys_macro_p (cpp_reader *);
1144extern unsigned char *cpp_quote_string (unsigned char *, const unsigned char *,
1145 unsigned int);
6de1e2a9 1146
28f68625 1147/* In files.c */
8f9b4009 1148extern bool cpp_included (cpp_reader *, const char *);
f1e20710 1149extern bool cpp_included_before (cpp_reader *, const char *, source_location);
6cf87ca4 1150extern void cpp_make_system_header (cpp_reader *, int, int);
6cf87ca4 1151extern bool cpp_push_include (cpp_reader *, const char *);
1efcb8c6 1152extern bool cpp_push_default_include (cpp_reader *, const char *);
6cf87ca4 1153extern void cpp_change_file (cpp_reader *, enum lc_reason, const char *);
94d1613b 1154extern const char *cpp_get_path (struct _cpp_file *);
e3c287c9 1155extern cpp_dir *cpp_get_dir (struct _cpp_file *);
94d1613b
MS
1156extern cpp_buffer *cpp_get_buffer (cpp_reader *);
1157extern struct _cpp_file *cpp_get_file (cpp_buffer *);
1158extern cpp_buffer *cpp_get_prev (cpp_buffer *);
97f6bd40 1159extern void cpp_clear_file_cache (cpp_reader *);
b0699dad 1160
28f68625 1161/* In pch.c */
17211ab5 1162struct save_macro_data;
6cf87ca4
ZW
1163extern int cpp_save_state (cpp_reader *, FILE *);
1164extern int cpp_write_pch_deps (cpp_reader *, FILE *);
1165extern int cpp_write_pch_state (cpp_reader *, FILE *);
1166extern int cpp_valid_state (cpp_reader *, const char *, int);
1167extern void cpp_prepare_state (cpp_reader *, struct save_macro_data **);
1168extern int cpp_read_state (cpp_reader *, const char *, FILE *,
1169 struct save_macro_data *);
17211ab5 1170
e3dfef44
GC
1171/* In lex.c */
1172extern void cpp_force_token_locations (cpp_reader *, source_location *);
1173extern void cpp_stop_forcing_token_locations (cpp_reader *);
1174
3ce4f9e4
ESR
1175/* In expr.c */
1176extern enum cpp_ttype cpp_userdef_string_remove_type
1177 (enum cpp_ttype type);
1178extern enum cpp_ttype cpp_userdef_string_add_type
1179 (enum cpp_ttype type);
1180extern enum cpp_ttype cpp_userdef_char_remove_type
1181 (enum cpp_ttype type);
1182extern enum cpp_ttype cpp_userdef_char_add_type
1183 (enum cpp_ttype type);
1184extern bool cpp_userdef_string_p
1185 (enum cpp_ttype type);
1186extern bool cpp_userdef_char_p
1187 (enum cpp_ttype type);
1188extern const char * cpp_get_userdef_suffix
1189 (const cpp_token *);
1190
4f4e53dd 1191#endif /* ! LIBCPP_CPPLIB_H */