xref: /netbsd-src/external/gpl3/gcc.old/dist/libcpp/include/cpplib.h (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
136ac495dSmrg /* Definitions for CPP library.
2*8feb0f0bSmrg    Copyright (C) 1995-2020 Free Software Foundation, Inc.
336ac495dSmrg    Written by Per Bothner, 1994-95.
436ac495dSmrg 
536ac495dSmrg This program is free software; you can redistribute it and/or modify it
636ac495dSmrg under the terms of the GNU General Public License as published by the
736ac495dSmrg Free Software Foundation; either version 3, or (at your option) any
836ac495dSmrg later version.
936ac495dSmrg 
1036ac495dSmrg This program is distributed in the hope that it will be useful,
1136ac495dSmrg but WITHOUT ANY WARRANTY; without even the implied warranty of
1236ac495dSmrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1336ac495dSmrg GNU General Public License for more details.
1436ac495dSmrg 
1536ac495dSmrg You should have received a copy of the GNU General Public License
1636ac495dSmrg along with this program; see the file COPYING3.  If not see
1736ac495dSmrg <http://www.gnu.org/licenses/>.
1836ac495dSmrg 
1936ac495dSmrg  In other words, you are welcome to use, share and improve this program.
2036ac495dSmrg  You are forbidden to forbid anyone else to use, share and improve
2136ac495dSmrg  what you give them.   Help stamp out software-hoarding!  */
2236ac495dSmrg #ifndef LIBCPP_CPPLIB_H
2336ac495dSmrg #define LIBCPP_CPPLIB_H
2436ac495dSmrg 
2536ac495dSmrg #include <sys/types.h>
2636ac495dSmrg #include "symtab.h"
2736ac495dSmrg #include "line-map.h"
2836ac495dSmrg 
2936ac495dSmrg typedef struct cpp_reader cpp_reader;
3036ac495dSmrg typedef struct cpp_buffer cpp_buffer;
3136ac495dSmrg typedef struct cpp_options cpp_options;
3236ac495dSmrg typedef struct cpp_token cpp_token;
3336ac495dSmrg typedef struct cpp_string cpp_string;
3436ac495dSmrg typedef struct cpp_hashnode cpp_hashnode;
3536ac495dSmrg typedef struct cpp_macro cpp_macro;
3636ac495dSmrg typedef struct cpp_callbacks cpp_callbacks;
3736ac495dSmrg typedef struct cpp_dir cpp_dir;
3836ac495dSmrg 
3936ac495dSmrg struct _cpp_file;
4036ac495dSmrg 
4136ac495dSmrg /* The first three groups, apart from '=', can appear in preprocessor
4236ac495dSmrg    expressions (+= and -= are used to indicate unary + and - resp.).
4336ac495dSmrg    This allows a lookup table to be implemented in _cpp_parse_expr.
4436ac495dSmrg 
4536ac495dSmrg    The first group, to CPP_LAST_EQ, can be immediately followed by an
4636ac495dSmrg    '='.  The lexer needs operators ending in '=', like ">>=", to be in
4736ac495dSmrg    the same order as their counterparts without the '=', like ">>".
4836ac495dSmrg 
4936ac495dSmrg    See the cpp_operator table optab in expr.c if you change the order or
5036ac495dSmrg    add or remove anything in the first group.  */
5136ac495dSmrg 
5236ac495dSmrg #define TTYPE_TABLE							\
5336ac495dSmrg   OP(EQ,		"=")						\
5436ac495dSmrg   OP(NOT,		"!")						\
5536ac495dSmrg   OP(GREATER,		">")	/* compare */				\
5636ac495dSmrg   OP(LESS,		"<")						\
5736ac495dSmrg   OP(PLUS,		"+")	/* math */				\
5836ac495dSmrg   OP(MINUS,		"-")						\
5936ac495dSmrg   OP(MULT,		"*")						\
6036ac495dSmrg   OP(DIV,		"/")						\
6136ac495dSmrg   OP(MOD,		"%")						\
6236ac495dSmrg   OP(AND,		"&")	/* bit ops */				\
6336ac495dSmrg   OP(OR,		"|")						\
6436ac495dSmrg   OP(XOR,		"^")						\
6536ac495dSmrg   OP(RSHIFT,		">>")						\
6636ac495dSmrg   OP(LSHIFT,		"<<")						\
6736ac495dSmrg 									\
6836ac495dSmrg   OP(COMPL,		"~")						\
6936ac495dSmrg   OP(AND_AND,		"&&")	/* logical */				\
7036ac495dSmrg   OP(OR_OR,		"||")						\
7136ac495dSmrg   OP(QUERY,		"?")						\
7236ac495dSmrg   OP(COLON,		":")						\
7336ac495dSmrg   OP(COMMA,		",")	/* grouping */				\
7436ac495dSmrg   OP(OPEN_PAREN,	"(")						\
7536ac495dSmrg   OP(CLOSE_PAREN,	")")						\
7636ac495dSmrg   TK(EOF,		NONE)						\
7736ac495dSmrg   OP(EQ_EQ,		"==")	/* compare */				\
7836ac495dSmrg   OP(NOT_EQ,		"!=")						\
7936ac495dSmrg   OP(GREATER_EQ,	">=")						\
8036ac495dSmrg   OP(LESS_EQ,		"<=")						\
81*8feb0f0bSmrg   OP(SPACESHIP,		"<=>")						\
8236ac495dSmrg 									\
8336ac495dSmrg   /* These two are unary + / - in preprocessor expressions.  */		\
8436ac495dSmrg   OP(PLUS_EQ,		"+=")	/* math */				\
8536ac495dSmrg   OP(MINUS_EQ,		"-=")						\
8636ac495dSmrg 									\
8736ac495dSmrg   OP(MULT_EQ,		"*=")						\
8836ac495dSmrg   OP(DIV_EQ,		"/=")						\
8936ac495dSmrg   OP(MOD_EQ,		"%=")						\
9036ac495dSmrg   OP(AND_EQ,		"&=")	/* bit ops */				\
9136ac495dSmrg   OP(OR_EQ,		"|=")						\
9236ac495dSmrg   OP(XOR_EQ,		"^=")						\
9336ac495dSmrg   OP(RSHIFT_EQ,		">>=")						\
9436ac495dSmrg   OP(LSHIFT_EQ,		"<<=")						\
9536ac495dSmrg   /* Digraphs together, beginning with CPP_FIRST_DIGRAPH.  */		\
9636ac495dSmrg   OP(HASH,		"#")	/* digraphs */				\
9736ac495dSmrg   OP(PASTE,		"##")						\
9836ac495dSmrg   OP(OPEN_SQUARE,	"[")						\
9936ac495dSmrg   OP(CLOSE_SQUARE,	"]")						\
10036ac495dSmrg   OP(OPEN_BRACE,	"{")						\
10136ac495dSmrg   OP(CLOSE_BRACE,	"}")						\
10236ac495dSmrg   /* The remainder of the punctuation.	Order is not significant.  */	\
10336ac495dSmrg   OP(SEMICOLON,		";")	/* structure */				\
10436ac495dSmrg   OP(ELLIPSIS,		"...")						\
10536ac495dSmrg   OP(PLUS_PLUS,		"++")	/* increment */				\
10636ac495dSmrg   OP(MINUS_MINUS,	"--")						\
10736ac495dSmrg   OP(DEREF,		"->")	/* accessors */				\
10836ac495dSmrg   OP(DOT,		".")						\
10936ac495dSmrg   OP(SCOPE,		"::")						\
11036ac495dSmrg   OP(DEREF_STAR,	"->*")						\
11136ac495dSmrg   OP(DOT_STAR,		".*")						\
11236ac495dSmrg   OP(ATSIGN,		"@")  /* used in Objective-C */			\
11336ac495dSmrg 									\
11436ac495dSmrg   TK(NAME,		IDENT)	 /* word */				\
11536ac495dSmrg   TK(AT_NAME,		IDENT)	 /* @word - Objective-C */		\
11636ac495dSmrg   TK(NUMBER,		LITERAL) /* 34_be+ta  */			\
11736ac495dSmrg 									\
11836ac495dSmrg   TK(CHAR,		LITERAL) /* 'char' */				\
11936ac495dSmrg   TK(WCHAR,		LITERAL) /* L'char' */				\
12036ac495dSmrg   TK(CHAR16,		LITERAL) /* u'char' */				\
12136ac495dSmrg   TK(CHAR32,		LITERAL) /* U'char' */				\
12236ac495dSmrg   TK(UTF8CHAR,		LITERAL) /* u8'char' */				\
12336ac495dSmrg   TK(OTHER,		LITERAL) /* stray punctuation */		\
12436ac495dSmrg 									\
12536ac495dSmrg   TK(STRING,		LITERAL) /* "string" */				\
12636ac495dSmrg   TK(WSTRING,		LITERAL) /* L"string" */			\
12736ac495dSmrg   TK(STRING16,		LITERAL) /* u"string" */			\
12836ac495dSmrg   TK(STRING32,		LITERAL) /* U"string" */			\
12936ac495dSmrg   TK(UTF8STRING,	LITERAL) /* u8"string" */			\
13036ac495dSmrg   TK(OBJC_STRING,	LITERAL) /* @"string" - Objective-C */		\
13136ac495dSmrg   TK(HEADER_NAME,	LITERAL) /* <stdio.h> in #include */		\
13236ac495dSmrg 									\
13336ac495dSmrg   TK(CHAR_USERDEF,	LITERAL) /* 'char'_suffix - C++-0x */		\
13436ac495dSmrg   TK(WCHAR_USERDEF,	LITERAL) /* L'char'_suffix - C++-0x */		\
13536ac495dSmrg   TK(CHAR16_USERDEF,	LITERAL) /* u'char'_suffix - C++-0x */		\
13636ac495dSmrg   TK(CHAR32_USERDEF,	LITERAL) /* U'char'_suffix - C++-0x */		\
13736ac495dSmrg   TK(UTF8CHAR_USERDEF,	LITERAL) /* u8'char'_suffix - C++-0x */		\
13836ac495dSmrg   TK(STRING_USERDEF,	LITERAL) /* "string"_suffix - C++-0x */		\
13936ac495dSmrg   TK(WSTRING_USERDEF,	LITERAL) /* L"string"_suffix - C++-0x */	\
14036ac495dSmrg   TK(STRING16_USERDEF,	LITERAL) /* u"string"_suffix - C++-0x */	\
14136ac495dSmrg   TK(STRING32_USERDEF,	LITERAL) /* U"string"_suffix - C++-0x */	\
14236ac495dSmrg   TK(UTF8STRING_USERDEF,LITERAL) /* u8"string"_suffix - C++-0x */	\
14336ac495dSmrg 									\
14436ac495dSmrg   TK(COMMENT,		LITERAL) /* Only if output comments.  */	\
14536ac495dSmrg 				 /* SPELL_LITERAL happens to DTRT.  */	\
14636ac495dSmrg   TK(MACRO_ARG,		NONE)	 /* Macro argument.  */			\
14736ac495dSmrg   TK(PRAGMA,		NONE)	 /* Only for deferred pragmas.  */	\
14836ac495dSmrg   TK(PRAGMA_EOL,	NONE)	 /* End-of-line for deferred pragmas.  */ \
14936ac495dSmrg   TK(PADDING,		NONE)	 /* Whitespace for -E.	*/
15036ac495dSmrg 
15136ac495dSmrg #define OP(e, s) CPP_ ## e,
15236ac495dSmrg #define TK(e, s) CPP_ ## e,
15336ac495dSmrg enum cpp_ttype
15436ac495dSmrg {
15536ac495dSmrg   TTYPE_TABLE
15636ac495dSmrg   N_TTYPES,
15736ac495dSmrg 
15836ac495dSmrg   /* A token type for keywords, as opposed to ordinary identifiers.  */
15936ac495dSmrg   CPP_KEYWORD,
16036ac495dSmrg 
16136ac495dSmrg   /* Positions in the table.  */
16236ac495dSmrg   CPP_LAST_EQ        = CPP_LSHIFT,
16336ac495dSmrg   CPP_FIRST_DIGRAPH  = CPP_HASH,
16436ac495dSmrg   CPP_LAST_PUNCTUATOR= CPP_ATSIGN,
16536ac495dSmrg   CPP_LAST_CPP_OP    = CPP_LESS_EQ
16636ac495dSmrg };
16736ac495dSmrg #undef OP
16836ac495dSmrg #undef TK
16936ac495dSmrg 
17036ac495dSmrg /* C language kind, used when calling cpp_create_reader.  */
171c0a68be4Smrg enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11, CLK_GNUC17, CLK_GNUC2X,
172a2dc1f3fSmrg 	     CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_STDC11, CLK_STDC17,
173c0a68be4Smrg 	     CLK_STDC2X,
17436ac495dSmrg 	     CLK_GNUCXX, CLK_CXX98, CLK_GNUCXX11, CLK_CXX11,
175a2dc1f3fSmrg 	     CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX17, CLK_CXX17,
176a2dc1f3fSmrg 	     CLK_GNUCXX2A, CLK_CXX2A, CLK_ASM};
17736ac495dSmrg 
17836ac495dSmrg /* Payload of a NUMBER, STRING, CHAR or COMMENT token.  */
17936ac495dSmrg struct GTY(()) cpp_string {
18036ac495dSmrg   unsigned int len;
18136ac495dSmrg   const unsigned char *text;
18236ac495dSmrg };
18336ac495dSmrg 
18436ac495dSmrg /* Flags for the cpp_token structure.  */
18536ac495dSmrg #define PREV_WHITE	(1 << 0) /* If whitespace before this token.  */
18636ac495dSmrg #define DIGRAPH		(1 << 1) /* If it was a digraph.  */
18736ac495dSmrg #define STRINGIFY_ARG	(1 << 2) /* If macro argument to be stringified.  */
18836ac495dSmrg #define PASTE_LEFT	(1 << 3) /* If on LHS of a ## operator.  */
18936ac495dSmrg #define NAMED_OP	(1 << 4) /* C++ named operators.  */
19036ac495dSmrg #define PREV_FALLTHROUGH (1 << 5) /* On a token preceeded by FALLTHROUGH
19136ac495dSmrg 				     comment.  */
19236ac495dSmrg #define BOL		(1 << 6) /* Token at beginning of line.  */
19336ac495dSmrg #define PURE_ZERO	(1 << 7) /* Single 0 digit, used by the C++ frontend,
19436ac495dSmrg 				    set in c-lex.c.  */
19536ac495dSmrg #define SP_DIGRAPH	(1 << 8) /* # or ## token was a digraph.  */
19636ac495dSmrg #define SP_PREV_WHITE	(1 << 9) /* If whitespace before a ##
19736ac495dSmrg 				    operator, or before this token
19836ac495dSmrg 				    after a # operator.  */
19936ac495dSmrg #define NO_EXPAND	(1 << 10) /* Do not macro-expand this token.  */
20036ac495dSmrg 
20136ac495dSmrg /* Specify which field, if any, of the cpp_token union is used.  */
20236ac495dSmrg 
20336ac495dSmrg enum cpp_token_fld_kind {
20436ac495dSmrg   CPP_TOKEN_FLD_NODE,
20536ac495dSmrg   CPP_TOKEN_FLD_SOURCE,
20636ac495dSmrg   CPP_TOKEN_FLD_STR,
20736ac495dSmrg   CPP_TOKEN_FLD_ARG_NO,
20836ac495dSmrg   CPP_TOKEN_FLD_TOKEN_NO,
20936ac495dSmrg   CPP_TOKEN_FLD_PRAGMA,
21036ac495dSmrg   CPP_TOKEN_FLD_NONE
21136ac495dSmrg };
21236ac495dSmrg 
21336ac495dSmrg /* A macro argument in the cpp_token union.  */
21436ac495dSmrg struct GTY(()) cpp_macro_arg {
21536ac495dSmrg   /* Argument number.  */
21636ac495dSmrg   unsigned int arg_no;
21736ac495dSmrg   /* The original spelling of the macro argument token.  */
21836ac495dSmrg   cpp_hashnode *
21936ac495dSmrg     GTY ((nested_ptr (union tree_node,
22036ac495dSmrg 		"%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
22136ac495dSmrg 			"%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL")))
22236ac495dSmrg        spelling;
22336ac495dSmrg };
22436ac495dSmrg 
22536ac495dSmrg /* An identifier in the cpp_token union.  */
22636ac495dSmrg struct GTY(()) cpp_identifier {
22736ac495dSmrg   /* The canonical (UTF-8) spelling of the identifier.  */
22836ac495dSmrg   cpp_hashnode *
22936ac495dSmrg     GTY ((nested_ptr (union tree_node,
23036ac495dSmrg 		"%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
23136ac495dSmrg 			"%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL")))
23236ac495dSmrg        node;
23336ac495dSmrg   /* The original spelling of the identifier.  */
23436ac495dSmrg   cpp_hashnode *
23536ac495dSmrg     GTY ((nested_ptr (union tree_node,
23636ac495dSmrg 		"%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
23736ac495dSmrg 			"%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL")))
23836ac495dSmrg        spelling;
23936ac495dSmrg };
24036ac495dSmrg 
24136ac495dSmrg /* A preprocessing token.  This has been carefully packed and should
24236ac495dSmrg    occupy 16 bytes on 32-bit hosts and 24 bytes on 64-bit hosts.  */
24336ac495dSmrg struct GTY(()) cpp_token {
244c0a68be4Smrg 
245c0a68be4Smrg   /* Location of first char of token, together with range of full token.  */
246c0a68be4Smrg   location_t src_loc;
247c0a68be4Smrg 
24836ac495dSmrg   ENUM_BITFIELD(cpp_ttype) type : CHAR_BIT;  /* token type */
24936ac495dSmrg   unsigned short flags;		/* flags - see above */
25036ac495dSmrg 
25136ac495dSmrg   union cpp_token_u
25236ac495dSmrg   {
25336ac495dSmrg     /* An identifier.  */
25436ac495dSmrg     struct cpp_identifier GTY ((tag ("CPP_TOKEN_FLD_NODE"))) node;
25536ac495dSmrg 
25636ac495dSmrg     /* Inherit padding from this token.  */
25736ac495dSmrg     cpp_token * GTY ((tag ("CPP_TOKEN_FLD_SOURCE"))) source;
25836ac495dSmrg 
25936ac495dSmrg     /* A string, or number.  */
26036ac495dSmrg     struct cpp_string GTY ((tag ("CPP_TOKEN_FLD_STR"))) str;
26136ac495dSmrg 
26236ac495dSmrg     /* Argument no. (and original spelling) for a CPP_MACRO_ARG.  */
26336ac495dSmrg     struct cpp_macro_arg GTY ((tag ("CPP_TOKEN_FLD_ARG_NO"))) macro_arg;
26436ac495dSmrg 
26536ac495dSmrg     /* Original token no. for a CPP_PASTE (from a sequence of
26636ac495dSmrg        consecutive paste tokens in a macro expansion).  */
26736ac495dSmrg     unsigned int GTY ((tag ("CPP_TOKEN_FLD_TOKEN_NO"))) token_no;
26836ac495dSmrg 
26936ac495dSmrg     /* Caller-supplied identifier for a CPP_PRAGMA.  */
27036ac495dSmrg     unsigned int GTY ((tag ("CPP_TOKEN_FLD_PRAGMA"))) pragma;
27136ac495dSmrg   } GTY ((desc ("cpp_token_val_index (&%1)"))) val;
27236ac495dSmrg };
27336ac495dSmrg 
27436ac495dSmrg /* Say which field is in use.  */
27536ac495dSmrg extern enum cpp_token_fld_kind cpp_token_val_index (const cpp_token *tok);
27636ac495dSmrg 
27736ac495dSmrg /* A type wide enough to hold any multibyte source character.
27836ac495dSmrg    cpplib's character constant interpreter requires an unsigned type.
27936ac495dSmrg    Also, a typedef for the signed equivalent.
28036ac495dSmrg    The width of this type is capped at 32 bits; there do exist targets
28136ac495dSmrg    where wchar_t is 64 bits, but only in a non-default mode, and there
28236ac495dSmrg    would be no meaningful interpretation for a wchar_t value greater
28336ac495dSmrg    than 2^32 anyway -- the widest wide-character encoding around is
28436ac495dSmrg    ISO 10646, which stops at 2^31.  */
28536ac495dSmrg #if CHAR_BIT * SIZEOF_INT >= 32
28636ac495dSmrg # define CPPCHAR_SIGNED_T int
28736ac495dSmrg #elif CHAR_BIT * SIZEOF_LONG >= 32
28836ac495dSmrg # define CPPCHAR_SIGNED_T long
28936ac495dSmrg #else
29036ac495dSmrg # error "Cannot find a least-32-bit signed integer type"
29136ac495dSmrg #endif
29236ac495dSmrg typedef unsigned CPPCHAR_SIGNED_T cppchar_t;
29336ac495dSmrg typedef CPPCHAR_SIGNED_T cppchar_signed_t;
29436ac495dSmrg 
29536ac495dSmrg /* Style of header dependencies to generate.  */
29636ac495dSmrg enum cpp_deps_style { DEPS_NONE = 0, DEPS_USER, DEPS_SYSTEM };
29736ac495dSmrg 
29836ac495dSmrg /* The possible normalization levels, from most restrictive to least.  */
29936ac495dSmrg enum cpp_normalize_level {
30036ac495dSmrg   /* In NFKC.  */
30136ac495dSmrg   normalized_KC = 0,
30236ac495dSmrg   /* In NFC.  */
30336ac495dSmrg   normalized_C,
30436ac495dSmrg   /* In NFC, except for subsequences where being in NFC would make
30536ac495dSmrg      the identifier invalid.  */
30636ac495dSmrg   normalized_identifier_C,
30736ac495dSmrg   /* Not normalized at all.  */
30836ac495dSmrg   normalized_none
30936ac495dSmrg };
31036ac495dSmrg 
31136ac495dSmrg /* This structure is nested inside struct cpp_reader, and
31236ac495dSmrg    carries all the options visible to the command line.  */
31336ac495dSmrg struct cpp_options
31436ac495dSmrg {
31536ac495dSmrg   /* Characters between tab stops.  */
31636ac495dSmrg   unsigned int tabstop;
31736ac495dSmrg 
31836ac495dSmrg   /* The language we're preprocessing.  */
31936ac495dSmrg   enum c_lang lang;
32036ac495dSmrg 
32136ac495dSmrg   /* Nonzero means use extra default include directories for C++.  */
32236ac495dSmrg   unsigned char cplusplus;
32336ac495dSmrg 
32436ac495dSmrg   /* Nonzero means handle cplusplus style comments.  */
32536ac495dSmrg   unsigned char cplusplus_comments;
32636ac495dSmrg 
32736ac495dSmrg   /* Nonzero means define __OBJC__, treat @ as a special token, use
32836ac495dSmrg      the OBJC[PLUS]_INCLUDE_PATH environment variable, and allow
32936ac495dSmrg      "#import".  */
33036ac495dSmrg   unsigned char objc;
33136ac495dSmrg 
33236ac495dSmrg   /* Nonzero means don't copy comments into the output file.  */
33336ac495dSmrg   unsigned char discard_comments;
33436ac495dSmrg 
33536ac495dSmrg   /* Nonzero means don't copy comments into the output file during
33636ac495dSmrg      macro expansion.  */
33736ac495dSmrg   unsigned char discard_comments_in_macro_exp;
33836ac495dSmrg 
33936ac495dSmrg   /* Nonzero means process the ISO trigraph sequences.  */
34036ac495dSmrg   unsigned char trigraphs;
34136ac495dSmrg 
34236ac495dSmrg   /* Nonzero means process the ISO digraph sequences.  */
34336ac495dSmrg   unsigned char digraphs;
34436ac495dSmrg 
34536ac495dSmrg   /* Nonzero means to allow hexadecimal floats and LL suffixes.  */
34636ac495dSmrg   unsigned char extended_numbers;
34736ac495dSmrg 
34836ac495dSmrg   /* Nonzero means process u/U prefix literals (UTF-16/32).  */
34936ac495dSmrg   unsigned char uliterals;
35036ac495dSmrg 
35136ac495dSmrg   /* Nonzero means process u8 prefixed character literals (UTF-8).  */
35236ac495dSmrg   unsigned char utf8_char_literals;
35336ac495dSmrg 
35436ac495dSmrg   /* Nonzero means process r/R raw strings.  If this is set, uliterals
35536ac495dSmrg      must be set as well.  */
35636ac495dSmrg   unsigned char rliterals;
35736ac495dSmrg 
35836ac495dSmrg   /* Nonzero means print names of header files (-H).  */
35936ac495dSmrg   unsigned char print_include_names;
36036ac495dSmrg 
36136ac495dSmrg   /* Nonzero means complain about deprecated features.  */
36236ac495dSmrg   unsigned char cpp_warn_deprecated;
36336ac495dSmrg 
36436ac495dSmrg   /* Nonzero means warn if slash-star appears in a comment.  */
36536ac495dSmrg   unsigned char warn_comments;
36636ac495dSmrg 
36736ac495dSmrg   /* Nonzero means to warn about __DATA__, __TIME__ and __TIMESTAMP__ usage.   */
36836ac495dSmrg   unsigned char warn_date_time;
36936ac495dSmrg 
37036ac495dSmrg   /* Nonzero means warn if a user-supplied include directory does not
37136ac495dSmrg      exist.  */
37236ac495dSmrg   unsigned char warn_missing_include_dirs;
37336ac495dSmrg 
37436ac495dSmrg   /* Nonzero means warn if there are any trigraphs.  */
37536ac495dSmrg   unsigned char warn_trigraphs;
37636ac495dSmrg 
37736ac495dSmrg   /* Nonzero means warn about multicharacter charconsts.  */
37836ac495dSmrg   unsigned char warn_multichar;
37936ac495dSmrg 
38036ac495dSmrg   /* Nonzero means warn about various incompatibilities with
38136ac495dSmrg      traditional C.  */
38236ac495dSmrg   unsigned char cpp_warn_traditional;
38336ac495dSmrg 
38436ac495dSmrg   /* Nonzero means warn about long long numeric constants.  */
38536ac495dSmrg   unsigned char cpp_warn_long_long;
38636ac495dSmrg 
38736ac495dSmrg   /* Nonzero means warn about text after an #endif (or #else).  */
38836ac495dSmrg   unsigned char warn_endif_labels;
38936ac495dSmrg 
39036ac495dSmrg   /* Nonzero means warn about implicit sign changes owing to integer
39136ac495dSmrg      promotions.  */
39236ac495dSmrg   unsigned char warn_num_sign_change;
39336ac495dSmrg 
39436ac495dSmrg   /* Zero means don't warn about __VA_ARGS__ usage in c89 pedantic mode.
39536ac495dSmrg      Presumably the usage is protected by the appropriate #ifdef.  */
39636ac495dSmrg   unsigned char warn_variadic_macros;
39736ac495dSmrg 
39836ac495dSmrg   /* Nonzero means warn about builtin macros that are redefined or
39936ac495dSmrg      explicitly undefined.  */
40036ac495dSmrg   unsigned char warn_builtin_macro_redefined;
40136ac495dSmrg 
40236ac495dSmrg   /* Different -Wimplicit-fallthrough= levels.  */
40336ac495dSmrg   unsigned char cpp_warn_implicit_fallthrough;
40436ac495dSmrg 
40536ac495dSmrg   /* Nonzero means we should look for header.gcc files that remap file
40636ac495dSmrg      names.  */
40736ac495dSmrg   unsigned char remap;
40836ac495dSmrg 
40936ac495dSmrg   /* Zero means dollar signs are punctuation.  */
41036ac495dSmrg   unsigned char dollars_in_ident;
41136ac495dSmrg 
41236ac495dSmrg   /* Nonzero means UCNs are accepted in identifiers.  */
41336ac495dSmrg   unsigned char extended_identifiers;
41436ac495dSmrg 
41536ac495dSmrg   /* True if we should warn about dollars in identifiers or numbers
41636ac495dSmrg      for this translation unit.  */
41736ac495dSmrg   unsigned char warn_dollars;
41836ac495dSmrg 
41936ac495dSmrg   /* Nonzero means warn if undefined identifiers are evaluated in an #if.  */
42036ac495dSmrg   unsigned char warn_undef;
42136ac495dSmrg 
42236ac495dSmrg   /* Nonzero means warn if "defined" is encountered in a place other than
42336ac495dSmrg      an #if.  */
42436ac495dSmrg   unsigned char warn_expansion_to_defined;
42536ac495dSmrg 
42636ac495dSmrg   /* Nonzero means warn of unused macros from the main file.  */
42736ac495dSmrg   unsigned char warn_unused_macros;
42836ac495dSmrg 
42936ac495dSmrg   /* Nonzero for the 1999 C Standard, including corrigenda and amendments.  */
43036ac495dSmrg   unsigned char c99;
43136ac495dSmrg 
43236ac495dSmrg   /* Nonzero if we are conforming to a specific C or C++ standard.  */
43336ac495dSmrg   unsigned char std;
43436ac495dSmrg 
43536ac495dSmrg   /* Nonzero means give all the error messages the ANSI standard requires.  */
43636ac495dSmrg   unsigned char cpp_pedantic;
43736ac495dSmrg 
43836ac495dSmrg   /* Nonzero means we're looking at already preprocessed code, so don't
43936ac495dSmrg      bother trying to do macro expansion and whatnot.  */
44036ac495dSmrg   unsigned char preprocessed;
44136ac495dSmrg 
44236ac495dSmrg   /* Nonzero means we are going to emit debugging logs during
44336ac495dSmrg      preprocessing.  */
44436ac495dSmrg   unsigned char debug;
44536ac495dSmrg 
44636ac495dSmrg   /* Nonzero means we are tracking locations of tokens involved in
44736ac495dSmrg      macro expansion. 1 Means we track the location in degraded mode
44836ac495dSmrg      where we do not track locations of tokens resulting from the
44936ac495dSmrg      expansion of arguments of function-like macro.  2 Means we do
45036ac495dSmrg      track all macro expansions. This last option is the one that
45136ac495dSmrg      consumes the highest amount of memory.  */
45236ac495dSmrg   unsigned char track_macro_expansion;
45336ac495dSmrg 
45436ac495dSmrg   /* Nonzero means handle C++ alternate operator names.  */
45536ac495dSmrg   unsigned char operator_names;
45636ac495dSmrg 
45736ac495dSmrg   /* Nonzero means warn about use of C++ alternate operator names.  */
45836ac495dSmrg   unsigned char warn_cxx_operator_names;
45936ac495dSmrg 
46036ac495dSmrg   /* True for traditional preprocessing.  */
46136ac495dSmrg   unsigned char traditional;
46236ac495dSmrg 
46336ac495dSmrg   /* Nonzero for C++ 2011 Standard user-defined literals.  */
46436ac495dSmrg   unsigned char user_literals;
46536ac495dSmrg 
46636ac495dSmrg   /* Nonzero means warn when a string or character literal is followed by a
46736ac495dSmrg      ud-suffix which does not beging with an underscore.  */
46836ac495dSmrg   unsigned char warn_literal_suffix;
46936ac495dSmrg 
47036ac495dSmrg   /* Nonzero means interpret imaginary, fixed-point, or other gnu extension
47136ac495dSmrg      literal number suffixes as user-defined literal number suffixes.  */
47236ac495dSmrg   unsigned char ext_numeric_literals;
47336ac495dSmrg 
47436ac495dSmrg   /* Nonzero means extended identifiers allow the characters specified
47536ac495dSmrg      in C11 and C++11.  */
47636ac495dSmrg   unsigned char c11_identifiers;
47736ac495dSmrg 
47836ac495dSmrg   /* Nonzero for C++ 2014 Standard binary constants.  */
47936ac495dSmrg   unsigned char binary_constants;
48036ac495dSmrg 
48136ac495dSmrg   /* Nonzero for C++ 2014 Standard digit separators.  */
48236ac495dSmrg   unsigned char digit_separators;
48336ac495dSmrg 
484*8feb0f0bSmrg   /* Nonzero for C2X decimal floating-point constants.  */
485*8feb0f0bSmrg   unsigned char dfp_constants;
486*8feb0f0bSmrg 
487a2dc1f3fSmrg   /* Nonzero for C++2a __VA_OPT__ feature.  */
488a2dc1f3fSmrg   unsigned char va_opt;
489a2dc1f3fSmrg 
490*8feb0f0bSmrg   /* Nonzero for the '::' token.  */
491*8feb0f0bSmrg   unsigned char scope;
492*8feb0f0bSmrg 
49336ac495dSmrg   /* Holds the name of the target (execution) character set.  */
49436ac495dSmrg   const char *narrow_charset;
49536ac495dSmrg 
49636ac495dSmrg   /* Holds the name of the target wide character set.  */
49736ac495dSmrg   const char *wide_charset;
49836ac495dSmrg 
49936ac495dSmrg   /* Holds the name of the input character set.  */
50036ac495dSmrg   const char *input_charset;
50136ac495dSmrg 
50236ac495dSmrg   /* The minimum permitted level of normalization before a warning
50336ac495dSmrg      is generated.  See enum cpp_normalize_level.  */
50436ac495dSmrg   int warn_normalize;
50536ac495dSmrg 
50636ac495dSmrg   /* True to warn about precompiled header files we couldn't use.  */
50736ac495dSmrg   bool warn_invalid_pch;
50836ac495dSmrg 
50936ac495dSmrg   /* True if dependencies should be restored from a precompiled header.  */
51036ac495dSmrg   bool restore_pch_deps;
51136ac495dSmrg 
51236ac495dSmrg   /* True if warn about differences between C90 and C99.  */
51336ac495dSmrg   signed char cpp_warn_c90_c99_compat;
51436ac495dSmrg 
515*8feb0f0bSmrg   /* True if warn about differences between C11 and C2X.  */
516*8feb0f0bSmrg   signed char cpp_warn_c11_c2x_compat;
517*8feb0f0bSmrg 
51836ac495dSmrg   /* True if warn about differences between C++98 and C++11.  */
51936ac495dSmrg   bool cpp_warn_cxx11_compat;
52036ac495dSmrg 
52136ac495dSmrg   /* Dependency generation.  */
52236ac495dSmrg   struct
52336ac495dSmrg   {
52436ac495dSmrg     /* Style of header dependencies to generate.  */
52536ac495dSmrg     enum cpp_deps_style style;
52636ac495dSmrg 
52736ac495dSmrg     /* Assume missing files are generated files.  */
52836ac495dSmrg     bool missing_files;
52936ac495dSmrg 
53036ac495dSmrg     /* Generate phony targets for each dependency apart from the first
53136ac495dSmrg        one.  */
53236ac495dSmrg     bool phony_targets;
53336ac495dSmrg 
53436ac495dSmrg     /* If true, no dependency is generated on the main file.  */
53536ac495dSmrg     bool ignore_main_file;
53636ac495dSmrg 
53736ac495dSmrg     /* If true, intend to use the preprocessor output (e.g., for compilation)
53836ac495dSmrg        in addition to the dependency info.  */
53936ac495dSmrg     bool need_preprocessor_output;
54036ac495dSmrg   } deps;
54136ac495dSmrg 
54236ac495dSmrg   /* Target-specific features set by the front end or client.  */
54336ac495dSmrg 
54436ac495dSmrg   /* Precision for target CPP arithmetic, target characters, target
54536ac495dSmrg      ints and target wide characters, respectively.  */
54636ac495dSmrg   size_t precision, char_precision, int_precision, wchar_precision;
54736ac495dSmrg 
54836ac495dSmrg   /* True means chars (wide chars) are unsigned.  */
54936ac495dSmrg   bool unsigned_char, unsigned_wchar;
55036ac495dSmrg 
55136ac495dSmrg   /* True if the most significant byte in a word has the lowest
55236ac495dSmrg      address in memory.  */
55336ac495dSmrg   bool bytes_big_endian;
55436ac495dSmrg 
55536ac495dSmrg   /* Nonzero means __STDC__ should have the value 0 in system headers.  */
55636ac495dSmrg   unsigned char stdc_0_in_system_headers;
55736ac495dSmrg 
55836ac495dSmrg   /* True disables tokenization outside of preprocessing directives. */
55936ac495dSmrg   bool directives_only;
56036ac495dSmrg 
56136ac495dSmrg   /* True enables canonicalization of system header file paths. */
56236ac495dSmrg   bool canonical_system_headers;
563*8feb0f0bSmrg 
564*8feb0f0bSmrg   /* The maximum depth of the nested #include.  */
565*8feb0f0bSmrg   unsigned int max_include_depth;
56636ac495dSmrg };
56736ac495dSmrg 
568c0a68be4Smrg /* Diagnostic levels.  To get a diagnostic without associating a
569c0a68be4Smrg    position in the translation unit with it, use cpp_error_with_line
570c0a68be4Smrg    with a line number of zero.  */
571c0a68be4Smrg 
572c0a68be4Smrg enum cpp_diagnostic_level {
573c0a68be4Smrg   /* Warning, an error with -Werror.  */
574c0a68be4Smrg   CPP_DL_WARNING = 0,
575c0a68be4Smrg   /* Same as CPP_DL_WARNING, except it is not suppressed in system headers.  */
576c0a68be4Smrg   CPP_DL_WARNING_SYSHDR,
577c0a68be4Smrg   /* Warning, an error with -pedantic-errors or -Werror.  */
578c0a68be4Smrg   CPP_DL_PEDWARN,
579c0a68be4Smrg   /* An error.  */
580c0a68be4Smrg   CPP_DL_ERROR,
581c0a68be4Smrg   /* An internal consistency check failed.  Prints "internal error: ",
582c0a68be4Smrg      otherwise the same as CPP_DL_ERROR.  */
583c0a68be4Smrg   CPP_DL_ICE,
584c0a68be4Smrg   /* An informative note following a warning.  */
585c0a68be4Smrg   CPP_DL_NOTE,
586c0a68be4Smrg   /* A fatal error.  */
587c0a68be4Smrg   CPP_DL_FATAL
588c0a68be4Smrg };
589c0a68be4Smrg 
590c0a68be4Smrg /* Warning reason codes. Use a reason code of CPP_W_NONE for unclassified
591c0a68be4Smrg    warnings and diagnostics that are not warnings.  */
592c0a68be4Smrg 
593c0a68be4Smrg enum cpp_warning_reason {
594c0a68be4Smrg   CPP_W_NONE = 0,
595c0a68be4Smrg   CPP_W_DEPRECATED,
596c0a68be4Smrg   CPP_W_COMMENTS,
597c0a68be4Smrg   CPP_W_MISSING_INCLUDE_DIRS,
598c0a68be4Smrg   CPP_W_TRIGRAPHS,
599c0a68be4Smrg   CPP_W_MULTICHAR,
600c0a68be4Smrg   CPP_W_TRADITIONAL,
601c0a68be4Smrg   CPP_W_LONG_LONG,
602c0a68be4Smrg   CPP_W_ENDIF_LABELS,
603c0a68be4Smrg   CPP_W_NUM_SIGN_CHANGE,
604c0a68be4Smrg   CPP_W_VARIADIC_MACROS,
605c0a68be4Smrg   CPP_W_BUILTIN_MACRO_REDEFINED,
606c0a68be4Smrg   CPP_W_DOLLARS,
607c0a68be4Smrg   CPP_W_UNDEF,
608c0a68be4Smrg   CPP_W_UNUSED_MACROS,
609c0a68be4Smrg   CPP_W_CXX_OPERATOR_NAMES,
610c0a68be4Smrg   CPP_W_NORMALIZE,
611c0a68be4Smrg   CPP_W_INVALID_PCH,
612c0a68be4Smrg   CPP_W_WARNING_DIRECTIVE,
613c0a68be4Smrg   CPP_W_LITERAL_SUFFIX,
614c0a68be4Smrg   CPP_W_DATE_TIME,
615c0a68be4Smrg   CPP_W_PEDANTIC,
616c0a68be4Smrg   CPP_W_C90_C99_COMPAT,
617*8feb0f0bSmrg   CPP_W_C11_C2X_COMPAT,
618c0a68be4Smrg   CPP_W_CXX11_COMPAT,
619c0a68be4Smrg   CPP_W_EXPANSION_TO_DEFINED
620c0a68be4Smrg };
621c0a68be4Smrg 
62236ac495dSmrg /* Callback for header lookup for HEADER, which is the name of a
62336ac495dSmrg    source file.  It is used as a method of last resort to find headers
62436ac495dSmrg    that are not otherwise found during the normal include processing.
62536ac495dSmrg    The return value is the malloced name of a header to try and open,
62636ac495dSmrg    if any, or NULL otherwise.  This callback is called only if the
62736ac495dSmrg    header is otherwise unfound.  */
62836ac495dSmrg typedef const char *(*missing_header_cb)(cpp_reader *, const char *header, cpp_dir **);
62936ac495dSmrg 
63036ac495dSmrg /* Call backs to cpplib client.  */
63136ac495dSmrg struct cpp_callbacks
63236ac495dSmrg {
63336ac495dSmrg   /* Called when a new line of preprocessed output is started.  */
63436ac495dSmrg   void (*line_change) (cpp_reader *, const cpp_token *, int);
63536ac495dSmrg 
63636ac495dSmrg   /* Called when switching to/from a new file.
63736ac495dSmrg      The line_map is for the new file.  It is NULL if there is no new file.
63836ac495dSmrg      (In C this happens when done with <built-in>+<command line> and also
63936ac495dSmrg      when done with a main file.)  This can be used for resource cleanup.  */
64036ac495dSmrg   void (*file_change) (cpp_reader *, const line_map_ordinary *);
64136ac495dSmrg 
64236ac495dSmrg   void (*dir_change) (cpp_reader *, const char *);
643c0a68be4Smrg   void (*include) (cpp_reader *, location_t, const unsigned char *,
64436ac495dSmrg 		   const char *, int, const cpp_token **);
645c0a68be4Smrg   void (*define) (cpp_reader *, location_t, cpp_hashnode *);
646c0a68be4Smrg   void (*undef) (cpp_reader *, location_t, cpp_hashnode *);
647c0a68be4Smrg   void (*ident) (cpp_reader *, location_t, const cpp_string *);
648c0a68be4Smrg   void (*def_pragma) (cpp_reader *, location_t);
64936ac495dSmrg   int (*valid_pch) (cpp_reader *, const char *, int);
65036ac495dSmrg   void (*read_pch) (cpp_reader *, const char *, int, const char *);
65136ac495dSmrg   missing_header_cb missing_header;
65236ac495dSmrg 
65336ac495dSmrg   /* Context-sensitive macro support.  Returns macro (if any) that should
65436ac495dSmrg      be expanded.  */
65536ac495dSmrg   cpp_hashnode * (*macro_to_expand) (cpp_reader *, const cpp_token *);
65636ac495dSmrg 
65736ac495dSmrg   /* Called to emit a diagnostic.  This callback receives the
65836ac495dSmrg      translated message.  */
659c0a68be4Smrg   bool (*diagnostic) (cpp_reader *,
660c0a68be4Smrg 		      enum cpp_diagnostic_level,
661c0a68be4Smrg 		      enum cpp_warning_reason,
662c0a68be4Smrg 		      rich_location *,
66336ac495dSmrg 		      const char *, va_list *)
66436ac495dSmrg        ATTRIBUTE_FPTR_PRINTF(5,0);
66536ac495dSmrg 
66636ac495dSmrg   /* Callbacks for when a macro is expanded, or tested (whether
66736ac495dSmrg      defined or not at the time) in #ifdef, #ifndef or "defined".  */
668c0a68be4Smrg   void (*used_define) (cpp_reader *, location_t, cpp_hashnode *);
669c0a68be4Smrg   void (*used_undef) (cpp_reader *, location_t, cpp_hashnode *);
67036ac495dSmrg   /* Called before #define and #undef or other macro definition
67136ac495dSmrg      changes are processed.  */
67236ac495dSmrg   void (*before_define) (cpp_reader *);
67336ac495dSmrg   /* Called whenever a macro is expanded or tested.
67436ac495dSmrg      Second argument is the location of the start of the current expansion.  */
675c0a68be4Smrg   void (*used) (cpp_reader *, location_t, cpp_hashnode *);
67636ac495dSmrg 
67736ac495dSmrg   /* Callback to identify whether an attribute exists.  */
67836ac495dSmrg   int (*has_attribute) (cpp_reader *);
67936ac495dSmrg 
680*8feb0f0bSmrg   /* Callback to determine whether a built-in function is recognized.  */
681*8feb0f0bSmrg   int (*has_builtin) (cpp_reader *);
682*8feb0f0bSmrg 
683c0a68be4Smrg   /* Callback that can change a user lazy into normal macro.  */
684c0a68be4Smrg   void (*user_lazy_macro) (cpp_reader *, cpp_macro *, unsigned);
68536ac495dSmrg 
68636ac495dSmrg   /* Callback to parse SOURCE_DATE_EPOCH from environment.  */
68736ac495dSmrg   time_t (*get_source_date_epoch) (cpp_reader *);
68836ac495dSmrg 
68936ac495dSmrg   /* Callback for providing suggestions for misspelled directives.  */
69036ac495dSmrg   const char *(*get_suggestion) (cpp_reader *, const char *, const char *const *);
691a2dc1f3fSmrg 
692a2dc1f3fSmrg   /* Callback for when a comment is encountered, giving the location
693a2dc1f3fSmrg      of the opening slash, a pointer to the content (which is not
694a2dc1f3fSmrg      necessarily 0-terminated), and the length of the content.
695a2dc1f3fSmrg      The content contains the opening slash-star (or slash-slash),
696a2dc1f3fSmrg      and for C-style comments contains the closing star-slash.  For
697a2dc1f3fSmrg      C++-style comments it does not include the terminating newline.  */
698c0a68be4Smrg   void (*comment) (cpp_reader *, location_t, const unsigned char *,
699a2dc1f3fSmrg 		   size_t);
700a2dc1f3fSmrg 
701a2dc1f3fSmrg   /* Callback for filename remapping in __FILE__ and __BASE_FILE__ macro
702a2dc1f3fSmrg      expansions.  */
703a2dc1f3fSmrg   const char *(*remap_filename) (const char*);
70436ac495dSmrg };
70536ac495dSmrg 
70636ac495dSmrg #ifdef VMS
70736ac495dSmrg #define INO_T_CPP ino_t ino[3]
70836ac495dSmrg #else
70936ac495dSmrg #define INO_T_CPP ino_t ino
71036ac495dSmrg #endif
71136ac495dSmrg 
71236ac495dSmrg /* Chain of directories to look for include files in.  */
71336ac495dSmrg struct cpp_dir
71436ac495dSmrg {
71536ac495dSmrg   /* NULL-terminated singly-linked list.  */
71636ac495dSmrg   struct cpp_dir *next;
71736ac495dSmrg 
71836ac495dSmrg   /* NAME of the directory, NUL-terminated.  */
71936ac495dSmrg   char *name;
72036ac495dSmrg   unsigned int len;
72136ac495dSmrg 
72236ac495dSmrg   /* One if a system header, two if a system header that has extern
72336ac495dSmrg      "C" guards for C++.  */
72436ac495dSmrg   unsigned char sysp;
72536ac495dSmrg 
72636ac495dSmrg   /* Is this a user-supplied directory? */
72736ac495dSmrg   bool user_supplied_p;
72836ac495dSmrg 
72936ac495dSmrg   /* The canonicalized NAME as determined by lrealpath.  This field
73036ac495dSmrg      is only used by hosts that lack reliable inode numbers.  */
73136ac495dSmrg   char *canonical_name;
73236ac495dSmrg 
73336ac495dSmrg   /* Mapping of file names for this directory for MS-DOS and related
73436ac495dSmrg      platforms.  A NULL-terminated array of (from, to) pairs.  */
73536ac495dSmrg   const char **name_map;
73636ac495dSmrg 
73736ac495dSmrg   /* Routine to construct pathname, given the search path name and the
73836ac495dSmrg      HEADER we are trying to find, return a constructed pathname to
73936ac495dSmrg      try and open.  If this is NULL, the constructed pathname is as
74036ac495dSmrg      constructed by append_file_to_dir.  */
74136ac495dSmrg   char *(*construct) (const char *header, cpp_dir *dir);
74236ac495dSmrg 
74336ac495dSmrg   /* The C front end uses these to recognize duplicated
74436ac495dSmrg      directories in the search path.  */
74536ac495dSmrg   INO_T_CPP;
74636ac495dSmrg   dev_t dev;
74736ac495dSmrg };
74836ac495dSmrg 
749c0a68be4Smrg /* The kind of the cpp_macro.  */
750c0a68be4Smrg enum cpp_macro_kind {
751c0a68be4Smrg   cmk_macro,	/* An ISO macro (token expansion).  */
752c0a68be4Smrg   cmk_assert,   /* An assertion.  */
753c0a68be4Smrg   cmk_traditional	/* A traditional macro (text expansion).  */
754c0a68be4Smrg };
755c0a68be4Smrg 
756c0a68be4Smrg /* Each macro definition is recorded in a cpp_macro structure.
757c0a68be4Smrg    Variadic macros cannot occur with traditional cpp.  */
758c0a68be4Smrg struct GTY(()) cpp_macro {
759c0a68be4Smrg   union cpp_parm_u
760c0a68be4Smrg   {
761c0a68be4Smrg     /* Parameters, if any.  If parameter names use extended identifiers,
762c0a68be4Smrg        the original spelling of those identifiers, not the canonical
763c0a68be4Smrg        UTF-8 spelling, goes here.  */
764c0a68be4Smrg     cpp_hashnode ** GTY ((tag ("false"),
765c0a68be4Smrg 			  nested_ptr (union tree_node,
766c0a68be4Smrg 	"%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
767c0a68be4Smrg 	"%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL"),
768c0a68be4Smrg 			  length ("%1.paramc"))) params;
769c0a68be4Smrg 
770c0a68be4Smrg     /* If this is an assertion, the next one in the chain.  */
771c0a68be4Smrg     cpp_macro *GTY ((tag ("true"))) next;
772c0a68be4Smrg   } GTY ((desc ("%1.kind == cmk_assert"))) parm;
773c0a68be4Smrg 
774c0a68be4Smrg   /* Definition line number.  */
775c0a68be4Smrg   location_t line;
776c0a68be4Smrg 
777c0a68be4Smrg   /* Number of tokens in body, or bytes for traditional macros.  */
778c0a68be4Smrg   /* Do we really need 2^32-1 range here?  */
779c0a68be4Smrg   unsigned int count;
780c0a68be4Smrg 
781c0a68be4Smrg   /* Number of parameters.  */
782c0a68be4Smrg   unsigned short paramc;
783c0a68be4Smrg 
784c0a68be4Smrg   /* Non-zero if this is a user-lazy macro, value provided by user.  */
785c0a68be4Smrg   unsigned char lazy;
786c0a68be4Smrg 
787c0a68be4Smrg   /* The kind of this macro (ISO, trad or assert) */
788c0a68be4Smrg   unsigned kind : 2;
789c0a68be4Smrg 
790c0a68be4Smrg   /* If a function-like macro.  */
791c0a68be4Smrg   unsigned int fun_like : 1;
792c0a68be4Smrg 
793c0a68be4Smrg   /* If a variadic macro.  */
794c0a68be4Smrg   unsigned int variadic : 1;
795c0a68be4Smrg 
796c0a68be4Smrg   /* If macro defined in system header.  */
797c0a68be4Smrg   unsigned int syshdr   : 1;
798c0a68be4Smrg 
799c0a68be4Smrg   /* Nonzero if it has been expanded or had its existence tested.  */
800c0a68be4Smrg   unsigned int used     : 1;
801c0a68be4Smrg 
802c0a68be4Smrg   /* Indicate whether the tokens include extra CPP_PASTE tokens at the
803c0a68be4Smrg      end to track invalid redefinitions with consecutive CPP_PASTE
804c0a68be4Smrg      tokens.  */
805c0a68be4Smrg   unsigned int extra_tokens : 1;
806c0a68be4Smrg 
807c0a68be4Smrg   /* 1 bits spare (32-bit). 33 on 64-bit target.  */
808c0a68be4Smrg 
809c0a68be4Smrg   union cpp_exp_u
810c0a68be4Smrg   {
811c0a68be4Smrg     /* Trailing array of replacement tokens (ISO), or assertion body value.  */
812c0a68be4Smrg     cpp_token GTY ((tag ("false"), length ("%1.count"))) tokens[1];
813c0a68be4Smrg 
814c0a68be4Smrg     /* Pointer to replacement text (traditional).  See comment at top
815c0a68be4Smrg        of cpptrad.c for how traditional function-like macros are
816c0a68be4Smrg        encoded.  */
817c0a68be4Smrg     const unsigned char *GTY ((tag ("true"))) text;
818c0a68be4Smrg   } GTY ((desc ("%1.kind == cmk_traditional"))) exp;
819c0a68be4Smrg };
820c0a68be4Smrg 
821c0a68be4Smrg /* Poisoned identifiers are flagged NODE_POISONED.  NODE_OPERATOR (C++
822c0a68be4Smrg    only) indicates an identifier that behaves like an operator such as
823c0a68be4Smrg    "xor".  NODE_DIAGNOSTIC is for speed in lex_token: it indicates a
82436ac495dSmrg    diagnostic may be required for this node.  Currently this only
82536ac495dSmrg    applies to __VA_ARGS__, poisoned identifiers, and -Wc++-compat
82636ac495dSmrg    warnings about NODE_OPERATOR.  */
82736ac495dSmrg 
82836ac495dSmrg /* Hash node flags.  */
82936ac495dSmrg #define NODE_OPERATOR	(1 << 0)	/* C++ named operator.  */
83036ac495dSmrg #define NODE_POISONED	(1 << 1)	/* Poisoned identifier.  */
831c0a68be4Smrg #define NODE_DIAGNOSTIC (1 << 2)	/* Possible diagnostic when lexed.  */
832c0a68be4Smrg #define NODE_WARN	(1 << 3)	/* Warn if redefined or undefined.  */
833c0a68be4Smrg #define NODE_DISABLED	(1 << 4)	/* A disabled macro.  */
834c0a68be4Smrg #define NODE_USED	(1 << 5)	/* Dumped with -dU.  */
835c0a68be4Smrg #define NODE_CONDITIONAL (1 << 6)	/* Conditional macro */
836c0a68be4Smrg #define NODE_WARN_OPERATOR (1 << 7)	/* Warn about C++ named operator.  */
83736ac495dSmrg 
83836ac495dSmrg /* Different flavors of hash node.  */
83936ac495dSmrg enum node_type
84036ac495dSmrg {
841c0a68be4Smrg   NT_VOID = 0,	   /* Maybe an assert?  */
842c0a68be4Smrg   NT_MACRO_ARG,	   /* A macro arg.  */
843c0a68be4Smrg   NT_USER_MACRO,   /* A user macro.  */
844c0a68be4Smrg   NT_BUILTIN_MACRO, /* A builtin macro.  */
845c0a68be4Smrg   NT_MACRO_MASK = NT_USER_MACRO  /* Mask for either macro kind.  */
84636ac495dSmrg };
84736ac495dSmrg 
84836ac495dSmrg /* Different flavors of builtin macro.  _Pragma is an operator, but we
84936ac495dSmrg    handle it with the builtin code for efficiency reasons.  */
85036ac495dSmrg enum cpp_builtin_type
85136ac495dSmrg {
85236ac495dSmrg   BT_SPECLINE = 0,		/* `__LINE__' */
85336ac495dSmrg   BT_DATE,			/* `__DATE__' */
85436ac495dSmrg   BT_FILE,			/* `__FILE__' */
85536ac495dSmrg   BT_BASE_FILE,			/* `__BASE_FILE__' */
85636ac495dSmrg   BT_INCLUDE_LEVEL,		/* `__INCLUDE_LEVEL__' */
85736ac495dSmrg   BT_TIME,			/* `__TIME__' */
85836ac495dSmrg   BT_STDC,			/* `__STDC__' */
85936ac495dSmrg   BT_PRAGMA,			/* `_Pragma' operator */
86036ac495dSmrg   BT_TIMESTAMP,			/* `__TIMESTAMP__' */
86136ac495dSmrg   BT_COUNTER,			/* `__COUNTER__' */
862*8feb0f0bSmrg   BT_HAS_ATTRIBUTE,		/* `__has_attribute(x)' */
863*8feb0f0bSmrg   BT_HAS_BUILTIN,		/* `__has_builtin(x)' */
864*8feb0f0bSmrg   BT_HAS_INCLUDE,		/* `__has_include(x)' */
865*8feb0f0bSmrg   BT_HAS_INCLUDE_NEXT		/* `__has_include_next(x)' */
86636ac495dSmrg };
86736ac495dSmrg 
86836ac495dSmrg #define CPP_HASHNODE(HNODE)	((cpp_hashnode *) (HNODE))
869c0a68be4Smrg #define HT_NODE(NODE)		(&(NODE)->ident)
870c0a68be4Smrg #define NODE_LEN(NODE)		HT_LEN (HT_NODE (NODE))
871c0a68be4Smrg #define NODE_NAME(NODE)		HT_STR (HT_NODE (NODE))
87236ac495dSmrg 
87336ac495dSmrg /* The common part of an identifier node shared amongst all 3 C front
87436ac495dSmrg    ends.  Also used to store CPP identifiers, which are a superset of
87536ac495dSmrg    identifiers in the grammatical sense.  */
87636ac495dSmrg 
87736ac495dSmrg union GTY(()) _cpp_hashnode_value {
878c0a68be4Smrg   /* Assert (maybe NULL) */
879c0a68be4Smrg   cpp_macro * GTY((tag ("NT_VOID"))) answers;
880c0a68be4Smrg   /* Macro (never NULL) */
881c0a68be4Smrg   cpp_macro * GTY((tag ("NT_USER_MACRO"))) macro;
88236ac495dSmrg   /* Code for a builtin macro.  */
883c0a68be4Smrg   enum cpp_builtin_type GTY ((tag ("NT_BUILTIN_MACRO"))) builtin;
88436ac495dSmrg   /* Macro argument index.  */
885c0a68be4Smrg   unsigned short GTY ((tag ("NT_MACRO_ARG"))) arg_index;
88636ac495dSmrg };
88736ac495dSmrg 
88836ac495dSmrg struct GTY(()) cpp_hashnode {
88936ac495dSmrg   struct ht_identifier ident;
89036ac495dSmrg   unsigned int is_directive : 1;
89136ac495dSmrg   unsigned int directive_index : 7;	/* If is_directive,
89236ac495dSmrg 					   then index into directive table.
89336ac495dSmrg 					   Otherwise, a NODE_OPERATOR.  */
89436ac495dSmrg   unsigned char rid_code;		/* Rid code - for front ends.  */
895c0a68be4Smrg   ENUM_BITFIELD(node_type) type : 2;	/* CPP node type.  */
896c0a68be4Smrg   unsigned int flags : 8;		/* CPP flags.  */
89736ac495dSmrg 
898c0a68be4Smrg   /* 6 bits spare (plus another 32 on 64-bit hosts).  */
899c0a68be4Smrg 
900c0a68be4Smrg   union _cpp_hashnode_value GTY ((desc ("%1.type"))) value;
90136ac495dSmrg };
90236ac495dSmrg 
90336ac495dSmrg /* A class for iterating through the source locations within a
90436ac495dSmrg    string token (before escapes are interpreted, and before
90536ac495dSmrg    concatenation).  */
90636ac495dSmrg 
90736ac495dSmrg class cpp_string_location_reader {
90836ac495dSmrg  public:
909c0a68be4Smrg   cpp_string_location_reader (location_t src_loc,
91036ac495dSmrg 			      line_maps *line_table);
91136ac495dSmrg 
91236ac495dSmrg   source_range get_next ();
91336ac495dSmrg 
91436ac495dSmrg  private:
915c0a68be4Smrg   location_t m_loc;
91636ac495dSmrg   int m_offset_per_column;
91736ac495dSmrg };
91836ac495dSmrg 
91936ac495dSmrg /* A class for storing the source ranges of all of the characters within
92036ac495dSmrg    a string literal, after escapes are interpreted, and after
92136ac495dSmrg    concatenation.
92236ac495dSmrg 
92336ac495dSmrg    This is not GTY-marked, as instances are intended to be temporary.  */
92436ac495dSmrg 
92536ac495dSmrg class cpp_substring_ranges
92636ac495dSmrg {
92736ac495dSmrg  public:
92836ac495dSmrg   cpp_substring_ranges ();
92936ac495dSmrg   ~cpp_substring_ranges ();
93036ac495dSmrg 
get_num_ranges()93136ac495dSmrg   int get_num_ranges () const { return m_num_ranges; }
get_range(int idx)93236ac495dSmrg   source_range get_range (int idx) const
93336ac495dSmrg   {
93436ac495dSmrg     linemap_assert (idx < m_num_ranges);
93536ac495dSmrg     return m_ranges[idx];
93636ac495dSmrg   }
93736ac495dSmrg 
93836ac495dSmrg   void add_range (source_range range);
93936ac495dSmrg   void add_n_ranges (int num, cpp_string_location_reader &loc_reader);
94036ac495dSmrg 
94136ac495dSmrg  private:
94236ac495dSmrg   source_range *m_ranges;
94336ac495dSmrg   int m_num_ranges;
94436ac495dSmrg   int m_alloc_ranges;
94536ac495dSmrg };
94636ac495dSmrg 
94736ac495dSmrg /* Call this first to get a handle to pass to other functions.
94836ac495dSmrg 
94936ac495dSmrg    If you want cpplib to manage its own hashtable, pass in a NULL
95036ac495dSmrg    pointer.  Otherwise you should pass in an initialized hash table
95136ac495dSmrg    that cpplib will share; this technique is used by the C front
95236ac495dSmrg    ends.  */
95336ac495dSmrg extern cpp_reader *cpp_create_reader (enum c_lang, struct ht *,
954*8feb0f0bSmrg 				      class line_maps *);
95536ac495dSmrg 
95636ac495dSmrg /* Reset the cpp_reader's line_map.  This is only used after reading a
95736ac495dSmrg    PCH file.  */
958*8feb0f0bSmrg extern void cpp_set_line_map (cpp_reader *, class line_maps *);
95936ac495dSmrg 
96036ac495dSmrg /* Call this to change the selected language standard (e.g. because of
96136ac495dSmrg    command line options).  */
96236ac495dSmrg extern void cpp_set_lang (cpp_reader *, enum c_lang);
96336ac495dSmrg 
96436ac495dSmrg /* Set the include paths.  */
96536ac495dSmrg extern void cpp_set_include_chains (cpp_reader *, cpp_dir *, cpp_dir *, int);
96636ac495dSmrg 
96736ac495dSmrg /* Provide src:dst pair for __FILE__ remapping.  */
96836ac495dSmrg extern void add_cpp_remap_path (const char *);
96936ac495dSmrg 
97036ac495dSmrg /* Call these to get pointers to the options, callback, and deps
97136ac495dSmrg    structures for a given reader.  These pointers are good until you
97236ac495dSmrg    call cpp_finish on that reader.  You can either edit the callbacks
97336ac495dSmrg    through the pointer returned from cpp_get_callbacks, or set them
97436ac495dSmrg    with cpp_set_callbacks.  */
97536ac495dSmrg extern cpp_options *cpp_get_options (cpp_reader *);
97636ac495dSmrg extern cpp_callbacks *cpp_get_callbacks (cpp_reader *);
97736ac495dSmrg extern void cpp_set_callbacks (cpp_reader *, cpp_callbacks *);
978*8feb0f0bSmrg extern class mkdeps *cpp_get_deps (cpp_reader *);
97936ac495dSmrg 
98036ac495dSmrg /* This function reads the file, but does not start preprocessing.  It
98136ac495dSmrg    returns the name of the original file; this is the same as the
98236ac495dSmrg    input file, except for preprocessed input.  This will generate at
98336ac495dSmrg    least one file change callback, and possibly a line change callback
98436ac495dSmrg    too.  If there was an error opening the file, it returns NULL.  */
98536ac495dSmrg extern const char *cpp_read_main_file (cpp_reader *, const char *);
98636ac495dSmrg 
98736ac495dSmrg /* Set up built-ins with special behavior.  Use cpp_init_builtins()
98836ac495dSmrg    instead unless your know what you are doing.  */
98936ac495dSmrg extern void cpp_init_special_builtins (cpp_reader *);
99036ac495dSmrg 
99136ac495dSmrg /* Set up built-ins like __FILE__.  */
99236ac495dSmrg extern void cpp_init_builtins (cpp_reader *, int);
99336ac495dSmrg 
99436ac495dSmrg /* This is called after options have been parsed, and partially
99536ac495dSmrg    processed.  */
99636ac495dSmrg extern void cpp_post_options (cpp_reader *);
99736ac495dSmrg 
99836ac495dSmrg /* Set up translation to the target character set.  */
99936ac495dSmrg extern void cpp_init_iconv (cpp_reader *);
100036ac495dSmrg 
100136ac495dSmrg /* Call this to finish preprocessing.  If you requested dependency
100236ac495dSmrg    generation, pass an open stream to write the information to,
100336ac495dSmrg    otherwise NULL.  It is your responsibility to close the stream.  */
100436ac495dSmrg extern void cpp_finish (cpp_reader *, FILE *deps_stream);
100536ac495dSmrg 
100636ac495dSmrg /* Call this to release the handle at the end of preprocessing.  Any
100736ac495dSmrg    use of the handle after this function returns is invalid.  */
100836ac495dSmrg extern void cpp_destroy (cpp_reader *);
100936ac495dSmrg 
101036ac495dSmrg extern unsigned int cpp_token_len (const cpp_token *);
101136ac495dSmrg extern unsigned char *cpp_token_as_text (cpp_reader *, const cpp_token *);
101236ac495dSmrg extern unsigned char *cpp_spell_token (cpp_reader *, const cpp_token *,
101336ac495dSmrg 				       unsigned char *, bool);
101436ac495dSmrg extern void cpp_register_pragma (cpp_reader *, const char *, const char *,
101536ac495dSmrg 				 void (*) (cpp_reader *), bool);
101636ac495dSmrg extern void cpp_register_deferred_pragma (cpp_reader *, const char *,
101736ac495dSmrg 					  const char *, unsigned, bool, bool);
101836ac495dSmrg extern int cpp_avoid_paste (cpp_reader *, const cpp_token *,
101936ac495dSmrg 			    const cpp_token *);
102036ac495dSmrg extern const cpp_token *cpp_get_token (cpp_reader *);
102136ac495dSmrg extern const cpp_token *cpp_get_token_with_location (cpp_reader *,
1022c0a68be4Smrg 						     location_t *);
cpp_user_macro_p(const cpp_hashnode * node)1023c0a68be4Smrg inline bool cpp_user_macro_p (const cpp_hashnode *node)
1024c0a68be4Smrg {
1025c0a68be4Smrg   return node->type == NT_USER_MACRO;
1026c0a68be4Smrg }
cpp_builtin_macro_p(const cpp_hashnode * node)1027c0a68be4Smrg inline bool cpp_builtin_macro_p (const cpp_hashnode *node)
1028c0a68be4Smrg {
1029c0a68be4Smrg   return node->type == NT_BUILTIN_MACRO;
1030c0a68be4Smrg }
cpp_macro_p(const cpp_hashnode * node)1031c0a68be4Smrg inline bool cpp_macro_p (const cpp_hashnode *node)
1032c0a68be4Smrg {
1033c0a68be4Smrg   return node->type & NT_MACRO_MASK;
1034c0a68be4Smrg }
1035c0a68be4Smrg 
1036c0a68be4Smrg /* Returns true if NODE is a function-like user macro.  */
cpp_fun_like_macro_p(cpp_hashnode * node)1037c0a68be4Smrg inline bool cpp_fun_like_macro_p (cpp_hashnode *node)
1038c0a68be4Smrg {
1039c0a68be4Smrg   return cpp_user_macro_p (node) && node->value.macro->fun_like;
1040c0a68be4Smrg }
1041c0a68be4Smrg 
104236ac495dSmrg extern const unsigned char *cpp_macro_definition (cpp_reader *,
104336ac495dSmrg 						  cpp_hashnode *);
cpp_macro_definition_location(cpp_hashnode * node)1044c0a68be4Smrg inline location_t cpp_macro_definition_location (cpp_hashnode *node)
1045c0a68be4Smrg {
1046c0a68be4Smrg   return node->value.macro->line;
1047c0a68be4Smrg }
104836ac495dSmrg extern void _cpp_backup_tokens (cpp_reader *, unsigned int);
104936ac495dSmrg extern const cpp_token *cpp_peek_token (cpp_reader *, int);
105036ac495dSmrg 
105136ac495dSmrg /* Evaluate a CPP_*CHAR* token.  */
105236ac495dSmrg extern cppchar_t cpp_interpret_charconst (cpp_reader *, const cpp_token *,
105336ac495dSmrg 					  unsigned int *, int *);
105436ac495dSmrg /* Evaluate a vector of CPP_*STRING* tokens.  */
105536ac495dSmrg extern bool cpp_interpret_string (cpp_reader *,
105636ac495dSmrg 				  const cpp_string *, size_t,
105736ac495dSmrg 				  cpp_string *, enum cpp_ttype);
105836ac495dSmrg extern const char *cpp_interpret_string_ranges (cpp_reader *pfile,
105936ac495dSmrg 						const cpp_string *from,
106036ac495dSmrg 						cpp_string_location_reader *,
106136ac495dSmrg 						size_t count,
106236ac495dSmrg 						cpp_substring_ranges *out,
106336ac495dSmrg 						enum cpp_ttype type);
106436ac495dSmrg extern bool cpp_interpret_string_notranslate (cpp_reader *,
106536ac495dSmrg 					      const cpp_string *, size_t,
106636ac495dSmrg 					      cpp_string *, enum cpp_ttype);
106736ac495dSmrg 
106836ac495dSmrg /* Convert a host character constant to the execution character set.  */
106936ac495dSmrg extern cppchar_t cpp_host_to_exec_charset (cpp_reader *, cppchar_t);
107036ac495dSmrg 
107136ac495dSmrg /* Used to register macros and assertions, perhaps from the command line.
107236ac495dSmrg    The text is the same as the command line argument.  */
107336ac495dSmrg extern void cpp_define (cpp_reader *, const char *);
107436ac495dSmrg extern void cpp_define_formatted (cpp_reader *pfile,
107536ac495dSmrg 				  const char *fmt, ...) ATTRIBUTE_PRINTF_2;
107636ac495dSmrg extern void cpp_assert (cpp_reader *, const char *);
107736ac495dSmrg extern void cpp_undef (cpp_reader *, const char *);
107836ac495dSmrg extern void cpp_unassert (cpp_reader *, const char *);
107936ac495dSmrg 
1080c0a68be4Smrg /* Mark a node as a lazily defined macro.  */
1081c0a68be4Smrg extern void cpp_define_lazily (cpp_reader *, cpp_hashnode *node, unsigned N);
1082c0a68be4Smrg 
108336ac495dSmrg /* Undefine all macros and assertions.  */
108436ac495dSmrg extern void cpp_undef_all (cpp_reader *);
108536ac495dSmrg 
108636ac495dSmrg extern cpp_buffer *cpp_push_buffer (cpp_reader *, const unsigned char *,
108736ac495dSmrg 				    size_t, int);
108836ac495dSmrg extern int cpp_defined (cpp_reader *, const unsigned char *, int);
108936ac495dSmrg 
109036ac495dSmrg /* A preprocessing number.  Code assumes that any unused high bits of
109136ac495dSmrg    the double integer are set to zero.  */
109236ac495dSmrg 
109336ac495dSmrg /* This type has to be equal to unsigned HOST_WIDE_INT, see
109436ac495dSmrg    gcc/c-family/c-lex.c.  */
109536ac495dSmrg typedef uint64_t cpp_num_part;
109636ac495dSmrg typedef struct cpp_num cpp_num;
109736ac495dSmrg struct cpp_num
109836ac495dSmrg {
109936ac495dSmrg   cpp_num_part high;
110036ac495dSmrg   cpp_num_part low;
110136ac495dSmrg   bool unsignedp;  /* True if value should be treated as unsigned.  */
110236ac495dSmrg   bool overflow;   /* True if the most recent calculation overflowed.  */
110336ac495dSmrg };
110436ac495dSmrg 
110536ac495dSmrg /* cpplib provides two interfaces for interpretation of preprocessing
110636ac495dSmrg    numbers.
110736ac495dSmrg 
110836ac495dSmrg    cpp_classify_number categorizes numeric constants according to
110936ac495dSmrg    their field (integer, floating point, or invalid), radix (decimal,
111036ac495dSmrg    octal, hexadecimal), and type suffixes.  */
111136ac495dSmrg 
111236ac495dSmrg #define CPP_N_CATEGORY  0x000F
111336ac495dSmrg #define CPP_N_INVALID	0x0000
111436ac495dSmrg #define CPP_N_INTEGER	0x0001
111536ac495dSmrg #define CPP_N_FLOATING	0x0002
111636ac495dSmrg 
111736ac495dSmrg #define CPP_N_WIDTH	0x00F0
111836ac495dSmrg #define CPP_N_SMALL	0x0010	/* int, float, short _Fract/Accum  */
111936ac495dSmrg #define CPP_N_MEDIUM	0x0020	/* long, double, long _Fract/_Accum.  */
112036ac495dSmrg #define CPP_N_LARGE	0x0040	/* long long, long double,
112136ac495dSmrg 				   long long _Fract/Accum.  */
112236ac495dSmrg 
112336ac495dSmrg #define CPP_N_WIDTH_MD	0xF0000	/* machine defined.  */
112436ac495dSmrg #define CPP_N_MD_W	0x10000
112536ac495dSmrg #define CPP_N_MD_Q	0x20000
112636ac495dSmrg 
112736ac495dSmrg #define CPP_N_RADIX	0x0F00
112836ac495dSmrg #define CPP_N_DECIMAL	0x0100
112936ac495dSmrg #define CPP_N_HEX	0x0200
113036ac495dSmrg #define CPP_N_OCTAL	0x0400
113136ac495dSmrg #define CPP_N_BINARY	0x0800
113236ac495dSmrg 
113336ac495dSmrg #define CPP_N_UNSIGNED	0x1000	/* Properties.  */
113436ac495dSmrg #define CPP_N_IMAGINARY	0x2000
113536ac495dSmrg #define CPP_N_DFLOAT	0x4000
113636ac495dSmrg #define CPP_N_DEFAULT	0x8000
113736ac495dSmrg 
113836ac495dSmrg #define CPP_N_FRACT	0x100000 /* Fract types.  */
113936ac495dSmrg #define CPP_N_ACCUM	0x200000 /* Accum types.  */
114036ac495dSmrg #define CPP_N_FLOATN	0x400000 /* _FloatN types.  */
114136ac495dSmrg #define CPP_N_FLOATNX	0x800000 /* _FloatNx types.  */
114236ac495dSmrg 
114336ac495dSmrg #define CPP_N_USERDEF	0x1000000 /* C++0x user-defined literal.  */
114436ac495dSmrg 
114536ac495dSmrg #define CPP_N_WIDTH_FLOATN_NX	0xF0000000 /* _FloatN / _FloatNx value
114636ac495dSmrg 					      of N, divided by 16.  */
114736ac495dSmrg #define CPP_FLOATN_SHIFT	24
114836ac495dSmrg #define CPP_FLOATN_MAX	0xF0
114936ac495dSmrg 
115036ac495dSmrg /* Classify a CPP_NUMBER token.  The return value is a combination of
115136ac495dSmrg    the flags from the above sets.  */
115236ac495dSmrg extern unsigned cpp_classify_number (cpp_reader *, const cpp_token *,
1153c0a68be4Smrg 				     const char **, location_t);
115436ac495dSmrg 
115536ac495dSmrg /* Return the classification flags for a float suffix.  */
115636ac495dSmrg extern unsigned int cpp_interpret_float_suffix (cpp_reader *, const char *,
115736ac495dSmrg 						size_t);
115836ac495dSmrg 
115936ac495dSmrg /* Return the classification flags for an int suffix.  */
116036ac495dSmrg extern unsigned int cpp_interpret_int_suffix (cpp_reader *, const char *,
116136ac495dSmrg 					      size_t);
116236ac495dSmrg 
116336ac495dSmrg /* Evaluate a token classified as category CPP_N_INTEGER.  */
116436ac495dSmrg extern cpp_num cpp_interpret_integer (cpp_reader *, const cpp_token *,
116536ac495dSmrg 				      unsigned int);
116636ac495dSmrg 
116736ac495dSmrg /* Sign extend a number, with PRECISION significant bits and all
116836ac495dSmrg    others assumed clear, to fill out a cpp_num structure.  */
116936ac495dSmrg cpp_num cpp_num_sign_extend (cpp_num, size_t);
117036ac495dSmrg 
117136ac495dSmrg /* Output a diagnostic of some kind.  */
1172c0a68be4Smrg extern bool cpp_error (cpp_reader *, enum cpp_diagnostic_level,
1173c0a68be4Smrg 		       const char *msgid, ...)
117436ac495dSmrg   ATTRIBUTE_PRINTF_3;
1175c0a68be4Smrg extern bool cpp_warning (cpp_reader *, enum cpp_warning_reason,
1176c0a68be4Smrg 			 const char *msgid, ...)
117736ac495dSmrg   ATTRIBUTE_PRINTF_3;
1178c0a68be4Smrg extern bool cpp_pedwarning (cpp_reader *, enum cpp_warning_reason,
1179c0a68be4Smrg 			    const char *msgid, ...)
118036ac495dSmrg   ATTRIBUTE_PRINTF_3;
1181c0a68be4Smrg extern bool cpp_warning_syshdr (cpp_reader *, enum cpp_warning_reason reason,
1182c0a68be4Smrg 				const char *msgid, ...)
118336ac495dSmrg   ATTRIBUTE_PRINTF_3;
118436ac495dSmrg 
118536ac495dSmrg /* Output a diagnostic with "MSGID: " preceding the
118636ac495dSmrg    error string of errno.  No location is printed.  */
1187c0a68be4Smrg extern bool cpp_errno (cpp_reader *, enum cpp_diagnostic_level,
1188c0a68be4Smrg 		       const char *msgid);
118936ac495dSmrg /* Similarly, but with "FILENAME: " instead of "MSGID: ", where
119036ac495dSmrg    the filename is not localized.  */
1191c0a68be4Smrg extern bool cpp_errno_filename (cpp_reader *, enum cpp_diagnostic_level,
1192c0a68be4Smrg 				const char *filename, location_t loc);
119336ac495dSmrg 
119436ac495dSmrg /* Same as cpp_error, except additionally specifies a position as a
119536ac495dSmrg    (translation unit) physical line and physical column.  If the line is
119636ac495dSmrg    zero, then no location is printed.  */
1197c0a68be4Smrg extern bool cpp_error_with_line (cpp_reader *, enum cpp_diagnostic_level,
1198c0a68be4Smrg 				 location_t, unsigned,
1199c0a68be4Smrg 				 const char *msgid, ...)
120036ac495dSmrg   ATTRIBUTE_PRINTF_5;
1201c0a68be4Smrg extern bool cpp_warning_with_line (cpp_reader *, enum cpp_warning_reason,
1202c0a68be4Smrg 				   location_t, unsigned,
1203c0a68be4Smrg 				   const char *msgid, ...)
120436ac495dSmrg   ATTRIBUTE_PRINTF_5;
1205c0a68be4Smrg extern bool cpp_pedwarning_with_line (cpp_reader *, enum cpp_warning_reason,
1206c0a68be4Smrg 				      location_t, unsigned,
1207c0a68be4Smrg 				      const char *msgid, ...)
120836ac495dSmrg   ATTRIBUTE_PRINTF_5;
1209c0a68be4Smrg extern bool cpp_warning_with_line_syshdr (cpp_reader *, enum cpp_warning_reason,
1210c0a68be4Smrg 					  location_t, unsigned,
1211c0a68be4Smrg 					  const char *msgid, ...)
121236ac495dSmrg   ATTRIBUTE_PRINTF_5;
121336ac495dSmrg 
1214c0a68be4Smrg extern bool cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level,
1215c0a68be4Smrg 			  location_t src_loc, const char *msgid, ...)
121636ac495dSmrg   ATTRIBUTE_PRINTF_4;
121736ac495dSmrg 
1218c0a68be4Smrg extern bool cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level,
1219c0a68be4Smrg 			  rich_location *richloc, const char *msgid, ...)
122036ac495dSmrg   ATTRIBUTE_PRINTF_4;
122136ac495dSmrg 
122236ac495dSmrg /* In lex.c */
122336ac495dSmrg extern int cpp_ideq (const cpp_token *, const char *);
122436ac495dSmrg extern void cpp_output_line (cpp_reader *, FILE *);
122536ac495dSmrg extern unsigned char *cpp_output_line_to_string (cpp_reader *,
122636ac495dSmrg 						 const unsigned char *);
122736ac495dSmrg extern void cpp_output_token (const cpp_token *, FILE *);
122836ac495dSmrg extern const char *cpp_type2name (enum cpp_ttype, unsigned char flags);
122936ac495dSmrg /* Returns the value of an escape sequence, truncated to the correct
123036ac495dSmrg    target precision.  PSTR points to the input pointer, which is just
123136ac495dSmrg    after the backslash.  LIMIT is how much text we have.  WIDE is true
123236ac495dSmrg    if the escape sequence is part of a wide character constant or
123336ac495dSmrg    string literal.  Handles all relevant diagnostics.  */
123436ac495dSmrg extern cppchar_t cpp_parse_escape (cpp_reader *, const unsigned char ** pstr,
123536ac495dSmrg 				   const unsigned char *limit, int wide);
123636ac495dSmrg 
123736ac495dSmrg /* Structure used to hold a comment block at a given location in the
123836ac495dSmrg    source code.  */
123936ac495dSmrg 
124036ac495dSmrg typedef struct
124136ac495dSmrg {
124236ac495dSmrg   /* Text of the comment including the terminators.  */
124336ac495dSmrg   char *comment;
124436ac495dSmrg 
124536ac495dSmrg   /* source location for the given comment.  */
1246c0a68be4Smrg   location_t sloc;
124736ac495dSmrg } cpp_comment;
124836ac495dSmrg 
124936ac495dSmrg /* Structure holding all comments for a given cpp_reader.  */
125036ac495dSmrg 
125136ac495dSmrg typedef struct
125236ac495dSmrg {
125336ac495dSmrg   /* table of comment entries.  */
125436ac495dSmrg   cpp_comment *entries;
125536ac495dSmrg 
125636ac495dSmrg   /* number of actual entries entered in the table.  */
125736ac495dSmrg   int count;
125836ac495dSmrg 
125936ac495dSmrg   /* number of entries allocated currently.  */
126036ac495dSmrg   int allocated;
126136ac495dSmrg } cpp_comment_table;
126236ac495dSmrg 
126336ac495dSmrg /* Returns the table of comments encountered by the preprocessor. This
126436ac495dSmrg    table is only populated when pfile->state.save_comments is true. */
126536ac495dSmrg extern cpp_comment_table *cpp_get_comments (cpp_reader *);
126636ac495dSmrg 
126736ac495dSmrg /* In hash.c */
126836ac495dSmrg 
126936ac495dSmrg /* Lookup an identifier in the hashtable.  Puts the identifier in the
127036ac495dSmrg    table if it is not already there.  */
127136ac495dSmrg extern cpp_hashnode *cpp_lookup (cpp_reader *, const unsigned char *,
127236ac495dSmrg 				 unsigned int);
127336ac495dSmrg 
127436ac495dSmrg typedef int (*cpp_cb) (cpp_reader *, cpp_hashnode *, void *);
127536ac495dSmrg extern void cpp_forall_identifiers (cpp_reader *, cpp_cb, void *);
127636ac495dSmrg 
127736ac495dSmrg /* In macro.c */
127836ac495dSmrg extern void cpp_scan_nooutput (cpp_reader *);
127936ac495dSmrg extern int  cpp_sys_macro_p (cpp_reader *);
128036ac495dSmrg extern unsigned char *cpp_quote_string (unsigned char *, const unsigned char *,
128136ac495dSmrg 					unsigned int);
128236ac495dSmrg 
128336ac495dSmrg /* In files.c */
128436ac495dSmrg extern bool cpp_included (cpp_reader *, const char *);
1285c0a68be4Smrg extern bool cpp_included_before (cpp_reader *, const char *, location_t);
128636ac495dSmrg extern void cpp_make_system_header (cpp_reader *, int, int);
128736ac495dSmrg extern bool cpp_push_include (cpp_reader *, const char *);
128836ac495dSmrg extern bool cpp_push_default_include (cpp_reader *, const char *);
128936ac495dSmrg extern void cpp_change_file (cpp_reader *, enum lc_reason, const char *);
129036ac495dSmrg extern const char *cpp_get_path (struct _cpp_file *);
129136ac495dSmrg extern cpp_dir *cpp_get_dir (struct _cpp_file *);
129236ac495dSmrg extern cpp_buffer *cpp_get_buffer (cpp_reader *);
129336ac495dSmrg extern struct _cpp_file *cpp_get_file (cpp_buffer *);
129436ac495dSmrg extern cpp_buffer *cpp_get_prev (cpp_buffer *);
129536ac495dSmrg extern void cpp_clear_file_cache (cpp_reader *);
129636ac495dSmrg 
129736ac495dSmrg /* In pch.c */
129836ac495dSmrg struct save_macro_data;
129936ac495dSmrg extern int cpp_save_state (cpp_reader *, FILE *);
130036ac495dSmrg extern int cpp_write_pch_deps (cpp_reader *, FILE *);
130136ac495dSmrg extern int cpp_write_pch_state (cpp_reader *, FILE *);
130236ac495dSmrg extern int cpp_valid_state (cpp_reader *, const char *, int);
130336ac495dSmrg extern void cpp_prepare_state (cpp_reader *, struct save_macro_data **);
130436ac495dSmrg extern int cpp_read_state (cpp_reader *, const char *, FILE *,
130536ac495dSmrg 			   struct save_macro_data *);
130636ac495dSmrg 
130736ac495dSmrg /* In lex.c */
1308c0a68be4Smrg extern void cpp_force_token_locations (cpp_reader *, location_t);
130936ac495dSmrg extern void cpp_stop_forcing_token_locations (cpp_reader *);
131036ac495dSmrg 
131136ac495dSmrg /* In expr.c */
131236ac495dSmrg extern enum cpp_ttype cpp_userdef_string_remove_type
131336ac495dSmrg   (enum cpp_ttype type);
131436ac495dSmrg extern enum cpp_ttype cpp_userdef_string_add_type
131536ac495dSmrg   (enum cpp_ttype type);
131636ac495dSmrg extern enum cpp_ttype cpp_userdef_char_remove_type
131736ac495dSmrg   (enum cpp_ttype type);
131836ac495dSmrg extern enum cpp_ttype cpp_userdef_char_add_type
131936ac495dSmrg   (enum cpp_ttype type);
132036ac495dSmrg extern bool cpp_userdef_string_p
132136ac495dSmrg   (enum cpp_ttype type);
132236ac495dSmrg extern bool cpp_userdef_char_p
132336ac495dSmrg   (enum cpp_ttype type);
132436ac495dSmrg extern const char * cpp_get_userdef_suffix
132536ac495dSmrg   (const cpp_token *);
132636ac495dSmrg 
1327*8feb0f0bSmrg /* In charset.c */
1328*8feb0f0bSmrg int cpp_byte_column_to_display_column (const char *data, int data_length,
1329*8feb0f0bSmrg 				       int column);
cpp_display_width(const char * data,int data_length)1330*8feb0f0bSmrg inline int cpp_display_width (const char *data, int data_length)
1331*8feb0f0bSmrg {
1332*8feb0f0bSmrg     return cpp_byte_column_to_display_column (data, data_length, data_length);
1333*8feb0f0bSmrg }
1334*8feb0f0bSmrg int cpp_display_column_to_byte_column (const char *data, int data_length,
1335*8feb0f0bSmrg 				       int display_col);
1336*8feb0f0bSmrg int cpp_wcwidth (cppchar_t c);
1337*8feb0f0bSmrg 
133836ac495dSmrg #endif /* ! LIBCPP_CPPLIB_H */
1339