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