Showing the changes to gcc/libcpp/include/cpplib.h (1 of 31387 files). Show all
Unified · Split
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* Definitions for CPP library. |
| 2 | − Copyright (C) 1995-2018 Free Software Foundation, Inc. | |
| 2 | + Copyright (C) 1995-2019 Free Software Foundation, Inc. | |
| 3 | 3 | Written by Per Bothner, 1994-95. |
| 4 | 4 | |
| 5 | 5 | This program is free software; you can redistribute it and/or modify it |
| @@ -36,7 +36,6 @@ typedef struct cpp_macro cpp_macro; · 30 unmodified lines | ||
| 36 | 36 | typedef struct cpp_callbacks cpp_callbacks; |
| 37 | 37 | typedef struct cpp_dir cpp_dir; |
| 38 | 38 | |
| 39 | −struct answer; | |
| 40 | 39 | struct _cpp_file; |
| 41 | 40 | |
| 42 | 41 | /* The first three groups, apart from '=', can appear in preprocessor |
| @@ -168,8 +167,9 @@ enum cpp_ttype · 125 unmodified lines | ||
| 168 | 167 | #undef TK |
| 169 | 168 | |
| 170 | 169 | /* C language kind, used when calling cpp_create_reader. */ |
| 171 | −enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11, CLK_GNUC17, | |
| 170 | +enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11, CLK_GNUC17, CLK_GNUC2X, | |
| 172 | 171 | CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_STDC11, CLK_STDC17, |
| 172 | + CLK_STDC2X, | |
| 173 | 173 | CLK_GNUCXX, CLK_CXX98, CLK_GNUCXX11, CLK_CXX11, |
| 174 | 174 | CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX17, CLK_CXX17, |
| 175 | 175 | CLK_GNUCXX2A, CLK_CXX2A, CLK_ASM}; |
| @@ -240,8 +240,10 @@ struct GTY(()) cpp_identifier { · 64 unmodified lines | ||
| 240 | 240 | /* A preprocessing token. This has been carefully packed and should |
| 241 | 241 | occupy 16 bytes on 32-bit hosts and 24 bytes on 64-bit hosts. */ |
| 242 | 242 | struct GTY(()) cpp_token { |
| 243 | − source_location src_loc; /* Location of first char of token, | |
| 244 | − together with range of full token. */ | |
| 243 | + | |
| 244 | + /* Location of first char of token, together with range of full token. */ | |
| 245 | + location_t src_loc; | |
| 246 | + | |
| 245 | 247 | ENUM_BITFIELD(cpp_ttype) type : CHAR_BIT; /* token type */ |
| 246 | 248 | unsigned short flags; /* flags - see above */ |
| 247 | 249 | |
| @@ -550,6 +552,59 @@ struct cpp_options · 302 unmodified lines | ||
| 550 | 552 | bool canonical_system_headers; |
| 551 | 553 | }; |
| 552 | 554 | |
| 555 | +/* Diagnostic levels. To get a diagnostic without associating a | |
| 556 | + position in the translation unit with it, use cpp_error_with_line | |
| 557 | + with a line number of zero. */ | |
| 558 | + | |
| 559 | +enum cpp_diagnostic_level { | |
| 560 | + /* Warning, an error with -Werror. */ | |
| 561 | + CPP_DL_WARNING = 0, | |
| 562 | + /* Same as CPP_DL_WARNING, except it is not suppressed in system headers. */ | |
| 563 | + CPP_DL_WARNING_SYSHDR, | |
| 564 | + /* Warning, an error with -pedantic-errors or -Werror. */ | |
| 565 | + CPP_DL_PEDWARN, | |
| 566 | + /* An error. */ | |
| 567 | + CPP_DL_ERROR, | |
| 568 | + /* An internal consistency check failed. Prints "internal error: ", | |
| 569 | + otherwise the same as CPP_DL_ERROR. */ | |
| 570 | + CPP_DL_ICE, | |
| 571 | + /* An informative note following a warning. */ | |
| 572 | + CPP_DL_NOTE, | |
| 573 | + /* A fatal error. */ | |
| 574 | + CPP_DL_FATAL | |
| 575 | +}; | |
| 576 | + | |
| 577 | +/* Warning reason codes. Use a reason code of CPP_W_NONE for unclassified | |
| 578 | + warnings and diagnostics that are not warnings. */ | |
| 579 | + | |
| 580 | +enum cpp_warning_reason { | |
| 581 | + CPP_W_NONE = 0, | |
| 582 | + CPP_W_DEPRECATED, | |
| 583 | + CPP_W_COMMENTS, | |
| 584 | + CPP_W_MISSING_INCLUDE_DIRS, | |
| 585 | + CPP_W_TRIGRAPHS, | |
| 586 | + CPP_W_MULTICHAR, | |
| 587 | + CPP_W_TRADITIONAL, | |
| 588 | + CPP_W_LONG_LONG, | |
| 589 | + CPP_W_ENDIF_LABELS, | |
| 590 | + CPP_W_NUM_SIGN_CHANGE, | |
| 591 | + CPP_W_VARIADIC_MACROS, | |
| 592 | + CPP_W_BUILTIN_MACRO_REDEFINED, | |
| 593 | + CPP_W_DOLLARS, | |
| 594 | + CPP_W_UNDEF, | |
| 595 | + CPP_W_UNUSED_MACROS, | |
| 596 | + CPP_W_CXX_OPERATOR_NAMES, | |
| 597 | + CPP_W_NORMALIZE, | |
| 598 | + CPP_W_INVALID_PCH, | |
| 599 | + CPP_W_WARNING_DIRECTIVE, | |
| 600 | + CPP_W_LITERAL_SUFFIX, | |
| 601 | + CPP_W_DATE_TIME, | |
| 602 | + CPP_W_PEDANTIC, | |
| 603 | + CPP_W_C90_C99_COMPAT, | |
| 604 | + CPP_W_CXX11_COMPAT, | |
| 605 | + CPP_W_EXPANSION_TO_DEFINED | |
| 606 | +}; | |
| 607 | + | |
| 553 | 608 | /* Callback for header lookup for HEADER, which is the name of a |
| 554 | 609 | source file. It is used as a method of last resort to find headers |
| 555 | 610 | that are not otherwise found during the normal include processing. |
| @@ -571,12 +626,12 @@ struct cpp_callbacks · 15 unmodified lines | ||
| 571 | 626 | void (*file_change) (cpp_reader *, const line_map_ordinary *); |
| 572 | 627 | |
| 573 | 628 | void (*dir_change) (cpp_reader *, const char *); |
| 574 | − void (*include) (cpp_reader *, source_location, const unsigned char *, | |
| 629 | + void (*include) (cpp_reader *, location_t, const unsigned char *, | |
| 575 | 630 | const char *, int, const cpp_token **); |
| 576 | − void (*define) (cpp_reader *, source_location, cpp_hashnode *); | |
| 577 | − void (*undef) (cpp_reader *, source_location, cpp_hashnode *); | |
| 578 | − void (*ident) (cpp_reader *, source_location, const cpp_string *); | |
| 579 | − void (*def_pragma) (cpp_reader *, source_location); | |
| 631 | + void (*define) (cpp_reader *, location_t, cpp_hashnode *); | |
| 632 | + void (*undef) (cpp_reader *, location_t, cpp_hashnode *); | |
| 633 | + void (*ident) (cpp_reader *, location_t, const cpp_string *); | |
| 634 | + void (*def_pragma) (cpp_reader *, location_t); | |
| 580 | 635 | int (*valid_pch) (cpp_reader *, const char *, int); |
| 581 | 636 | void (*read_pch) (cpp_reader *, const char *, int, const char *); |
| 582 | 637 | missing_header_cb missing_header; |
| @@ -587,26 +642,29 @@ struct cpp_callbacks · 4 unmodified lines | ||
| 587 | 642 | |
| 588 | 643 | /* Called to emit a diagnostic. This callback receives the |
| 589 | 644 | translated message. */ |
| 590 | − bool (*error) (cpp_reader *, int, int, rich_location *, | |
| 591 | − const char *, va_list *) | |
| 645 | + bool (*diagnostic) (cpp_reader *, | |
| 646 | + enum cpp_diagnostic_level, | |
| 647 | + enum cpp_warning_reason, | |
| 648 | + rich_location *, | |
| 649 | + const char *, va_list *) | |
| 592 | 650 | ATTRIBUTE_FPTR_PRINTF(5,0); |
| 593 | 651 | |
| 594 | 652 | /* Callbacks for when a macro is expanded, or tested (whether |
| 595 | 653 | defined or not at the time) in #ifdef, #ifndef or "defined". */ |
| 596 | − void (*used_define) (cpp_reader *, source_location, cpp_hashnode *); | |
| 597 | − void (*used_undef) (cpp_reader *, source_location, cpp_hashnode *); | |
| 654 | + void (*used_define) (cpp_reader *, location_t, cpp_hashnode *); | |
| 655 | + void (*used_undef) (cpp_reader *, location_t, cpp_hashnode *); | |
| 598 | 656 | /* Called before #define and #undef or other macro definition |
| 599 | 657 | changes are processed. */ |
| 600 | 658 | void (*before_define) (cpp_reader *); |
| 601 | 659 | /* Called whenever a macro is expanded or tested. |
| 602 | 660 | Second argument is the location of the start of the current expansion. */ |
| 603 | − void (*used) (cpp_reader *, source_location, cpp_hashnode *); | |
| 661 | + void (*used) (cpp_reader *, location_t, cpp_hashnode *); | |
| 604 | 662 | |
| 605 | 663 | /* Callback to identify whether an attribute exists. */ |
| 606 | 664 | int (*has_attribute) (cpp_reader *); |
| 607 | 665 | |
| 608 | − /* Callback that can change a user builtin into normal macro. */ | |
| 609 | − bool (*user_builtin_macro) (cpp_reader *, cpp_hashnode *); | |
| 666 | + /* Callback that can change a user lazy into normal macro. */ | |
| 667 | + void (*user_lazy_macro) (cpp_reader *, cpp_macro *, unsigned); | |
| 610 | 668 | |
| 611 | 669 | /* Callback to parse SOURCE_DATE_EPOCH from environment. */ |
| 612 | 670 | time_t (*get_source_date_epoch) (cpp_reader *); |
| @@ -620,7 +678,7 @@ struct cpp_callbacks · 7 unmodified lines | ||
| 620 | 678 | The content contains the opening slash-star (or slash-slash), |
| 621 | 679 | and for C-style comments contains the closing star-slash. For |
| 622 | 680 | C++-style comments it does not include the terminating newline. */ |
| 623 | − void (*comment) (cpp_reader *, source_location, const unsigned char *, | |
| 681 | + void (*comment) (cpp_reader *, location_t, const unsigned char *, | |
| 624 | 682 | size_t); |
| 625 | 683 | |
| 626 | 684 | /* Callback for filename remapping in __FILE__ and __BASE_FILE__ macro |
| @@ -671,14 +729,81 @@ struct cpp_dir · 44 unmodified lines | ||
| 671 | 729 | dev_t dev; |
| 672 | 730 | }; |
| 673 | 731 | |
| 674 | −/* The structure of a node in the hash table. The hash table has | |
| 675 | − entries for all identifiers: either macros defined by #define | |
| 676 | − commands (type NT_MACRO), assertions created with #assert | |
| 677 | − (NT_ASSERTION), or neither of the above (NT_VOID). Builtin macros | |
| 678 | − like __LINE__ are flagged NODE_BUILTIN. Poisoned identifiers are | |
| 679 | − flagged NODE_POISONED. NODE_OPERATOR (C++ only) indicates an | |
| 680 | − identifier that behaves like an operator such as "xor". | |
| 681 | − NODE_DIAGNOSTIC is for speed in lex_token: it indicates a | |
| 732 | +/* The kind of the cpp_macro. */ | |
| 733 | +enum cpp_macro_kind { | |
| 734 | + cmk_macro, /* An ISO macro (token expansion). */ | |
| 735 | + cmk_assert, /* An assertion. */ | |
| 736 | + cmk_traditional /* A traditional macro (text expansion). */ | |
| 737 | +}; | |
| 738 | + | |
| 739 | +/* Each macro definition is recorded in a cpp_macro structure. | |
| 740 | + Variadic macros cannot occur with traditional cpp. */ | |
| 741 | +struct GTY(()) cpp_macro { | |
| 742 | + union cpp_parm_u | |
| 743 | + { | |
| 744 | + /* Parameters, if any. If parameter names use extended identifiers, | |
| 745 | + the original spelling of those identifiers, not the canonical | |
| 746 | + UTF-8 spelling, goes here. */ | |
| 747 | + cpp_hashnode ** GTY ((tag ("false"), | |
| 748 | + nested_ptr (union tree_node, | |
| 749 | + "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL", | |
| 750 | + "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL"), | |
| 751 | + length ("%1.paramc"))) params; | |
| 752 | + | |
| 753 | + /* If this is an assertion, the next one in the chain. */ | |
| 754 | + cpp_macro *GTY ((tag ("true"))) next; | |
| 755 | + } GTY ((desc ("%1.kind == cmk_assert"))) parm; | |
| 756 | + | |
| 757 | + /* Definition line number. */ | |
| 758 | + location_t line; | |
| 759 | + | |
| 760 | + /* Number of tokens in body, or bytes for traditional macros. */ | |
| 761 | + /* Do we really need 2^32-1 range here? */ | |
| 762 | + unsigned int count; | |
| 763 | + | |
| 764 | + /* Number of parameters. */ | |
| 765 | + unsigned short paramc; | |
| 766 | + | |
| 767 | + /* Non-zero if this is a user-lazy macro, value provided by user. */ | |
| 768 | + unsigned char lazy; | |
| 769 | + | |
| 770 | + /* The kind of this macro (ISO, trad or assert) */ | |
| 771 | + unsigned kind : 2; | |
| 772 | + | |
| 773 | + /* If a function-like macro. */ | |
| 774 | + unsigned int fun_like : 1; | |
| 775 | + | |
| 776 | + /* If a variadic macro. */ | |
| 777 | + unsigned int variadic : 1; | |
| 778 | + | |
| 779 | + /* If macro defined in system header. */ | |
| 780 | + unsigned int syshdr : 1; | |
| 781 | + | |
| 782 | + /* Nonzero if it has been expanded or had its existence tested. */ | |
| 783 | + unsigned int used : 1; | |
| 784 | + | |
| 785 | + /* Indicate whether the tokens include extra CPP_PASTE tokens at the | |
| 786 | + end to track invalid redefinitions with consecutive CPP_PASTE | |
| 787 | + tokens. */ | |
| 788 | + unsigned int extra_tokens : 1; | |
| 789 | + | |
| 790 | + /* 1 bits spare (32-bit). 33 on 64-bit target. */ | |
| 791 | + | |
| 792 | + union cpp_exp_u | |
| 793 | + { | |
| 794 | + /* Trailing array of replacement tokens (ISO), or assertion body value. */ | |
| 795 | + cpp_token GTY ((tag ("false"), length ("%1.count"))) tokens[1]; | |
| 796 | + | |
| 797 | + /* Pointer to replacement text (traditional). See comment at top | |
| 798 | + of cpptrad.c for how traditional function-like macros are | |
| 799 | + encoded. */ | |
| 800 | + const unsigned char *GTY ((tag ("true"))) text; | |
| 801 | + } GTY ((desc ("%1.kind == cmk_traditional"))) exp; | |
| 802 | +}; | |
| 803 | + | |
| 804 | +/* Poisoned identifiers are flagged NODE_POISONED. NODE_OPERATOR (C++ | |
| 805 | + only) indicates an identifier that behaves like an operator such as | |
| 806 | + "xor". NODE_DIAGNOSTIC is for speed in lex_token: it indicates a | |
| 682 | 807 | diagnostic may be required for this node. Currently this only |
| 683 | 808 | applies to __VA_ARGS__, poisoned identifiers, and -Wc++-compat |
| 684 | 809 | warnings about NODE_OPERATOR. */ |
| @@ -686,21 +811,21 @@ struct cpp_dir · 1 unmodified line | ||
| 686 | 811 | /* Hash node flags. */ |
| 687 | 812 | #define NODE_OPERATOR (1 << 0) /* C++ named operator. */ |
| 688 | 813 | #define NODE_POISONED (1 << 1) /* Poisoned identifier. */ |
| 689 | −#define NODE_BUILTIN (1 << 2) /* Builtin macro. */ | |
| 690 | −#define NODE_DIAGNOSTIC (1 << 3) /* Possible diagnostic when lexed. */ | |
| 691 | −#define NODE_WARN (1 << 4) /* Warn if redefined or undefined. */ | |
| 692 | −#define NODE_DISABLED (1 << 5) /* A disabled macro. */ | |
| 693 | −#define NODE_MACRO_ARG (1 << 6) /* Used during #define processing. */ | |
| 694 | −#define NODE_USED (1 << 7) /* Dumped with -dU. */ | |
| 695 | −#define NODE_CONDITIONAL (1 << 8) /* Conditional macro */ | |
| 696 | −#define NODE_WARN_OPERATOR (1 << 9) /* Warn about C++ named operator. */ | |
| 814 | +#define NODE_DIAGNOSTIC (1 << 2) /* Possible diagnostic when lexed. */ | |
| 815 | +#define NODE_WARN (1 << 3) /* Warn if redefined or undefined. */ | |
| 816 | +#define NODE_DISABLED (1 << 4) /* A disabled macro. */ | |
| 817 | +#define NODE_USED (1 << 5) /* Dumped with -dU. */ | |
| 818 | +#define NODE_CONDITIONAL (1 << 6) /* Conditional macro */ | |
| 819 | +#define NODE_WARN_OPERATOR (1 << 7) /* Warn about C++ named operator. */ | |
| 697 | 820 | |
| 698 | 821 | /* Different flavors of hash node. */ |
| 699 | 822 | enum node_type |
| 700 | 823 | { |
| 701 | − NT_VOID = 0, /* No definition yet. */ | |
| 702 | − NT_MACRO, /* A macro of some form. */ | |
| 703 | − NT_ASSERTION /* Predicate for #assert. */ | |
| 824 | + NT_VOID = 0, /* Maybe an assert? */ | |
| 825 | + NT_MACRO_ARG, /* A macro arg. */ | |
| 826 | + NT_USER_MACRO, /* A user macro. */ | |
| 827 | + NT_BUILTIN_MACRO, /* A builtin macro. */ | |
| 828 | + NT_MACRO_MASK = NT_USER_MACRO /* Mask for either macro kind. */ | |
| 704 | 829 | }; |
| 705 | 830 | |
| 706 | 831 | /* Different flavors of builtin macro. _Pragma is an operator, but we |
| @@ -717,46 +842,27 @@ enum cpp_builtin_type · 10 unmodified lines | ||
| 717 | 842 | BT_PRAGMA, /* `_Pragma' operator */ |
| 718 | 843 | BT_TIMESTAMP, /* `__TIMESTAMP__' */ |
| 719 | 844 | BT_COUNTER, /* `__COUNTER__' */ |
| 720 | − BT_HAS_ATTRIBUTE, /* `__has_attribute__(x)' */ | |
| 721 | − BT_FIRST_USER, /* User defined builtin macros. */ | |
| 722 | − BT_LAST_USER = BT_FIRST_USER + 63 | |
| 845 | + BT_HAS_ATTRIBUTE /* `__has_attribute__(x)' */ | |
| 723 | 846 | }; |
| 724 | 847 | |
| 725 | 848 | #define CPP_HASHNODE(HNODE) ((cpp_hashnode *) (HNODE)) |
| 726 | −#define HT_NODE(NODE) ((ht_identifier *) (NODE)) | |
| 727 | −#define NODE_LEN(NODE) HT_LEN (&(NODE)->ident) | |
| 728 | −#define NODE_NAME(NODE) HT_STR (&(NODE)->ident) | |
| 729 | − | |
| 730 | −/* Specify which field, if any, of the union is used. */ | |
| 731 | − | |
| 732 | −enum { | |
| 733 | − NTV_MACRO, | |
| 734 | − NTV_ANSWER, | |
| 735 | − NTV_BUILTIN, | |
| 736 | − NTV_ARGUMENT, | |
| 737 | − NTV_NONE | |
| 738 | −}; | |
| 739 | − | |
| 740 | −#define CPP_HASHNODE_VALUE_IDX(HNODE) \ | |
| 741 | − ((HNODE.flags & NODE_MACRO_ARG) ? NTV_ARGUMENT \ | |
| 742 | − : HNODE.type == NT_MACRO ? ((HNODE.flags & NODE_BUILTIN) \ | |
| 743 | − ? NTV_BUILTIN : NTV_MACRO) \ | |
| 744 | − : HNODE.type == NT_ASSERTION ? NTV_ANSWER \ | |
| 745 | − : NTV_NONE) | |
| 849 | +#define HT_NODE(NODE) (&(NODE)->ident) | |
| 850 | +#define NODE_LEN(NODE) HT_LEN (HT_NODE (NODE)) | |
| 851 | +#define NODE_NAME(NODE) HT_STR (HT_NODE (NODE)) | |
| 746 | 852 | |
| 747 | 853 | /* The common part of an identifier node shared amongst all 3 C front |
| 748 | 854 | ends. Also used to store CPP identifiers, which are a superset of |
| 749 | 855 | identifiers in the grammatical sense. */ |
| 750 | 856 | |
| 751 | 857 | union GTY(()) _cpp_hashnode_value { |
| 752 | − /* If a macro. */ | |
| 753 | − cpp_macro * GTY((tag ("NTV_MACRO"))) macro; | |
| 754 | − /* Answers to an assertion. */ | |
| 755 | − struct answer * GTY ((tag ("NTV_ANSWER"))) answers; | |
| 858 | + /* Assert (maybe NULL) */ | |
| 859 | + cpp_macro * GTY((tag ("NT_VOID"))) answers; | |
| 860 | + /* Macro (never NULL) */ | |
| 861 | + cpp_macro * GTY((tag ("NT_USER_MACRO"))) macro; | |
| 756 | 862 | /* Code for a builtin macro. */ |
| 757 | − enum cpp_builtin_type GTY ((tag ("NTV_BUILTIN"))) builtin; | |
| 863 | + enum cpp_builtin_type GTY ((tag ("NT_BUILTIN_MACRO"))) builtin; | |
| 758 | 864 | /* Macro argument index. */ |
| 759 | − unsigned short GTY ((tag ("NTV_ARGUMENT"))) arg_index; | |
| 865 | + unsigned short GTY ((tag ("NT_MACRO_ARG"))) arg_index; | |
| 760 | 866 | }; |
| 761 | 867 | |
| 762 | 868 | struct GTY(()) cpp_hashnode { |
| @@ -766,10 +872,12 @@ struct GTY(()) cpp_hashnode { · 3 unmodified lines | ||
| 766 | 872 | then index into directive table. |
| 767 | 873 | Otherwise, a NODE_OPERATOR. */ |
| 768 | 874 | unsigned char rid_code; /* Rid code - for front ends. */ |
| 769 | − ENUM_BITFIELD(node_type) type : 6; /* CPP node type. */ | |
| 770 | − unsigned int flags : 10; /* CPP flags. */ | |
| 875 | + ENUM_BITFIELD(node_type) type : 2; /* CPP node type. */ | |
| 876 | + unsigned int flags : 8; /* CPP flags. */ | |
| 877 | + | |
| 878 | + /* 6 bits spare (plus another 32 on 64-bit hosts). */ | |
| 771 | 879 | |
| 772 | − union _cpp_hashnode_value GTY ((desc ("CPP_HASHNODE_VALUE_IDX (%1)"))) value; | |
| 880 | + union _cpp_hashnode_value GTY ((desc ("%1.type"))) value; | |
| 773 | 881 | }; |
| 774 | 882 | |
| 775 | 883 | /* A class for iterating through the source locations within a |
| @@ -778,13 +886,13 @@ struct GTY(()) cpp_hashnode { · 2 unmodified lines | ||
| 778 | 886 | |
| 779 | 887 | class cpp_string_location_reader { |
| 780 | 888 | public: |
| 781 | − cpp_string_location_reader (source_location src_loc, | |
| 889 | + cpp_string_location_reader (location_t src_loc, | |
| 782 | 890 | line_maps *line_table); |
| 783 | 891 | |
| 784 | 892 | source_range get_next (); |
| 785 | 893 | |
| 786 | 894 | private: |
| 787 | − source_location m_loc; | |
| 895 | + location_t m_loc; | |
| 788 | 896 | int m_offset_per_column; |
| 789 | 897 | line_maps *m_line_table; |
| 790 | 898 | }; |
| @@ -889,11 +997,32 @@ extern int cpp_avoid_paste (cpp_reader *, const cpp_token *, · 98 unmodified lines | ||
| 889 | 997 | const cpp_token *); |
| 890 | 998 | extern const cpp_token *cpp_get_token (cpp_reader *); |
| 891 | 999 | extern const cpp_token *cpp_get_token_with_location (cpp_reader *, |
| 892 | − source_location *); | |
| 893 | −extern bool cpp_fun_like_macro_p (cpp_hashnode *); | |
| 1000 | + location_t *); | |
| 1001 | +inline bool cpp_user_macro_p (const cpp_hashnode *node) | |
| 1002 | +{ | |
| 1003 | + return node->type == NT_USER_MACRO; | |
| 1004 | +} | |
| 1005 | +inline bool cpp_builtin_macro_p (const cpp_hashnode *node) | |
| 1006 | +{ | |
| 1007 | + return node->type == NT_BUILTIN_MACRO; | |
| 1008 | +} | |
| 1009 | +inline bool cpp_macro_p (const cpp_hashnode *node) | |
| 1010 | +{ | |
| 1011 | + return node->type & NT_MACRO_MASK; | |
| 1012 | +} | |
| 1013 | + | |
| 1014 | +/* Returns true if NODE is a function-like user macro. */ | |
| 1015 | +inline bool cpp_fun_like_macro_p (cpp_hashnode *node) | |
| 1016 | +{ | |
| 1017 | + return cpp_user_macro_p (node) && node->value.macro->fun_like; | |
| 1018 | +} | |
| 1019 | + | |
| 894 | 1020 | extern const unsigned char *cpp_macro_definition (cpp_reader *, |
| 895 | 1021 | cpp_hashnode *); |
| 896 | −extern source_location cpp_macro_definition_location (cpp_hashnode *); | |
| 1022 | +inline location_t cpp_macro_definition_location (cpp_hashnode *node) | |
| 1023 | +{ | |
| 1024 | + return node->value.macro->line; | |
| 1025 | +} | |
| 897 | 1026 | extern void _cpp_backup_tokens (cpp_reader *, unsigned int); |
| 898 | 1027 | extern const cpp_token *cpp_peek_token (cpp_reader *, int); |
| 899 | 1028 | |
| @@ -926,6 +1055,9 @@ extern void cpp_assert (cpp_reader *, const char *); · 26 unmodified lines | ||
| 926 | 1055 | extern void cpp_undef (cpp_reader *, const char *); |
| 927 | 1056 | extern void cpp_unassert (cpp_reader *, const char *); |
| 928 | 1057 | |
| 1058 | +/* Mark a node as a lazily defined macro. */ | |
| 1059 | +extern void cpp_define_lazily (cpp_reader *, cpp_hashnode *node, unsigned N); | |
| 1060 | + | |
| 929 | 1061 | /* Undefine all macros and assertions. */ |
| 930 | 1062 | extern void cpp_undef_all (cpp_reader *); |
| 931 | 1063 | |
| @@ -996,7 +1128,7 @@ struct cpp_num · 64 unmodified lines | ||
| 996 | 1128 | /* Classify a CPP_NUMBER token. The return value is a combination of |
| 997 | 1129 | the flags from the above sets. */ |
| 998 | 1130 | extern unsigned cpp_classify_number (cpp_reader *, const cpp_token *, |
| 999 | − const char **, source_location); | |
| 1131 | + const char **, location_t); | |
| 1000 | 1132 | |
| 1001 | 1133 | /* Return the classification flags for a float suffix. */ |
| 1002 | 1134 | extern unsigned int cpp_interpret_float_suffix (cpp_reader *, const char *, |
| @@ -1014,99 +1146,55 @@ extern cpp_num cpp_interpret_integer (cpp_reader *, const cpp_token *, · 11 unmodified lines | ||
| 1014 | 1146 | others assumed clear, to fill out a cpp_num structure. */ |
| 1015 | 1147 | cpp_num cpp_num_sign_extend (cpp_num, size_t); |
| 1016 | 1148 | |
| 1017 | −/* Diagnostic levels. To get a diagnostic without associating a | |
| 1018 | − position in the translation unit with it, use cpp_error_with_line | |
| 1019 | − with a line number of zero. */ | |
| 1020 | − | |
| 1021 | −enum { | |
| 1022 | − /* Warning, an error with -Werror. */ | |
| 1023 | − CPP_DL_WARNING = 0, | |
| 1024 | − /* Same as CPP_DL_WARNING, except it is not suppressed in system headers. */ | |
| 1025 | − CPP_DL_WARNING_SYSHDR, | |
| 1026 | − /* Warning, an error with -pedantic-errors or -Werror. */ | |
| 1027 | − CPP_DL_PEDWARN, | |
| 1028 | − /* An error. */ | |
| 1029 | − CPP_DL_ERROR, | |
| 1030 | − /* An internal consistency check failed. Prints "internal error: ", | |
| 1031 | − otherwise the same as CPP_DL_ERROR. */ | |
| 1032 | − CPP_DL_ICE, | |
| 1033 | − /* An informative note following a warning. */ | |
| 1034 | − CPP_DL_NOTE, | |
| 1035 | − /* A fatal error. */ | |
| 1036 | − CPP_DL_FATAL | |
| 1037 | −}; | |
| 1038 | − | |
| 1039 | −/* Warning reason codes. Use a reason code of zero for unclassified warnings | |
| 1040 | − and errors that are not warnings. */ | |
| 1041 | −enum { | |
| 1042 | − CPP_W_NONE = 0, | |
| 1043 | − CPP_W_DEPRECATED, | |
| 1044 | − CPP_W_COMMENTS, | |
| 1045 | − CPP_W_MISSING_INCLUDE_DIRS, | |
| 1046 | − CPP_W_TRIGRAPHS, | |
| 1047 | − CPP_W_MULTICHAR, | |
| 1048 | − CPP_W_TRADITIONAL, | |
| 1049 | − CPP_W_LONG_LONG, | |
| 1050 | − CPP_W_ENDIF_LABELS, | |
| 1051 | − CPP_W_NUM_SIGN_CHANGE, | |
| 1052 | − CPP_W_VARIADIC_MACROS, | |
| 1053 | − CPP_W_BUILTIN_MACRO_REDEFINED, | |
| 1054 | − CPP_W_DOLLARS, | |
| 1055 | − CPP_W_UNDEF, | |
| 1056 | − CPP_W_UNUSED_MACROS, | |
| 1057 | − CPP_W_CXX_OPERATOR_NAMES, | |
| 1058 | − CPP_W_NORMALIZE, | |
| 1059 | − CPP_W_INVALID_PCH, | |
| 1060 | − CPP_W_WARNING_DIRECTIVE, | |
| 1061 | − CPP_W_LITERAL_SUFFIX, | |
| 1062 | − CPP_W_DATE_TIME, | |
| 1063 | − CPP_W_PEDANTIC, | |
| 1064 | − CPP_W_C90_C99_COMPAT, | |
| 1065 | − CPP_W_CXX11_COMPAT, | |
| 1066 | − CPP_W_EXPANSION_TO_DEFINED | |
| 1067 | −}; | |
| 1068 | − | |
| 1069 | 1149 | /* Output a diagnostic of some kind. */ |
| 1070 | −extern bool cpp_error (cpp_reader *, int, const char *msgid, ...) | |
| 1150 | +extern bool cpp_error (cpp_reader *, enum cpp_diagnostic_level, | |
| 1151 | + const char *msgid, ...) | |
| 1071 | 1152 | ATTRIBUTE_PRINTF_3; |
| 1072 | −extern bool cpp_warning (cpp_reader *, int, const char *msgid, ...) | |
| 1153 | +extern bool cpp_warning (cpp_reader *, enum cpp_warning_reason, | |
| 1154 | + const char *msgid, ...) | |
| 1073 | 1155 | ATTRIBUTE_PRINTF_3; |
| 1074 | −extern bool cpp_pedwarning (cpp_reader *, int, const char *msgid, ...) | |
| 1156 | +extern bool cpp_pedwarning (cpp_reader *, enum cpp_warning_reason, | |
| 1157 | + const char *msgid, ...) | |
| 1075 | 1158 | ATTRIBUTE_PRINTF_3; |
| 1076 | −extern bool cpp_warning_syshdr (cpp_reader *, int, const char *msgid, ...) | |
| 1159 | +extern bool cpp_warning_syshdr (cpp_reader *, enum cpp_warning_reason reason, | |
| 1160 | + const char *msgid, ...) | |
| 1077 | 1161 | ATTRIBUTE_PRINTF_3; |
| 1078 | 1162 | |
| 1079 | 1163 | /* Output a diagnostic with "MSGID: " preceding the |
| 1080 | 1164 | error string of errno. No location is printed. */ |
| 1081 | −extern bool cpp_errno (cpp_reader *, int, const char *msgid); | |
| 1165 | +extern bool cpp_errno (cpp_reader *, enum cpp_diagnostic_level, | |
| 1166 | + const char *msgid); | |
| 1082 | 1167 | /* Similarly, but with "FILENAME: " instead of "MSGID: ", where |
| 1083 | 1168 | the filename is not localized. */ |
| 1084 | −extern bool cpp_errno_filename (cpp_reader *, int, const char *filename, | |
| 1085 | − source_location loc); | |
| 1169 | +extern bool cpp_errno_filename (cpp_reader *, enum cpp_diagnostic_level, | |
| 1170 | + const char *filename, location_t loc); | |
| 1086 | 1171 | |
| 1087 | 1172 | /* Same as cpp_error, except additionally specifies a position as a |
| 1088 | 1173 | (translation unit) physical line and physical column. If the line is |
| 1089 | 1174 | zero, then no location is printed. */ |
| 1090 | −extern bool cpp_error_with_line (cpp_reader *, int, source_location, | |
| 1091 | − unsigned, const char *msgid, ...) | |
| 1175 | +extern bool cpp_error_with_line (cpp_reader *, enum cpp_diagnostic_level, | |
| 1176 | + location_t, unsigned, | |
| 1177 | + const char *msgid, ...) | |
| 1092 | 1178 | ATTRIBUTE_PRINTF_5; |
| 1093 | −extern bool cpp_warning_with_line (cpp_reader *, int, source_location, | |
| 1094 | − unsigned, const char *msgid, ...) | |
| 1179 | +extern bool cpp_warning_with_line (cpp_reader *, enum cpp_warning_reason, | |
| 1180 | + location_t, unsigned, | |
| 1181 | + const char *msgid, ...) | |
| 1095 | 1182 | ATTRIBUTE_PRINTF_5; |
| 1096 | −extern bool cpp_pedwarning_with_line (cpp_reader *, int, source_location, | |
| 1097 | − unsigned, const char *msgid, ...) | |
| 1183 | +extern bool cpp_pedwarning_with_line (cpp_reader *, enum cpp_warning_reason, | |
| 1184 | + location_t, unsigned, | |
| 1185 | + const char *msgid, ...) | |
| 1098 | 1186 | ATTRIBUTE_PRINTF_5; |
| 1099 | −extern bool cpp_warning_with_line_syshdr (cpp_reader *, int, source_location, | |
| 1100 | − unsigned, const char *msgid, ...) | |
| 1187 | +extern bool cpp_warning_with_line_syshdr (cpp_reader *, enum cpp_warning_reason, | |
| 1188 | + location_t, unsigned, | |
| 1189 | + const char *msgid, ...) | |
| 1101 | 1190 | ATTRIBUTE_PRINTF_5; |
| 1102 | 1191 | |
| 1103 | −extern bool cpp_error_at (cpp_reader * pfile, int level, | |
| 1104 | − source_location src_loc, const char *msgid, ...) | |
| 1192 | +extern bool cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level, | |
| 1193 | + location_t src_loc, const char *msgid, ...) | |
| 1105 | 1194 | ATTRIBUTE_PRINTF_4; |
| 1106 | 1195 | |
| 1107 | −extern bool cpp_error_at (cpp_reader * pfile, int level, | |
| 1108 | − rich_location *richloc, const char *msgid, | |
| 1109 | − ...) | |
| 1196 | +extern bool cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level, | |
| 1197 | + rich_location *richloc, const char *msgid, ...) | |
| 1110 | 1198 | ATTRIBUTE_PRINTF_4; |
| 1111 | 1199 | |
| 1112 | 1200 | /* In lex.c */ |
| @@ -1133,7 +1221,7 @@ typedef struct · 20 unmodified lines | ||
| 1133 | 1221 | char *comment; |
| 1134 | 1222 | |
| 1135 | 1223 | /* source location for the given comment. */ |
| 1136 | − source_location sloc; | |
| 1224 | + location_t sloc; | |
| 1137 | 1225 | } cpp_comment; |
| 1138 | 1226 | |
| 1139 | 1227 | /* Structure holding all comments for a given cpp_reader. */ |
| @@ -1172,7 +1260,7 @@ extern unsigned char *cpp_quote_string (unsigned char *, const unsigned char *, · 32 unmodified lines | ||
| 1172 | 1260 | |
| 1173 | 1261 | /* In files.c */ |
| 1174 | 1262 | extern bool cpp_included (cpp_reader *, const char *); |
| 1175 | −extern bool cpp_included_before (cpp_reader *, const char *, source_location); | |
| 1263 | +extern bool cpp_included_before (cpp_reader *, const char *, location_t); | |
| 1176 | 1264 | extern void cpp_make_system_header (cpp_reader *, int, int); |
| 1177 | 1265 | extern bool cpp_push_include (cpp_reader *, const char *); |
| 1178 | 1266 | extern bool cpp_push_default_include (cpp_reader *, const char *); |
| @@ -1195,7 +1283,7 @@ extern int cpp_read_state (cpp_reader *, const char *, FILE *, · 16 unmodified lines | ||
| 1195 | 1283 | struct save_macro_data *); |
| 1196 | 1284 | |
| 1197 | 1285 | /* In lex.c */ |
| 1198 | −extern void cpp_force_token_locations (cpp_reader *, source_location *); | |
| 1286 | +extern void cpp_force_token_locations (cpp_reader *, location_t); | |
| 1199 | 1287 | extern void cpp_stop_forcing_token_locations (cpp_reader *); |
| 1200 | 1288 | |
| 1201 | 1289 | /* In expr.c */ |