]> gcc.gnu.org Git - gcc.git/blame - gcc/cpphash.h
typeck.c (build_prim_array_type): Correctly set the high word too.
[gcc.git] / gcc / cpphash.h
CommitLineData
88ae23e7
ZW
1/* Part of CPP library.
2 Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4283012f
JL
3
4This program is free software; you can redistribute it and/or modify it
5under the terms of the GNU General Public License as published by the
6Free Software Foundation; either version 2, or (at your option) any
7later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
42b17236 16Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
4283012f 17
88ae23e7
ZW
18/* This header defines all the internal data structures and functions
19 that need to be visible across files. It's called cpphash.h for
20 historical reasons. */
21
bb52fa7f
ZW
22#ifndef __GCC_CPPHASH__
23#define __GCC_CPPHASH__
24
88ae23e7
ZW
25typedef unsigned char U_CHAR;
26
bb52fa7f
ZW
27/* Structure allocated for every #define. For a simple replacement
28 such as
29 #define foo bar ,
30 nargs = -1, the `pattern' list is null, and the expansion is just
31 the replacement text. Nargs = 0 means a functionlike macro with no args,
32 e.g.,
33 #define getchar() getc (stdin) .
34 When there are args, the expansion is the replacement text with the
35 args squashed out, and the reflist is a list describing how to
36 build the output from the input: e.g., "3 chars, then the 1st arg,
37 then 9 chars, then the 3rd arg, then 0 chars, then the 2nd arg".
38 The chars here come from the expansion. Whatever is left of the
39 expansion after the last arg-occurrence is copied after that arg.
40 Note that the reflist can be arbitrarily long---
41 its length depends on the number of times the arguments appear in
42 the replacement text, not how many args there are. Example:
43 #define f(x) x+x+x+x+x+x+x would have replacement text "++++++" and
44 pattern list
45 { (0, 1), (1, 1), (1, 1), ..., (1, 1), NULL }
46 where (x, y) means (nchars, argno). */
47
ba412f14
ZW
48struct reflist
49{
50 struct reflist *next;
51 char stringify; /* nonzero if this arg was preceded by a
52 # operator. */
53 char raw_before; /* Nonzero if a ## operator before arg. */
54 char raw_after; /* Nonzero if a ## operator after arg. */
55 char rest_args; /* Nonzero if this arg. absorbs the rest */
56 int nchars; /* Number of literal chars to copy before
57 this arg occurrence. */
58 int argno; /* Number of arg to substitute (origin-0) */
59};
60
bb52fa7f 61typedef struct definition DEFINITION;
ba412f14
ZW
62struct definition
63{
bb52fa7f
ZW
64 int nargs;
65 int length; /* length of expansion string */
ba412f14 66 U_CHAR *expansion;
bb52fa7f 67 int line; /* Line number of definition */
ba412f14 68 int col;
bb52fa7f
ZW
69 const char *file; /* File of definition */
70 char rest_args; /* Nonzero if last arg. absorbs the rest */
ba412f14
ZW
71 struct reflist *pattern;
72
38b24ee2 73 /* Names of macro args, concatenated in order with \0 between
ba412f14
ZW
74 them. The only use of this is that we warn on redefinition if
75 this differs between the old and new definitions. */
76 U_CHAR *argnames;
bb52fa7f
ZW
77};
78
88ae23e7
ZW
79/* The structure of a node in the hash table. The hash table
80 has entries for all tokens defined by #define commands (type T_MACRO),
81 plus some special tokens like __LINE__ (these each have their own
82 type, and the appropriate code is run when that type of node is seen.
83 It does not contain control words like "#define", which are recognized
84 by a separate piece of code. */
85
86/* different flavors of hash nodes --- also used in keyword table */
87enum node_type
88{
89 T_DEFINE = 1, /* `#define' */
90 T_INCLUDE, /* `#include' */
91 T_INCLUDE_NEXT, /* `#include_next' */
92 T_IMPORT, /* `#import' */
93 T_IFDEF, /* `#ifdef' */
94 T_IFNDEF, /* `#ifndef' */
95 T_IF, /* `#if' */
96 T_ELSE, /* `#else' */
97 T_PRAGMA, /* `#pragma' */
98 T_ELIF, /* `#elif' */
99 T_UNDEF, /* `#undef' */
100 T_LINE, /* `#line' */
101 T_ERROR, /* `#error' */
102 T_WARNING, /* `#warning' */
103 T_ENDIF, /* `#endif' */
104 T_SCCS, /* `#sccs' */
105 T_IDENT, /* `#ident' */
106 T_ASSERT, /* `#assert' */
107 T_UNASSERT, /* `#unassert', */
108 T_SPECLINE, /* `__LINE__' */
109 T_DATE, /* `__DATE__' */
110 T_FILE, /* `__FILE__' */
111 T_BASE_FILE, /* `__BASE_FILE__' */
112 T_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */
113 T_VERSION, /* `__VERSION__' */
114 T_TIME, /* `__TIME__' */
115 T_STDC, /* `__STDC__' */
116 T_CONST, /* Constant string, used by `__SIZE_TYPE__' etc */
117 T_MACRO, /* macro defined by `#define' */
118 T_DISABLED, /* macro temporarily turned off for rescan */
119 T_POISON, /* macro defined with `#pragma poison' */
120 T_UNUSED /* Used for something not defined. */
121};
122
7f2935c7 123/* different kinds of things that can appear in the value field
5dfa4da1
ZW
124 of a hash node. */
125union hashval
126{
127 const char *cpval; /* some predefined macros */
128 DEFINITION *defn; /* #define */
129 struct hashnode *aschain; /* #assert */
7f2935c7
PB
130};
131
cf4ed945 132typedef struct hashnode HASHNODE;
88ae23e7
ZW
133struct hashnode
134{
d35364d1
ZW
135 const U_CHAR *name; /* the actual name */
136 size_t length; /* length of token, for quick comparison */
137 unsigned long hash; /* cached hash value */
7f2935c7 138 union hashval value; /* pointer to expansion, or whatever */
d35364d1 139 enum node_type type; /* type of special token */
7f2935c7
PB
140};
141
88ae23e7
ZW
142/* List of directories to look for include files in. */
143struct file_name_list
144{
145 struct file_name_list *next;
146 struct file_name_list *alloc; /* for the cache of
147 current directory entries */
148 char *name;
149 unsigned int nlen;
150 /* We use these to tell if the directory mentioned here is a duplicate
151 of an earlier directory on the search path. */
152 ino_t ino;
153 dev_t dev;
154 /* If the following is nonzero, it is a C-language system include
155 directory. */
156 int sysp;
157 /* Mapping of file names for this directory.
158 Only used on MS-DOS and related platforms. */
159 struct file_name_map *name_map;
160};
161#define ABSOLUTE_PATH ((struct file_name_list *)-1)
162
163/* This structure is used for the table of all includes. It is
164 indexed by the `short name' (the name as it appeared in the
165 #include statement) which is stored in *nshort. */
166struct ihash
167{
88ae23e7
ZW
168 /* Next file with the same short name but a
169 different (partial) pathname). */
170 struct ihash *next_this_file;
171
172 /* Location of the file in the include search path.
173 Used for include_next */
174 struct file_name_list *foundhere;
d35364d1
ZW
175
176 unsigned long hash; /* save hash value for future reference */
177 const char *nshort; /* name of file as referenced in #include;
178 points into name[] */
88ae23e7
ZW
179 const U_CHAR *control_macro; /* macro, if any, preventing reinclusion -
180 see redundant_include_p */
d35364d1 181 const char name[1]; /* (partial) pathname of file */
88ae23e7
ZW
182};
183typedef struct ihash IHASH;
184
185/* Character classes.
186 If the definition of `numchar' looks odd to you, please look up the
187 definition of a pp-number in the C standard [section 6.4.8 of C99] */
188#define ISidnum 0x01 /* a-zA-Z0-9_ */
189#define ISidstart 0x02 /* _a-zA-Z */
190#define ISnumstart 0x04 /* 0-9 */
191#define IShspace 0x08 /* ' ' \t \f \v */
192#define ISspace 0x10 /* ' ' \t \f \v \n */
193
194#define _dollar_ok(x) ((x) == '$' && CPP_OPTIONS (pfile)->dollars_in_ident)
195
196#define is_idchar(x) ((_cpp_IStable[x] & ISidnum) || _dollar_ok(x))
197#define is_idstart(x) ((_cpp_IStable[x] & ISidstart) || _dollar_ok(x))
198#define is_numchar(x) (_cpp_IStable[x] & ISidnum)
199#define is_numstart(x) (_cpp_IStable[x] & ISnumstart)
200#define is_hspace(x) (_cpp_IStable[x] & IShspace)
201#define is_space(x) (_cpp_IStable[x] & ISspace)
202
203/* This table is constant if it can be initialized at compile time,
204 which is the case if cpp was compiled with GCC >=2.7, or another
205 compiler that supports C99. */
206#if (GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L)
207extern const unsigned char _cpp_IStable[256];
208#else
209extern unsigned char _cpp_IStable[256];
210#endif
211
212/* Macros. */
213
214#define CPP_BUF_PEEK(BUFFER) \
215 ((BUFFER)->cur < (BUFFER)->rlimit ? *(BUFFER)->cur : EOF)
216#define CPP_BUF_GET(BUFFER) \
217 ((BUFFER)->cur < (BUFFER)->rlimit ? *(BUFFER)->cur++ : EOF)
218#define CPP_FORWARD(BUFFER, N) ((BUFFER)->cur += (N))
219
220/* Append string STR (of length N) to PFILE's output buffer.
221 Assume there is enough space. */
222#define CPP_PUTS_Q(PFILE, STR, N) \
223 (memcpy ((PFILE)->limit, STR, (N)), (PFILE)->limit += (N))
224/* Append string STR (of length N) to PFILE's output buffer. Make space. */
225#define CPP_PUTS(PFILE, STR, N) CPP_RESERVE(PFILE, N), CPP_PUTS_Q(PFILE, STR,N)
226/* Append character CH to PFILE's output buffer. Assume sufficient space. */
227#define CPP_PUTC_Q(PFILE, CH) (*(PFILE)->limit++ = (CH))
228/* Append character CH to PFILE's output buffer. Make space if need be. */
229#define CPP_PUTC(PFILE, CH) (CPP_RESERVE (PFILE, 1), CPP_PUTC_Q (PFILE, CH))
230/* Make sure PFILE->limit is followed by '\0'. */
231#define CPP_NUL_TERMINATE_Q(PFILE) (*(PFILE)->limit = 0)
232#define CPP_NUL_TERMINATE(PFILE) (CPP_RESERVE(PFILE, 1), *(PFILE)->limit = 0)
233
234/* Advance the current line by one. */
235#define CPP_BUMP_BUFFER_LINE(PBUF) ((PBUF)->lineno++,\
236 (PBUF)->line_base = (PBUF)->cur)
237#define CPP_BUMP_LINE(PFILE) CPP_BUMP_BUFFER_LINE(CPP_BUFFER(PFILE))
238#define CPP_PREV_BUFFER(BUFFER) ((BUFFER)->prev)
239
240#define CPP_PRINT_DEPS(PFILE) (CPP_OPTIONS (PFILE)->print_deps)
241#define CPP_TRADITIONAL(PFILE) (CPP_OPTIONS(PFILE)->traditional)
242#define CPP_PEDANTIC(PFILE) \
243 (CPP_OPTIONS (PFILE)->pedantic && !CPP_BUFFER (pfile)->system_header_p)
244
245/* In cpphash.c */
d35364d1
ZW
246extern HASHNODE *_cpp_make_hashnode PARAMS ((const U_CHAR *, size_t,
247 enum node_type,
248 unsigned long));
249extern HASHNODE *_cpp_lookup PARAMS ((cpp_reader *,
250 const U_CHAR *, int));
251extern HASHNODE **_cpp_lookup_slot PARAMS ((cpp_reader *,
252 const U_CHAR *, int, int,
253 unsigned long *));
254extern void _cpp_free_definition PARAMS ((DEFINITION *));
255extern DEFINITION *_cpp_create_definition PARAMS ((cpp_reader *, int));
256extern void _cpp_dump_definition PARAMS ((cpp_reader *, const U_CHAR *,
257 long, DEFINITION *));
258extern int _cpp_compare_defs PARAMS ((cpp_reader *, DEFINITION *,
259 DEFINITION *));
260extern void _cpp_macroexpand PARAMS ((cpp_reader *, HASHNODE *));
261extern void _cpp_init_macro_hash PARAMS ((cpp_reader *));
262extern void _cpp_dump_macro_hash PARAMS ((cpp_reader *));
bb52fa7f 263
88ae23e7
ZW
264/* In cppfiles.c */
265extern void _cpp_simplify_pathname PARAMS ((char *));
266extern int _cpp_find_include_file PARAMS ((cpp_reader *, const char *,
267 struct file_name_list *,
268 IHASH **, int *));
269extern int _cpp_read_include_file PARAMS ((cpp_reader *, int, IHASH *));
d35364d1 270extern void _cpp_init_include_hash PARAMS ((cpp_reader *));
88ae23e7
ZW
271
272/* In cppexp.c */
273extern int _cpp_parse_expr PARAMS ((cpp_reader *));
274
bb52fa7f 275#endif
This page took 0.526723 seconds and 5 git commands to generate.