Mercurial > hg > CbC > CbC_gcc
comparison libcpp/include/cpplib.h @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* Definitions for CPP library. | 1 /* Definitions for CPP library. |
2 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, | 2 Copyright (C) 1995-2017 Free Software Foundation, Inc. |
3 2004, 2005, 2007, 2008, 2009, 2010 | |
4 Free Software Foundation, Inc. | |
5 Written by Per Bothner, 1994-95. | 3 Written by Per Bothner, 1994-95. |
6 | 4 |
7 This program is free software; you can redistribute it and/or modify it | 5 This program is free software; you can redistribute it and/or modify it |
8 under the terms of the GNU General Public License as published by the | 6 under the terms of the GNU General Public License as published by the |
9 Free Software Foundation; either version 3, or (at your option) any | 7 Free Software Foundation; either version 3, or (at your option) any |
119 \ | 117 \ |
120 TK(CHAR, LITERAL) /* 'char' */ \ | 118 TK(CHAR, LITERAL) /* 'char' */ \ |
121 TK(WCHAR, LITERAL) /* L'char' */ \ | 119 TK(WCHAR, LITERAL) /* L'char' */ \ |
122 TK(CHAR16, LITERAL) /* u'char' */ \ | 120 TK(CHAR16, LITERAL) /* u'char' */ \ |
123 TK(CHAR32, LITERAL) /* U'char' */ \ | 121 TK(CHAR32, LITERAL) /* U'char' */ \ |
122 TK(UTF8CHAR, LITERAL) /* u8'char' */ \ | |
124 TK(OTHER, LITERAL) /* stray punctuation */ \ | 123 TK(OTHER, LITERAL) /* stray punctuation */ \ |
125 \ | 124 \ |
126 TK(STRING, LITERAL) /* "string" */ \ | 125 TK(STRING, LITERAL) /* "string" */ \ |
127 TK(WSTRING, LITERAL) /* L"string" */ \ | 126 TK(WSTRING, LITERAL) /* L"string" */ \ |
128 TK(STRING16, LITERAL) /* u"string" */ \ | 127 TK(STRING16, LITERAL) /* u"string" */ \ |
129 TK(STRING32, LITERAL) /* U"string" */ \ | 128 TK(STRING32, LITERAL) /* U"string" */ \ |
130 TK(UTF8STRING, LITERAL) /* u8"string" */ \ | 129 TK(UTF8STRING, LITERAL) /* u8"string" */ \ |
131 TK(OBJC_STRING, LITERAL) /* @"string" - Objective-C */ \ | 130 TK(OBJC_STRING, LITERAL) /* @"string" - Objective-C */ \ |
132 TK(HEADER_NAME, LITERAL) /* <stdio.h> in #include */ \ | 131 TK(HEADER_NAME, LITERAL) /* <stdio.h> in #include */ \ |
133 \ | 132 \ |
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 */ \ | |
137 TK(UTF8CHAR_USERDEF, LITERAL) /* u8'char'_suffix - C++-0x */ \ | |
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 \ | |
134 TK(COMMENT, LITERAL) /* Only if output comments. */ \ | 144 TK(COMMENT, LITERAL) /* Only if output comments. */ \ |
135 /* SPELL_LITERAL happens to DTRT. */ \ | 145 /* SPELL_LITERAL happens to DTRT. */ \ |
136 TK(MACRO_ARG, NONE) /* Macro argument. */ \ | 146 TK(MACRO_ARG, NONE) /* Macro argument. */ \ |
137 TK(PRAGMA, NONE) /* Only for deferred pragmas. */ \ | 147 TK(PRAGMA, NONE) /* Only for deferred pragmas. */ \ |
138 TK(PRAGMA_EOL, NONE) /* End-of-line for deferred pragmas. */ \ | 148 TK(PRAGMA_EOL, NONE) /* End-of-line for deferred pragmas. */ \ |
143 enum cpp_ttype | 153 enum cpp_ttype |
144 { | 154 { |
145 TTYPE_TABLE | 155 TTYPE_TABLE |
146 N_TTYPES, | 156 N_TTYPES, |
147 | 157 |
158 /* A token type for keywords, as opposed to ordinary identifiers. */ | |
159 CPP_KEYWORD, | |
160 | |
148 /* Positions in the table. */ | 161 /* Positions in the table. */ |
149 CPP_LAST_EQ = CPP_LSHIFT, | 162 CPP_LAST_EQ = CPP_LSHIFT, |
150 CPP_FIRST_DIGRAPH = CPP_HASH, | 163 CPP_FIRST_DIGRAPH = CPP_HASH, |
151 CPP_LAST_PUNCTUATOR= CPP_ATSIGN, | 164 CPP_LAST_PUNCTUATOR= CPP_ATSIGN, |
152 CPP_LAST_CPP_OP = CPP_LESS_EQ | 165 CPP_LAST_CPP_OP = CPP_LESS_EQ |
153 }; | 166 }; |
154 #undef OP | 167 #undef OP |
155 #undef TK | 168 #undef TK |
156 | 169 |
157 /* C language kind, used when calling cpp_create_reader. */ | 170 /* C language kind, used when calling cpp_create_reader. */ |
158 enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC1X, | 171 enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11, |
159 CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_STDC1X, | 172 CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_STDC11, |
160 CLK_GNUCXX, CLK_CXX98, CLK_GNUCXX0X, CLK_CXX0X, CLK_ASM}; | 173 CLK_GNUCXX, CLK_CXX98, CLK_GNUCXX11, CLK_CXX11, |
174 CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX17, CLK_CXX17, | |
175 CLK_GNUCXX2A, CLK_CXX2A, CLK_ASM}; | |
161 | 176 |
162 /* Payload of a NUMBER, STRING, CHAR or COMMENT token. */ | 177 /* Payload of a NUMBER, STRING, CHAR or COMMENT token. */ |
163 struct GTY(()) cpp_string { | 178 struct GTY(()) cpp_string { |
164 unsigned int len; | 179 unsigned int len; |
165 const unsigned char *text; | 180 const unsigned char *text; |
169 #define PREV_WHITE (1 << 0) /* If whitespace before this token. */ | 184 #define PREV_WHITE (1 << 0) /* If whitespace before this token. */ |
170 #define DIGRAPH (1 << 1) /* If it was a digraph. */ | 185 #define DIGRAPH (1 << 1) /* If it was a digraph. */ |
171 #define STRINGIFY_ARG (1 << 2) /* If macro argument to be stringified. */ | 186 #define STRINGIFY_ARG (1 << 2) /* If macro argument to be stringified. */ |
172 #define PASTE_LEFT (1 << 3) /* If on LHS of a ## operator. */ | 187 #define PASTE_LEFT (1 << 3) /* If on LHS of a ## operator. */ |
173 #define NAMED_OP (1 << 4) /* C++ named operators. */ | 188 #define NAMED_OP (1 << 4) /* C++ named operators. */ |
174 #define NO_EXPAND (1 << 5) /* Do not macro-expand this token. */ | 189 #define PREV_FALLTHROUGH (1 << 5) /* On a token preceeded by FALLTHROUGH |
190 comment. */ | |
175 #define BOL (1 << 6) /* Token at beginning of line. */ | 191 #define BOL (1 << 6) /* Token at beginning of line. */ |
176 #define PURE_ZERO (1 << 7) /* Single 0 digit, used by the C++ frontend, | 192 #define PURE_ZERO (1 << 7) /* Single 0 digit, used by the C++ frontend, |
177 set in c-lex.c. */ | 193 set in c-lex.c. */ |
178 #define SP_DIGRAPH (1 << 8) /* # or ## token was a digraph. */ | 194 #define SP_DIGRAPH (1 << 8) /* # or ## token was a digraph. */ |
179 #define SP_PREV_WHITE (1 << 9) /* If whitespace before a ## | 195 #define SP_PREV_WHITE (1 << 9) /* If whitespace before a ## |
180 operator, or before this token | 196 operator, or before this token |
181 after a # operator. */ | 197 after a # operator. */ |
198 #define NO_EXPAND (1 << 10) /* Do not macro-expand this token. */ | |
182 | 199 |
183 /* Specify which field, if any, of the cpp_token union is used. */ | 200 /* Specify which field, if any, of the cpp_token union is used. */ |
184 | 201 |
185 enum cpp_token_fld_kind { | 202 enum cpp_token_fld_kind { |
186 CPP_TOKEN_FLD_NODE, | 203 CPP_TOKEN_FLD_NODE, |
194 | 211 |
195 /* A macro argument in the cpp_token union. */ | 212 /* A macro argument in the cpp_token union. */ |
196 struct GTY(()) cpp_macro_arg { | 213 struct GTY(()) cpp_macro_arg { |
197 /* Argument number. */ | 214 /* Argument number. */ |
198 unsigned int arg_no; | 215 unsigned int arg_no; |
216 /* The original spelling of the macro argument token. */ | |
217 cpp_hashnode * | |
218 GTY ((nested_ptr (union tree_node, | |
219 "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL", | |
220 "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL"))) | |
221 spelling; | |
199 }; | 222 }; |
200 | 223 |
201 /* An identifier in the cpp_token union. */ | 224 /* An identifier in the cpp_token union. */ |
202 struct GTY(()) cpp_identifier { | 225 struct GTY(()) cpp_identifier { |
203 /* The canonical (UTF-8) spelling of the identifier. */ | 226 /* The canonical (UTF-8) spelling of the identifier. */ |
204 cpp_hashnode * | 227 cpp_hashnode * |
205 GTY ((nested_ptr (union tree_node, | 228 GTY ((nested_ptr (union tree_node, |
206 "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL", | 229 "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL", |
207 "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL"))) | 230 "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL"))) |
208 node; | 231 node; |
232 /* The original spelling of the identifier. */ | |
233 cpp_hashnode * | |
234 GTY ((nested_ptr (union tree_node, | |
235 "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL", | |
236 "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL"))) | |
237 spelling; | |
209 }; | 238 }; |
210 | 239 |
211 /* A preprocessing token. This has been carefully packed and should | 240 /* A preprocessing token. This has been carefully packed and should |
212 occupy 16 bytes on 32-bit hosts and 24 bytes on 64-bit hosts. */ | 241 occupy 16 bytes on 32-bit hosts and 24 bytes on 64-bit hosts. */ |
213 struct GTY(()) cpp_token { | 242 struct GTY(()) cpp_token { |
214 source_location src_loc; /* Location of first char of token. */ | 243 source_location src_loc; /* Location of first char of token, |
244 together with range of full token. */ | |
215 ENUM_BITFIELD(cpp_ttype) type : CHAR_BIT; /* token type */ | 245 ENUM_BITFIELD(cpp_ttype) type : CHAR_BIT; /* token type */ |
216 unsigned short flags; /* flags - see above */ | 246 unsigned short flags; /* flags - see above */ |
217 | 247 |
218 union cpp_token_u | 248 union cpp_token_u |
219 { | 249 { |
224 cpp_token * GTY ((tag ("CPP_TOKEN_FLD_SOURCE"))) source; | 254 cpp_token * GTY ((tag ("CPP_TOKEN_FLD_SOURCE"))) source; |
225 | 255 |
226 /* A string, or number. */ | 256 /* A string, or number. */ |
227 struct cpp_string GTY ((tag ("CPP_TOKEN_FLD_STR"))) str; | 257 struct cpp_string GTY ((tag ("CPP_TOKEN_FLD_STR"))) str; |
228 | 258 |
229 /* Argument no. for a CPP_MACRO_ARG. */ | 259 /* Argument no. (and original spelling) for a CPP_MACRO_ARG. */ |
230 struct cpp_macro_arg GTY ((tag ("CPP_TOKEN_FLD_ARG_NO"))) macro_arg; | 260 struct cpp_macro_arg GTY ((tag ("CPP_TOKEN_FLD_ARG_NO"))) macro_arg; |
231 | 261 |
232 /* Original token no. for a CPP_PASTE (from a sequence of | 262 /* Original token no. for a CPP_PASTE (from a sequence of |
233 consecutive paste tokens in a macro expansion). */ | 263 consecutive paste tokens in a macro expansion). */ |
234 unsigned int GTY ((tag ("CPP_TOKEN_FLD_TOKEN_NO"))) token_no; | 264 unsigned int GTY ((tag ("CPP_TOKEN_FLD_TOKEN_NO"))) token_no; |
237 unsigned int GTY ((tag ("CPP_TOKEN_FLD_PRAGMA"))) pragma; | 267 unsigned int GTY ((tag ("CPP_TOKEN_FLD_PRAGMA"))) pragma; |
238 } GTY ((desc ("cpp_token_val_index (&%1)"))) val; | 268 } GTY ((desc ("cpp_token_val_index (&%1)"))) val; |
239 }; | 269 }; |
240 | 270 |
241 /* Say which field is in use. */ | 271 /* Say which field is in use. */ |
242 extern enum cpp_token_fld_kind cpp_token_val_index (cpp_token *tok); | 272 extern enum cpp_token_fld_kind cpp_token_val_index (const cpp_token *tok); |
243 | 273 |
244 /* A type wide enough to hold any multibyte source character. | 274 /* A type wide enough to hold any multibyte source character. |
245 cpplib's character constant interpreter requires an unsigned type. | 275 cpplib's character constant interpreter requires an unsigned type. |
246 Also, a typedef for the signed equivalent. | 276 Also, a typedef for the signed equivalent. |
247 The width of this type is capped at 32 bits; there do exist targets | 277 The width of this type is capped at 32 bits; there do exist targets |
313 unsigned char extended_numbers; | 343 unsigned char extended_numbers; |
314 | 344 |
315 /* Nonzero means process u/U prefix literals (UTF-16/32). */ | 345 /* Nonzero means process u/U prefix literals (UTF-16/32). */ |
316 unsigned char uliterals; | 346 unsigned char uliterals; |
317 | 347 |
348 /* Nonzero means process u8 prefixed character literals (UTF-8). */ | |
349 unsigned char utf8_char_literals; | |
350 | |
351 /* Nonzero means process r/R raw strings. If this is set, uliterals | |
352 must be set as well. */ | |
353 unsigned char rliterals; | |
354 | |
318 /* Nonzero means print names of header files (-H). */ | 355 /* Nonzero means print names of header files (-H). */ |
319 unsigned char print_include_names; | 356 unsigned char print_include_names; |
320 | 357 |
321 /* Nonzero means complain about deprecated features. */ | 358 /* Nonzero means complain about deprecated features. */ |
322 unsigned char cpp_warn_deprecated; | 359 unsigned char cpp_warn_deprecated; |
323 | 360 |
324 /* Nonzero means warn if slash-star appears in a comment. */ | 361 /* Nonzero means warn if slash-star appears in a comment. */ |
325 unsigned char warn_comments; | 362 unsigned char warn_comments; |
363 | |
364 /* Nonzero means to warn about __DATA__, __TIME__ and __TIMESTAMP__ usage. */ | |
365 unsigned char warn_date_time; | |
326 | 366 |
327 /* Nonzero means warn if a user-supplied include directory does not | 367 /* Nonzero means warn if a user-supplied include directory does not |
328 exist. */ | 368 exist. */ |
329 unsigned char warn_missing_include_dirs; | 369 unsigned char warn_missing_include_dirs; |
330 | 370 |
354 | 394 |
355 /* Nonzero means warn about builtin macros that are redefined or | 395 /* Nonzero means warn about builtin macros that are redefined or |
356 explicitly undefined. */ | 396 explicitly undefined. */ |
357 unsigned char warn_builtin_macro_redefined; | 397 unsigned char warn_builtin_macro_redefined; |
358 | 398 |
399 /* Different -Wimplicit-fallthrough= levels. */ | |
400 unsigned char cpp_warn_implicit_fallthrough; | |
401 | |
359 /* Nonzero means we should look for header.gcc files that remap file | 402 /* Nonzero means we should look for header.gcc files that remap file |
360 names. */ | 403 names. */ |
361 unsigned char remap; | 404 unsigned char remap; |
362 | 405 |
363 /* Zero means dollar signs are punctuation. */ | 406 /* Zero means dollar signs are punctuation. */ |
371 unsigned char warn_dollars; | 414 unsigned char warn_dollars; |
372 | 415 |
373 /* Nonzero means warn if undefined identifiers are evaluated in an #if. */ | 416 /* Nonzero means warn if undefined identifiers are evaluated in an #if. */ |
374 unsigned char warn_undef; | 417 unsigned char warn_undef; |
375 | 418 |
419 /* Nonzero means warn if "defined" is encountered in a place other than | |
420 an #if. */ | |
421 unsigned char warn_expansion_to_defined; | |
422 | |
376 /* Nonzero means warn of unused macros from the main file. */ | 423 /* Nonzero means warn of unused macros from the main file. */ |
377 unsigned char warn_unused_macros; | 424 unsigned char warn_unused_macros; |
378 | 425 |
379 /* Nonzero for the 1999 C Standard, including corrigenda and amendments. */ | 426 /* Nonzero for the 1999 C Standard, including corrigenda and amendments. */ |
380 unsigned char c99; | 427 unsigned char c99; |
386 unsigned char cpp_pedantic; | 433 unsigned char cpp_pedantic; |
387 | 434 |
388 /* Nonzero means we're looking at already preprocessed code, so don't | 435 /* Nonzero means we're looking at already preprocessed code, so don't |
389 bother trying to do macro expansion and whatnot. */ | 436 bother trying to do macro expansion and whatnot. */ |
390 unsigned char preprocessed; | 437 unsigned char preprocessed; |
438 | |
439 /* Nonzero means we are going to emit debugging logs during | |
440 preprocessing. */ | |
441 unsigned char debug; | |
442 | |
443 /* Nonzero means we are tracking locations of tokens involved in | |
444 macro expansion. 1 Means we track the location in degraded mode | |
445 where we do not track locations of tokens resulting from the | |
446 expansion of arguments of function-like macro. 2 Means we do | |
447 track all macro expansions. This last option is the one that | |
448 consumes the highest amount of memory. */ | |
449 unsigned char track_macro_expansion; | |
391 | 450 |
392 /* Nonzero means handle C++ alternate operator names. */ | 451 /* Nonzero means handle C++ alternate operator names. */ |
393 unsigned char operator_names; | 452 unsigned char operator_names; |
394 | 453 |
395 /* Nonzero means warn about use of C++ alternate operator names. */ | 454 /* Nonzero means warn about use of C++ alternate operator names. */ |
396 unsigned char warn_cxx_operator_names; | 455 unsigned char warn_cxx_operator_names; |
397 | 456 |
398 /* True for traditional preprocessing. */ | 457 /* True for traditional preprocessing. */ |
399 unsigned char traditional; | 458 unsigned char traditional; |
400 | 459 |
460 /* Nonzero for C++ 2011 Standard user-defined literals. */ | |
461 unsigned char user_literals; | |
462 | |
463 /* Nonzero means warn when a string or character literal is followed by a | |
464 ud-suffix which does not beging with an underscore. */ | |
465 unsigned char warn_literal_suffix; | |
466 | |
467 /* Nonzero means interpret imaginary, fixed-point, or other gnu extension | |
468 literal number suffixes as user-defined literal number suffixes. */ | |
469 unsigned char ext_numeric_literals; | |
470 | |
471 /* Nonzero means extended identifiers allow the characters specified | |
472 in C11 and C++11. */ | |
473 unsigned char c11_identifiers; | |
474 | |
475 /* Nonzero for C++ 2014 Standard binary constants. */ | |
476 unsigned char binary_constants; | |
477 | |
478 /* Nonzero for C++ 2014 Standard digit separators. */ | |
479 unsigned char digit_separators; | |
480 | |
401 /* Holds the name of the target (execution) character set. */ | 481 /* Holds the name of the target (execution) character set. */ |
402 const char *narrow_charset; | 482 const char *narrow_charset; |
403 | 483 |
404 /* Holds the name of the target wide character set. */ | 484 /* Holds the name of the target wide character set. */ |
405 const char *wide_charset; | 485 const char *wide_charset; |
406 | 486 |
407 /* Holds the name of the input character set. */ | 487 /* Holds the name of the input character set. */ |
408 const char *input_charset; | 488 const char *input_charset; |
409 | 489 |
410 /* The minimum permitted level of normalization before a warning | 490 /* The minimum permitted level of normalization before a warning |
411 is generated. */ | 491 is generated. See enum cpp_normalize_level. */ |
412 enum cpp_normalize_level warn_normalize; | 492 int warn_normalize; |
413 | 493 |
414 /* True to warn about precompiled header files we couldn't use. */ | 494 /* True to warn about precompiled header files we couldn't use. */ |
415 bool warn_invalid_pch; | 495 bool warn_invalid_pch; |
416 | 496 |
417 /* True if dependencies should be restored from a precompiled header. */ | 497 /* True if dependencies should be restored from a precompiled header. */ |
418 bool restore_pch_deps; | 498 bool restore_pch_deps; |
499 | |
500 /* True if warn about differences between C90 and C99. */ | |
501 signed char cpp_warn_c90_c99_compat; | |
502 | |
503 /* True if warn about differences between C++98 and C++11. */ | |
504 bool cpp_warn_cxx11_compat; | |
419 | 505 |
420 /* Dependency generation. */ | 506 /* Dependency generation. */ |
421 struct | 507 struct |
422 { | 508 { |
423 /* Style of header dependencies to generate. */ | 509 /* Style of header dependencies to generate. */ |
454 /* Nonzero means __STDC__ should have the value 0 in system headers. */ | 540 /* Nonzero means __STDC__ should have the value 0 in system headers. */ |
455 unsigned char stdc_0_in_system_headers; | 541 unsigned char stdc_0_in_system_headers; |
456 | 542 |
457 /* True disables tokenization outside of preprocessing directives. */ | 543 /* True disables tokenization outside of preprocessing directives. */ |
458 bool directives_only; | 544 bool directives_only; |
545 | |
546 /* True enables canonicalization of system header file paths. */ | |
547 bool canonical_system_headers; | |
459 }; | 548 }; |
460 | 549 |
461 /* Callback for header lookup for HEADER, which is the name of a | 550 /* Callback for header lookup for HEADER, which is the name of a |
462 source file. It is used as a method of last resort to find headers | 551 source file. It is used as a method of last resort to find headers |
463 that are not otherwise found during the normal include processing. | 552 that are not otherwise found during the normal include processing. |
474 | 563 |
475 /* Called when switching to/from a new file. | 564 /* Called when switching to/from a new file. |
476 The line_map is for the new file. It is NULL if there is no new file. | 565 The line_map is for the new file. It is NULL if there is no new file. |
477 (In C this happens when done with <built-in>+<command line> and also | 566 (In C this happens when done with <built-in>+<command line> and also |
478 when done with a main file.) This can be used for resource cleanup. */ | 567 when done with a main file.) This can be used for resource cleanup. */ |
479 void (*file_change) (cpp_reader *, const struct line_map *); | 568 void (*file_change) (cpp_reader *, const line_map_ordinary *); |
480 | 569 |
481 void (*dir_change) (cpp_reader *, const char *); | 570 void (*dir_change) (cpp_reader *, const char *); |
482 void (*include) (cpp_reader *, unsigned int, const unsigned char *, | 571 void (*include) (cpp_reader *, source_location, const unsigned char *, |
483 const char *, int, const cpp_token **); | 572 const char *, int, const cpp_token **); |
484 void (*define) (cpp_reader *, unsigned int, cpp_hashnode *); | 573 void (*define) (cpp_reader *, source_location, cpp_hashnode *); |
485 void (*undef) (cpp_reader *, unsigned int, cpp_hashnode *); | 574 void (*undef) (cpp_reader *, source_location, cpp_hashnode *); |
486 void (*ident) (cpp_reader *, unsigned int, const cpp_string *); | 575 void (*ident) (cpp_reader *, source_location, const cpp_string *); |
487 void (*def_pragma) (cpp_reader *, unsigned int); | 576 void (*def_pragma) (cpp_reader *, source_location); |
488 int (*valid_pch) (cpp_reader *, const char *, int); | 577 int (*valid_pch) (cpp_reader *, const char *, int); |
489 void (*read_pch) (cpp_reader *, const char *, int, const char *); | 578 void (*read_pch) (cpp_reader *, const char *, int, const char *); |
490 missing_header_cb missing_header; | 579 missing_header_cb missing_header; |
491 | 580 |
492 /* Context-sensitive macro support. Returns macro (if any) that should | 581 /* Context-sensitive macro support. Returns macro (if any) that should |
493 be expanded. */ | 582 be expanded. */ |
494 cpp_hashnode * (*macro_to_expand) (cpp_reader *, const cpp_token *); | 583 cpp_hashnode * (*macro_to_expand) (cpp_reader *, const cpp_token *); |
495 | 584 |
496 /* Called to emit a diagnostic. This callback receives the | 585 /* Called to emit a diagnostic. This callback receives the |
497 translated message. */ | 586 translated message. */ |
498 bool (*error) (cpp_reader *, int, int, source_location, unsigned int, | 587 bool (*error) (cpp_reader *, int, int, rich_location *, |
499 const char *, va_list *) | 588 const char *, va_list *) |
500 ATTRIBUTE_FPTR_PRINTF(6,0); | 589 ATTRIBUTE_FPTR_PRINTF(5,0); |
501 | 590 |
502 /* Callbacks for when a macro is expanded, or tested (whether | 591 /* Callbacks for when a macro is expanded, or tested (whether |
503 defined or not at the time) in #ifdef, #ifndef or "defined". */ | 592 defined or not at the time) in #ifdef, #ifndef or "defined". */ |
504 void (*used_define) (cpp_reader *, unsigned int, cpp_hashnode *); | 593 void (*used_define) (cpp_reader *, source_location, cpp_hashnode *); |
505 void (*used_undef) (cpp_reader *, unsigned int, cpp_hashnode *); | 594 void (*used_undef) (cpp_reader *, source_location, cpp_hashnode *); |
506 /* Called before #define and #undef or other macro definition | 595 /* Called before #define and #undef or other macro definition |
507 changes are processed. */ | 596 changes are processed. */ |
508 void (*before_define) (cpp_reader *); | 597 void (*before_define) (cpp_reader *); |
509 /* Called whenever a macro is expanded or tested. | 598 /* Called whenever a macro is expanded or tested. |
510 Second argument is the location of the start of the current expansion. */ | 599 Second argument is the location of the start of the current expansion. */ |
511 void (*used) (cpp_reader *, source_location, cpp_hashnode *); | 600 void (*used) (cpp_reader *, source_location, cpp_hashnode *); |
512 | 601 |
602 /* Callback to identify whether an attribute exists. */ | |
603 int (*has_attribute) (cpp_reader *); | |
604 | |
513 /* Callback that can change a user builtin into normal macro. */ | 605 /* Callback that can change a user builtin into normal macro. */ |
514 bool (*user_builtin_macro) (cpp_reader *, cpp_hashnode *); | 606 bool (*user_builtin_macro) (cpp_reader *, cpp_hashnode *); |
607 | |
608 /* Callback to parse SOURCE_DATE_EPOCH from environment. */ | |
609 time_t (*get_source_date_epoch) (cpp_reader *); | |
610 | |
611 /* Callback for providing suggestions for misspelled directives. */ | |
612 const char *(*get_suggestion) (cpp_reader *, const char *, const char *const *); | |
613 | |
614 /* Callback for when a comment is encountered, giving the location | |
615 of the opening slash, a pointer to the content (which is not | |
616 necessarily 0-terminated), and the length of the content. | |
617 The content contains the opening slash-star (or slash-slash), | |
618 and for C-style comments contains the closing star-slash. For | |
619 C++-style comments it does not include the terminating newline. */ | |
620 void (*comment) (cpp_reader *, source_location, const unsigned char *, | |
621 size_t); | |
515 }; | 622 }; |
516 | 623 |
517 #ifdef VMS | 624 #ifdef VMS |
518 #define INO_T_CPP ino_t ino[3] | 625 #define INO_T_CPP ino_t ino[3] |
519 #else | 626 #else |
601 BT_TIME, /* `__TIME__' */ | 708 BT_TIME, /* `__TIME__' */ |
602 BT_STDC, /* `__STDC__' */ | 709 BT_STDC, /* `__STDC__' */ |
603 BT_PRAGMA, /* `_Pragma' operator */ | 710 BT_PRAGMA, /* `_Pragma' operator */ |
604 BT_TIMESTAMP, /* `__TIMESTAMP__' */ | 711 BT_TIMESTAMP, /* `__TIMESTAMP__' */ |
605 BT_COUNTER, /* `__COUNTER__' */ | 712 BT_COUNTER, /* `__COUNTER__' */ |
713 BT_HAS_ATTRIBUTE, /* `__has_attribute__(x)' */ | |
606 BT_FIRST_USER, /* User defined builtin macros. */ | 714 BT_FIRST_USER, /* User defined builtin macros. */ |
607 BT_LAST_USER = BT_FIRST_USER + 31 | 715 BT_LAST_USER = BT_FIRST_USER + 31 |
608 }; | 716 }; |
609 | 717 |
610 #define CPP_HASHNODE(HNODE) ((cpp_hashnode *) (HNODE)) | 718 #define CPP_HASHNODE(HNODE) ((cpp_hashnode *) (HNODE)) |
653 unsigned char rid_code; /* Rid code - for front ends. */ | 761 unsigned char rid_code; /* Rid code - for front ends. */ |
654 ENUM_BITFIELD(node_type) type : 6; /* CPP node type. */ | 762 ENUM_BITFIELD(node_type) type : 6; /* CPP node type. */ |
655 unsigned int flags : 10; /* CPP flags. */ | 763 unsigned int flags : 10; /* CPP flags. */ |
656 | 764 |
657 union _cpp_hashnode_value GTY ((desc ("CPP_HASHNODE_VALUE_IDX (%1)"))) value; | 765 union _cpp_hashnode_value GTY ((desc ("CPP_HASHNODE_VALUE_IDX (%1)"))) value; |
766 }; | |
767 | |
768 /* A class for iterating through the source locations within a | |
769 string token (before escapes are interpreted, and before | |
770 concatenation). */ | |
771 | |
772 class cpp_string_location_reader { | |
773 public: | |
774 cpp_string_location_reader (source_location src_loc, | |
775 line_maps *line_table); | |
776 | |
777 source_range get_next (); | |
778 | |
779 private: | |
780 source_location m_loc; | |
781 int m_offset_per_column; | |
782 line_maps *m_line_table; | |
783 }; | |
784 | |
785 /* A class for storing the source ranges of all of the characters within | |
786 a string literal, after escapes are interpreted, and after | |
787 concatenation. | |
788 | |
789 This is not GTY-marked, as instances are intended to be temporary. */ | |
790 | |
791 class cpp_substring_ranges | |
792 { | |
793 public: | |
794 cpp_substring_ranges (); | |
795 ~cpp_substring_ranges (); | |
796 | |
797 int get_num_ranges () const { return m_num_ranges; } | |
798 source_range get_range (int idx) const | |
799 { | |
800 linemap_assert (idx < m_num_ranges); | |
801 return m_ranges[idx]; | |
802 } | |
803 | |
804 void add_range (source_range range); | |
805 void add_n_ranges (int num, cpp_string_location_reader &loc_reader); | |
806 | |
807 private: | |
808 source_range *m_ranges; | |
809 int m_num_ranges; | |
810 int m_alloc_ranges; | |
658 }; | 811 }; |
659 | 812 |
660 /* Call this first to get a handle to pass to other functions. | 813 /* Call this first to get a handle to pass to other functions. |
661 | 814 |
662 If you want cpplib to manage its own hashtable, pass in a NULL | 815 If you want cpplib to manage its own hashtable, pass in a NULL |
728 extern int cpp_avoid_paste (cpp_reader *, const cpp_token *, | 881 extern int cpp_avoid_paste (cpp_reader *, const cpp_token *, |
729 const cpp_token *); | 882 const cpp_token *); |
730 extern const cpp_token *cpp_get_token (cpp_reader *); | 883 extern const cpp_token *cpp_get_token (cpp_reader *); |
731 extern const cpp_token *cpp_get_token_with_location (cpp_reader *, | 884 extern const cpp_token *cpp_get_token_with_location (cpp_reader *, |
732 source_location *); | 885 source_location *); |
886 extern bool cpp_fun_like_macro_p (cpp_hashnode *); | |
733 extern const unsigned char *cpp_macro_definition (cpp_reader *, | 887 extern const unsigned char *cpp_macro_definition (cpp_reader *, |
734 cpp_hashnode *); | 888 cpp_hashnode *); |
735 extern void _cpp_backup_tokens (cpp_reader *, unsigned int); | 889 extern void _cpp_backup_tokens (cpp_reader *, unsigned int); |
736 extern const cpp_token *cpp_peek_token (cpp_reader *, int); | 890 extern const cpp_token *cpp_peek_token (cpp_reader *, int); |
737 | 891 |
740 unsigned int *, int *); | 894 unsigned int *, int *); |
741 /* Evaluate a vector of CPP_*STRING* tokens. */ | 895 /* Evaluate a vector of CPP_*STRING* tokens. */ |
742 extern bool cpp_interpret_string (cpp_reader *, | 896 extern bool cpp_interpret_string (cpp_reader *, |
743 const cpp_string *, size_t, | 897 const cpp_string *, size_t, |
744 cpp_string *, enum cpp_ttype); | 898 cpp_string *, enum cpp_ttype); |
899 extern const char *cpp_interpret_string_ranges (cpp_reader *pfile, | |
900 const cpp_string *from, | |
901 cpp_string_location_reader *, | |
902 size_t count, | |
903 cpp_substring_ranges *out, | |
904 enum cpp_ttype type); | |
745 extern bool cpp_interpret_string_notranslate (cpp_reader *, | 905 extern bool cpp_interpret_string_notranslate (cpp_reader *, |
746 const cpp_string *, size_t, | 906 const cpp_string *, size_t, |
747 cpp_string *, enum cpp_ttype); | 907 cpp_string *, enum cpp_ttype); |
748 | 908 |
749 /* Convert a host character constant to the execution character set. */ | 909 /* Convert a host character constant to the execution character set. */ |
765 size_t, int); | 925 size_t, int); |
766 extern int cpp_defined (cpp_reader *, const unsigned char *, int); | 926 extern int cpp_defined (cpp_reader *, const unsigned char *, int); |
767 | 927 |
768 /* A preprocessing number. Code assumes that any unused high bits of | 928 /* A preprocessing number. Code assumes that any unused high bits of |
769 the double integer are set to zero. */ | 929 the double integer are set to zero. */ |
770 typedef unsigned HOST_WIDE_INT cpp_num_part; | 930 |
931 /* This type has to be equal to unsigned HOST_WIDE_INT, see | |
932 gcc/c-family/c-lex.c. */ | |
933 typedef uint64_t cpp_num_part; | |
771 typedef struct cpp_num cpp_num; | 934 typedef struct cpp_num cpp_num; |
772 struct cpp_num | 935 struct cpp_num |
773 { | 936 { |
774 cpp_num_part high; | 937 cpp_num_part high; |
775 cpp_num_part low; | 938 cpp_num_part low; |
788 #define CPP_N_INVALID 0x0000 | 951 #define CPP_N_INVALID 0x0000 |
789 #define CPP_N_INTEGER 0x0001 | 952 #define CPP_N_INTEGER 0x0001 |
790 #define CPP_N_FLOATING 0x0002 | 953 #define CPP_N_FLOATING 0x0002 |
791 | 954 |
792 #define CPP_N_WIDTH 0x00F0 | 955 #define CPP_N_WIDTH 0x00F0 |
793 #define CPP_N_SMALL 0x0010 /* int, float, shrot _Fract/Accum */ | 956 #define CPP_N_SMALL 0x0010 /* int, float, short _Fract/Accum */ |
794 #define CPP_N_MEDIUM 0x0020 /* long, double, long _Fract/_Accum. */ | 957 #define CPP_N_MEDIUM 0x0020 /* long, double, long _Fract/_Accum. */ |
795 #define CPP_N_LARGE 0x0040 /* long long, long double, | 958 #define CPP_N_LARGE 0x0040 /* long long, long double, |
796 long long _Fract/Accum. */ | 959 long long _Fract/Accum. */ |
797 | 960 |
798 #define CPP_N_WIDTH_MD 0xF0000 /* machine defined. */ | 961 #define CPP_N_WIDTH_MD 0xF0000 /* machine defined. */ |
810 #define CPP_N_DFLOAT 0x4000 | 973 #define CPP_N_DFLOAT 0x4000 |
811 #define CPP_N_DEFAULT 0x8000 | 974 #define CPP_N_DEFAULT 0x8000 |
812 | 975 |
813 #define CPP_N_FRACT 0x100000 /* Fract types. */ | 976 #define CPP_N_FRACT 0x100000 /* Fract types. */ |
814 #define CPP_N_ACCUM 0x200000 /* Accum types. */ | 977 #define CPP_N_ACCUM 0x200000 /* Accum types. */ |
978 #define CPP_N_FLOATN 0x400000 /* _FloatN types. */ | |
979 #define CPP_N_FLOATNX 0x800000 /* _FloatNx types. */ | |
980 | |
981 #define CPP_N_USERDEF 0x1000000 /* C++0x user-defined literal. */ | |
982 | |
983 #define CPP_N_WIDTH_FLOATN_NX 0xF0000000 /* _FloatN / _FloatNx value | |
984 of N, divided by 16. */ | |
985 #define CPP_FLOATN_SHIFT 24 | |
986 #define CPP_FLOATN_MAX 0xF0 | |
815 | 987 |
816 /* Classify a CPP_NUMBER token. The return value is a combination of | 988 /* Classify a CPP_NUMBER token. The return value is a combination of |
817 the flags from the above sets. */ | 989 the flags from the above sets. */ |
818 extern unsigned cpp_classify_number (cpp_reader *, const cpp_token *); | 990 extern unsigned cpp_classify_number (cpp_reader *, const cpp_token *, |
991 const char **, source_location); | |
992 | |
993 /* Return the classification flags for a float suffix. */ | |
994 extern unsigned int cpp_interpret_float_suffix (cpp_reader *, const char *, | |
995 size_t); | |
996 | |
997 /* Return the classification flags for an int suffix. */ | |
998 extern unsigned int cpp_interpret_int_suffix (cpp_reader *, const char *, | |
999 size_t); | |
819 | 1000 |
820 /* Evaluate a token classified as category CPP_N_INTEGER. */ | 1001 /* Evaluate a token classified as category CPP_N_INTEGER. */ |
821 extern cpp_num cpp_interpret_integer (cpp_reader *, const cpp_token *, | 1002 extern cpp_num cpp_interpret_integer (cpp_reader *, const cpp_token *, |
822 unsigned int type); | 1003 unsigned int); |
823 | 1004 |
824 /* Sign extend a number, with PRECISION significant bits and all | 1005 /* Sign extend a number, with PRECISION significant bits and all |
825 others assumed clear, to fill out a cpp_num structure. */ | 1006 others assumed clear, to fill out a cpp_num structure. */ |
826 cpp_num cpp_num_sign_extend (cpp_num, size_t); | 1007 cpp_num cpp_num_sign_extend (cpp_num, size_t); |
827 | 1008 |
866 CPP_W_UNDEF, | 1047 CPP_W_UNDEF, |
867 CPP_W_UNUSED_MACROS, | 1048 CPP_W_UNUSED_MACROS, |
868 CPP_W_CXX_OPERATOR_NAMES, | 1049 CPP_W_CXX_OPERATOR_NAMES, |
869 CPP_W_NORMALIZE, | 1050 CPP_W_NORMALIZE, |
870 CPP_W_INVALID_PCH, | 1051 CPP_W_INVALID_PCH, |
871 CPP_W_WARNING_DIRECTIVE | 1052 CPP_W_WARNING_DIRECTIVE, |
1053 CPP_W_LITERAL_SUFFIX, | |
1054 CPP_W_DATE_TIME, | |
1055 CPP_W_PEDANTIC, | |
1056 CPP_W_C90_C99_COMPAT, | |
1057 CPP_W_CXX11_COMPAT, | |
1058 CPP_W_EXPANSION_TO_DEFINED | |
872 }; | 1059 }; |
873 | 1060 |
874 /* Output a diagnostic of some kind. */ | 1061 /* Output a diagnostic of some kind. */ |
875 extern bool cpp_error (cpp_reader *, int, const char *msgid, ...) | 1062 extern bool cpp_error (cpp_reader *, int, const char *msgid, ...) |
876 ATTRIBUTE_PRINTF_3; | 1063 ATTRIBUTE_PRINTF_3; |
882 ATTRIBUTE_PRINTF_3; | 1069 ATTRIBUTE_PRINTF_3; |
883 | 1070 |
884 /* Output a diagnostic with "MSGID: " preceding the | 1071 /* Output a diagnostic with "MSGID: " preceding the |
885 error string of errno. No location is printed. */ | 1072 error string of errno. No location is printed. */ |
886 extern bool cpp_errno (cpp_reader *, int, const char *msgid); | 1073 extern bool cpp_errno (cpp_reader *, int, const char *msgid); |
1074 /* Similarly, but with "FILENAME: " instead of "MSGID: ", where | |
1075 the filename is not localized. */ | |
1076 extern bool cpp_errno_filename (cpp_reader *, int, const char *filename, | |
1077 source_location loc); | |
887 | 1078 |
888 /* Same as cpp_error, except additionally specifies a position as a | 1079 /* Same as cpp_error, except additionally specifies a position as a |
889 (translation unit) physical line and physical column. If the line is | 1080 (translation unit) physical line and physical column. If the line is |
890 zero, then no location is printed. */ | 1081 zero, then no location is printed. */ |
891 extern bool cpp_error_with_line (cpp_reader *, int, source_location, | 1082 extern bool cpp_error_with_line (cpp_reader *, int, source_location, |
899 ATTRIBUTE_PRINTF_5; | 1090 ATTRIBUTE_PRINTF_5; |
900 extern bool cpp_warning_with_line_syshdr (cpp_reader *, int, source_location, | 1091 extern bool cpp_warning_with_line_syshdr (cpp_reader *, int, source_location, |
901 unsigned, const char *msgid, ...) | 1092 unsigned, const char *msgid, ...) |
902 ATTRIBUTE_PRINTF_5; | 1093 ATTRIBUTE_PRINTF_5; |
903 | 1094 |
1095 extern bool cpp_error_at (cpp_reader * pfile, int level, | |
1096 source_location src_loc, const char *msgid, ...) | |
1097 ATTRIBUTE_PRINTF_4; | |
1098 | |
1099 extern bool cpp_error_at_richloc (cpp_reader * pfile, int level, | |
1100 rich_location *richloc, const char *msgid, | |
1101 ...) | |
1102 ATTRIBUTE_PRINTF_4; | |
1103 | |
904 /* In lex.c */ | 1104 /* In lex.c */ |
905 extern int cpp_ideq (const cpp_token *, const char *); | 1105 extern int cpp_ideq (const cpp_token *, const char *); |
906 extern void cpp_output_line (cpp_reader *, FILE *); | 1106 extern void cpp_output_line (cpp_reader *, FILE *); |
907 extern unsigned char *cpp_output_line_to_string (cpp_reader *, | 1107 extern unsigned char *cpp_output_line_to_string (cpp_reader *, |
908 const unsigned char *); | 1108 const unsigned char *); |
965 /* In files.c */ | 1165 /* In files.c */ |
966 extern bool cpp_included (cpp_reader *, const char *); | 1166 extern bool cpp_included (cpp_reader *, const char *); |
967 extern bool cpp_included_before (cpp_reader *, const char *, source_location); | 1167 extern bool cpp_included_before (cpp_reader *, const char *, source_location); |
968 extern void cpp_make_system_header (cpp_reader *, int, int); | 1168 extern void cpp_make_system_header (cpp_reader *, int, int); |
969 extern bool cpp_push_include (cpp_reader *, const char *); | 1169 extern bool cpp_push_include (cpp_reader *, const char *); |
1170 extern bool cpp_push_default_include (cpp_reader *, const char *); | |
970 extern void cpp_change_file (cpp_reader *, enum lc_reason, const char *); | 1171 extern void cpp_change_file (cpp_reader *, enum lc_reason, const char *); |
971 extern const char *cpp_get_path (struct _cpp_file *); | 1172 extern const char *cpp_get_path (struct _cpp_file *); |
972 extern cpp_dir *cpp_get_dir (struct _cpp_file *); | 1173 extern cpp_dir *cpp_get_dir (struct _cpp_file *); |
973 extern cpp_buffer *cpp_get_buffer (cpp_reader *); | 1174 extern cpp_buffer *cpp_get_buffer (cpp_reader *); |
974 extern struct _cpp_file *cpp_get_file (cpp_buffer *); | 1175 extern struct _cpp_file *cpp_get_file (cpp_buffer *); |
983 extern int cpp_valid_state (cpp_reader *, const char *, int); | 1184 extern int cpp_valid_state (cpp_reader *, const char *, int); |
984 extern void cpp_prepare_state (cpp_reader *, struct save_macro_data **); | 1185 extern void cpp_prepare_state (cpp_reader *, struct save_macro_data **); |
985 extern int cpp_read_state (cpp_reader *, const char *, FILE *, | 1186 extern int cpp_read_state (cpp_reader *, const char *, FILE *, |
986 struct save_macro_data *); | 1187 struct save_macro_data *); |
987 | 1188 |
1189 /* In lex.c */ | |
1190 extern void cpp_force_token_locations (cpp_reader *, source_location *); | |
1191 extern void cpp_stop_forcing_token_locations (cpp_reader *); | |
1192 | |
1193 /* In expr.c */ | |
1194 extern enum cpp_ttype cpp_userdef_string_remove_type | |
1195 (enum cpp_ttype type); | |
1196 extern enum cpp_ttype cpp_userdef_string_add_type | |
1197 (enum cpp_ttype type); | |
1198 extern enum cpp_ttype cpp_userdef_char_remove_type | |
1199 (enum cpp_ttype type); | |
1200 extern enum cpp_ttype cpp_userdef_char_add_type | |
1201 (enum cpp_ttype type); | |
1202 extern bool cpp_userdef_string_p | |
1203 (enum cpp_ttype type); | |
1204 extern bool cpp_userdef_char_p | |
1205 (enum cpp_ttype type); | |
1206 extern const char * cpp_get_userdef_suffix | |
1207 (const cpp_token *); | |
1208 | |
988 #endif /* ! LIBCPP_CPPLIB_H */ | 1209 #endif /* ! LIBCPP_CPPLIB_H */ |