]>
Commit | Line | Data |
---|---|---|
8d08fdba | 1 | /* Separate lexical analyzer for GNU C++. |
956d6950 | 2 | Copyright (C) 1987, 89, 92-96, 1997 Free Software Foundation, Inc. |
8d08fdba MS |
3 | Hacked by Michael Tiemann (tiemann@cygnus.com) |
4 | ||
5 | This file is part of GNU CC. | |
6 | ||
7 | GNU CC is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | GNU CC is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GNU CC; see the file COPYING. If not, write to | |
e9fa0c7c RK |
19 | the Free Software Foundation, 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. */ | |
8d08fdba MS |
21 | |
22 | ||
23 | /* This file is the lexical analyzer for GNU C++. */ | |
24 | ||
8926095f | 25 | /* Cause the `yydebug' variable to be defined. */ |
8d08fdba | 26 | #define YYDEBUG 1 |
8d08fdba | 27 | |
da20811c | 28 | #include "config.h" |
8d08fdba MS |
29 | #include <sys/types.h> |
30 | #include <stdio.h> | |
31 | #include <errno.h> | |
32 | #include <setjmp.h> | |
8d08fdba MS |
33 | #include "input.h" |
34 | #include "tree.h" | |
35 | #include "lex.h" | |
8d08fdba | 36 | #include "cp-tree.h" |
46b02c6d | 37 | #include "parse.h" |
8d08fdba MS |
38 | #include "flags.h" |
39 | #include "obstack.h" | |
3d6f7931 | 40 | #include "c-pragma.h" |
8d08fdba | 41 | |
30c317f5 DE |
42 | /* MULTIBYTE_CHARS support only works for native compilers. |
43 | ??? Ideally what we want is to model widechar support after | |
44 | the current floating point support. */ | |
45 | #ifdef CROSS_COMPILE | |
46 | #undef MULTIBYTE_CHARS | |
47 | #endif | |
48 | ||
8d08fdba MS |
49 | #ifdef MULTIBYTE_CHARS |
50 | #include <stdlib.h> | |
51 | #include <locale.h> | |
52 | #endif | |
53 | ||
49c249e1 JM |
54 | #ifdef HAVE_STDLIB_H |
55 | #ifndef MULTIBYTE_CHARS | |
56 | #include <stdlib.h> | |
57 | #endif | |
58 | #else | |
59 | extern double atof (); | |
60 | #endif | |
61 | ||
62 | #ifdef HAVE_STRING_H | |
63 | #include <string.h> | |
64 | #else | |
65 | extern char *index (); | |
66 | extern char *rindex (); | |
67 | #endif | |
68 | ||
8d08fdba MS |
69 | #ifndef errno |
70 | extern int errno; /* needed for VAX. */ | |
71 | #endif | |
8d08fdba MS |
72 | |
73 | #define obstack_chunk_alloc xmalloc | |
74 | #define obstack_chunk_free free | |
75 | ||
5566b478 | 76 | extern struct obstack permanent_obstack; |
8d08fdba MS |
77 | extern struct obstack *current_obstack, *saveable_obstack; |
78 | ||
49c249e1 JM |
79 | extern void yyprint PROTO((FILE *, int, YYSTYPE)); |
80 | extern void set_float_handler PROTO((jmp_buf)); | |
81 | extern void compiler_error PROTO((char *, HOST_WIDE_INT, | |
82 | HOST_WIDE_INT)); | |
83 | ||
84 | static tree get_time_identifier PROTO((char *)); | |
85 | static int check_newline PROTO((void)); | |
86 | static int skip_white_space PROTO((int)); | |
87 | static int yynextch PROTO((void)); | |
88 | static void finish_defarg PROTO((void)); | |
89 | static int my_get_run_time PROTO((void)); | |
90 | static int get_last_nonwhite_on_line PROTO((void)); | |
91 | static int interface_strcmp PROTO((char *)); | |
92 | static int readescape PROTO((int *)); | |
93 | static char *extend_token_buffer PROTO((char *)); | |
94 | static void consume_string PROTO((struct obstack *, int)); | |
95 | static void set_typedecl_interface_info PROTO((tree, tree)); | |
96 | static void feed_defarg PROTO((tree, tree)); | |
97 | static int set_vardecl_interface_info PROTO((tree, tree)); | |
98 | static void store_pending_inline PROTO((tree, struct pending_inline *)); | |
99 | static void reinit_parse_for_expr PROTO((struct obstack *)); | |
8d08fdba MS |
100 | |
101 | /* Given a file name X, return the nondirectory portion. | |
102 | Keep in mind that X can be computed more than once. */ | |
b2bb2710 BK |
103 | char * |
104 | file_name_nondirectory (x) | |
105 | char *x; | |
106 | { | |
107 | char *tmp = (char *) rindex (x, '/'); | |
108 | if (tmp) | |
109 | return (char *) (tmp + 1); | |
110 | else | |
111 | return x; | |
112 | } | |
8d08fdba | 113 | |
8d08fdba MS |
114 | /* This obstack is needed to hold text. It is not safe to use |
115 | TOKEN_BUFFER because `check_newline' calls `yylex'. */ | |
116 | struct obstack inline_text_obstack; | |
42976354 | 117 | char *inline_text_firstobj; |
f376e137 | 118 | |
8d08fdba MS |
119 | int end_of_file; |
120 | ||
121 | /* Pending language change. | |
122 | Positive is push count, negative is pop count. */ | |
123 | int pending_lang_change = 0; | |
124 | ||
125 | /* Wrap the current header file in extern "C". */ | |
126 | static int c_header_level = 0; | |
127 | ||
128 | extern int first_token; | |
129 | extern struct obstack token_obstack; | |
130 | ||
131 | /* ??? Don't really know where this goes yet. */ | |
132 | #if 1 | |
133 | #include "input.c" | |
134 | #else | |
135 | extern void put_back (/* int */); | |
136 | extern int input_redirected (); | |
42976354 | 137 | extern void feed_input (/* char *, int */); |
8d08fdba MS |
138 | #endif |
139 | ||
140 | /* Holds translations from TREE_CODEs to operator name strings, | |
141 | i.e., opname_tab[PLUS_EXPR] == "+". */ | |
142 | char **opname_tab; | |
143 | char **assignop_tab; | |
144 | \f | |
145 | extern int yychar; /* the lookahead symbol */ | |
146 | extern YYSTYPE yylval; /* the semantic value of the */ | |
147 | /* lookahead symbol */ | |
148 | ||
149 | #if 0 | |
150 | YYLTYPE yylloc; /* location data for the lookahead */ | |
151 | /* symbol */ | |
152 | #endif | |
153 | ||
154 | ||
155 | /* the declaration found for the last IDENTIFIER token read in. | |
156 | yylex must look this up to detect typedefs, which get token type TYPENAME, | |
157 | so it is left around in case the identifier is not a typedef but is | |
158 | used in a context which makes it a reference to a variable. */ | |
159 | tree lastiddecl; | |
160 | ||
161 | /* The elements of `ridpointers' are identifier nodes | |
162 | for the reserved type names and storage classes. | |
163 | It is indexed by a RID_... value. */ | |
164 | tree ridpointers[(int) RID_MAX]; | |
165 | ||
166 | /* We may keep statistics about how long which files took to compile. */ | |
167 | static int header_time, body_time; | |
8d08fdba MS |
168 | static tree filename_times; |
169 | static tree this_filename_time; | |
170 | ||
8d08fdba MS |
171 | /* Array for holding counts of the numbers of tokens seen. */ |
172 | extern int *token_count; | |
8d08fdba MS |
173 | \f |
174 | /* Return something to represent absolute declarators containing a *. | |
175 | TARGET is the absolute declarator that the * contains. | |
c11b6f21 | 176 | CV_QUALIFIERS is a list of modifiers such as const or volatile |
8d08fdba MS |
177 | to apply to the pointer type, represented as identifiers. |
178 | ||
179 | We return an INDIRECT_REF whose "contents" are TARGET | |
180 | and whose type is the modifier list. */ | |
181 | ||
182 | tree | |
c11b6f21 MS |
183 | make_pointer_declarator (cv_qualifiers, target) |
184 | tree cv_qualifiers, target; | |
8d08fdba MS |
185 | { |
186 | if (target && TREE_CODE (target) == IDENTIFIER_NODE | |
187 | && ANON_AGGRNAME_P (target)) | |
188 | error ("type name expected before `*'"); | |
189 | target = build_parse_node (INDIRECT_REF, target); | |
c11b6f21 | 190 | TREE_TYPE (target) = cv_qualifiers; |
8d08fdba MS |
191 | return target; |
192 | } | |
193 | ||
194 | /* Return something to represent absolute declarators containing a &. | |
195 | TARGET is the absolute declarator that the & contains. | |
c11b6f21 | 196 | CV_QUALIFIERS is a list of modifiers such as const or volatile |
8d08fdba MS |
197 | to apply to the reference type, represented as identifiers. |
198 | ||
199 | We return an ADDR_EXPR whose "contents" are TARGET | |
200 | and whose type is the modifier list. */ | |
201 | ||
202 | tree | |
c11b6f21 MS |
203 | make_reference_declarator (cv_qualifiers, target) |
204 | tree cv_qualifiers, target; | |
8d08fdba MS |
205 | { |
206 | if (target) | |
207 | { | |
208 | if (TREE_CODE (target) == ADDR_EXPR) | |
209 | { | |
210 | error ("cannot declare references to references"); | |
211 | return target; | |
212 | } | |
213 | if (TREE_CODE (target) == INDIRECT_REF) | |
214 | { | |
215 | error ("cannot declare pointers to references"); | |
216 | return target; | |
217 | } | |
218 | if (TREE_CODE (target) == IDENTIFIER_NODE && ANON_AGGRNAME_P (target)) | |
219 | error ("type name expected before `&'"); | |
220 | } | |
221 | target = build_parse_node (ADDR_EXPR, target); | |
c11b6f21 | 222 | TREE_TYPE (target) = cv_qualifiers; |
8d08fdba MS |
223 | return target; |
224 | } | |
c11b6f21 MS |
225 | |
226 | tree | |
227 | make_call_declarator (target, parms, cv_qualifiers, exception_specification) | |
228 | tree target, parms, cv_qualifiers, exception_specification; | |
229 | { | |
230 | target = build_parse_node (CALL_EXPR, target, parms, cv_qualifiers); | |
231 | TREE_TYPE (target) = exception_specification; | |
232 | return target; | |
233 | } | |
234 | ||
235 | void | |
236 | set_quals_and_spec (call_declarator, cv_qualifiers, exception_specification) | |
237 | tree call_declarator, cv_qualifiers, exception_specification; | |
238 | { | |
239 | TREE_OPERAND (call_declarator, 2) = cv_qualifiers; | |
240 | TREE_TYPE (call_declarator) = exception_specification; | |
241 | } | |
8d08fdba MS |
242 | \f |
243 | /* Build names and nodes for overloaded operators. */ | |
244 | ||
245 | tree ansi_opname[LAST_CPLUS_TREE_CODE]; | |
246 | tree ansi_assopname[LAST_CPLUS_TREE_CODE]; | |
247 | ||
248 | char * | |
249 | operator_name_string (name) | |
250 | tree name; | |
251 | { | |
252 | char *opname = IDENTIFIER_POINTER (name) + 2; | |
253 | tree *opname_table; | |
254 | int i, assign; | |
255 | ||
256 | /* Works for builtin and user defined types. */ | |
257 | if (IDENTIFIER_GLOBAL_VALUE (name) | |
258 | && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (name)) == TYPE_DECL) | |
259 | return IDENTIFIER_POINTER (name); | |
260 | ||
261 | if (opname[0] == 'a' && opname[2] != '\0' && opname[2] != '_') | |
262 | { | |
263 | opname += 1; | |
264 | assign = 1; | |
265 | opname_table = ansi_assopname; | |
266 | } | |
267 | else | |
268 | { | |
269 | assign = 0; | |
270 | opname_table = ansi_opname; | |
271 | } | |
272 | ||
273 | for (i = 0; i < (int) LAST_CPLUS_TREE_CODE; i++) | |
274 | { | |
275 | if (opname[0] == IDENTIFIER_POINTER (opname_table[i])[2+assign] | |
276 | && opname[1] == IDENTIFIER_POINTER (opname_table[i])[3+assign]) | |
277 | break; | |
278 | } | |
279 | ||
280 | if (i == LAST_CPLUS_TREE_CODE) | |
281 | return "<invalid operator>"; | |
282 | ||
283 | if (assign) | |
284 | return assignop_tab[i]; | |
285 | else | |
286 | return opname_tab[i]; | |
287 | } | |
288 | \f | |
289 | int interface_only; /* whether or not current file is only for | |
290 | interface definitions. */ | |
291 | int interface_unknown; /* whether or not we know this class | |
292 | to behave according to #pragma interface. */ | |
293 | ||
294 | /* lexical analyzer */ | |
295 | ||
296 | /* File used for outputting assembler code. */ | |
297 | extern FILE *asm_out_file; | |
298 | ||
299 | #ifndef WCHAR_TYPE_SIZE | |
300 | #ifdef INT_TYPE_SIZE | |
301 | #define WCHAR_TYPE_SIZE INT_TYPE_SIZE | |
302 | #else | |
303 | #define WCHAR_TYPE_SIZE BITS_PER_WORD | |
304 | #endif | |
305 | #endif | |
306 | ||
307 | /* Number of bytes in a wide character. */ | |
308 | #define WCHAR_BYTES (WCHAR_TYPE_SIZE / BITS_PER_UNIT) | |
309 | ||
310 | static int maxtoken; /* Current nominal length of token buffer. */ | |
311 | char *token_buffer; /* Pointer to token buffer. | |
312 | Actual allocated length is maxtoken + 2. */ | |
313 | ||
314 | #include "hash.h" | |
315 | \f | |
8d08fdba MS |
316 | |
317 | /* Nonzero tells yylex to ignore \ in string constants. */ | |
318 | static int ignore_escape_flag = 0; | |
319 | ||
8d08fdba MS |
320 | static tree |
321 | get_time_identifier (name) | |
322 | char *name; | |
323 | { | |
324 | tree time_identifier; | |
325 | int len = strlen (name); | |
326 | char *buf = (char *) alloca (len + 6); | |
327 | strcpy (buf, "file "); | |
328 | bcopy (name, buf+5, len); | |
329 | buf[len+5] = '\0'; | |
330 | time_identifier = get_identifier (buf); | |
331 | if (IDENTIFIER_LOCAL_VALUE (time_identifier) == NULL_TREE) | |
332 | { | |
333 | push_obstacks_nochange (); | |
334 | end_temporary_allocation (); | |
335 | IDENTIFIER_LOCAL_VALUE (time_identifier) = build_int_2 (0, 0); | |
336 | IDENTIFIER_CLASS_VALUE (time_identifier) = build_int_2 (0, 1); | |
337 | IDENTIFIER_GLOBAL_VALUE (time_identifier) = filename_times; | |
338 | filename_times = time_identifier; | |
339 | pop_obstacks (); | |
340 | } | |
341 | return time_identifier; | |
342 | } | |
343 | ||
344 | #ifdef __GNUC__ | |
345 | __inline | |
346 | #endif | |
347 | static int | |
348 | my_get_run_time () | |
349 | { | |
350 | int old_quiet_flag = quiet_flag; | |
351 | int this_time; | |
352 | quiet_flag = 0; | |
353 | this_time = get_run_time (); | |
354 | quiet_flag = old_quiet_flag; | |
355 | return this_time; | |
356 | } | |
357 | \f | |
358 | /* Table indexed by tree code giving a string containing a character | |
359 | classifying the tree code. Possibilities are | |
e92cc029 | 360 | t, d, s, c, r, <, 1 and 2. See cp/cp-tree.def for details. */ |
8d08fdba MS |
361 | |
362 | #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE, | |
363 | ||
364 | char *cplus_tree_code_type[] = { | |
365 | "x", | |
e92cc029 | 366 | #include "cp-tree.def" |
8d08fdba MS |
367 | }; |
368 | #undef DEFTREECODE | |
369 | ||
370 | /* Table indexed by tree code giving number of expression | |
371 | operands beyond the fixed part of the node structure. | |
372 | Not used for types or decls. */ | |
373 | ||
374 | #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH, | |
375 | ||
376 | int cplus_tree_code_length[] = { | |
377 | 0, | |
e92cc029 | 378 | #include "cp-tree.def" |
8d08fdba MS |
379 | }; |
380 | #undef DEFTREECODE | |
381 | ||
382 | /* Names of tree components. | |
383 | Used for printing out the tree and error messages. */ | |
384 | #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME, | |
385 | ||
386 | char *cplus_tree_code_name[] = { | |
387 | "@@dummy", | |
e92cc029 | 388 | #include "cp-tree.def" |
8d08fdba MS |
389 | }; |
390 | #undef DEFTREECODE | |
391 | \f | |
392 | /* toplev.c needs to call these. */ | |
393 | ||
394 | void | |
395 | lang_init () | |
396 | { | |
397 | /* the beginning of the file is a new line; check for # */ | |
398 | /* With luck, we discover the real source file's name from that | |
399 | and put it in input_filename. */ | |
400 | put_back (check_newline ()); | |
8d08fdba | 401 | if (flag_gnu_xref) GNU_xref_begin (input_filename); |
faae18ab | 402 | init_repo (input_filename); |
56bf1fd9 JL |
403 | |
404 | /* See comments in toplev.c before the call to lang_init. */ | |
405 | if (flag_exceptions == 2) | |
406 | flag_exceptions = 1; | |
8d08fdba MS |
407 | } |
408 | ||
409 | void | |
410 | lang_finish () | |
411 | { | |
412 | extern int errorcount, sorrycount; | |
413 | if (flag_gnu_xref) GNU_xref_end (errorcount+sorrycount); | |
414 | } | |
415 | ||
416 | char * | |
417 | lang_identify () | |
418 | { | |
419 | return "cplusplus"; | |
420 | } | |
421 | ||
422 | void | |
423 | init_filename_times () | |
424 | { | |
425 | this_filename_time = get_time_identifier ("<top level>"); | |
426 | if (flag_detailed_statistics) | |
427 | { | |
428 | header_time = 0; | |
429 | body_time = my_get_run_time (); | |
430 | TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time)) = body_time; | |
431 | } | |
432 | } | |
433 | ||
434 | /* Change by Bryan Boreham, Kewill, Thu Jul 27 09:46:05 1989. | |
435 | Stuck this hack in to get the files open correctly; this is called | |
436 | in place of init_lex if we are an unexec'd binary. */ | |
e92cc029 | 437 | |
bd6dd845 | 438 | #if 0 |
8d08fdba MS |
439 | void |
440 | reinit_lang_specific () | |
441 | { | |
442 | init_filename_times (); | |
443 | reinit_search_statistics (); | |
444 | } | |
bd6dd845 | 445 | #endif |
8d08fdba MS |
446 | |
447 | void | |
448 | init_lex () | |
449 | { | |
e1cd6e56 MS |
450 | extern int flag_no_gnu_keywords; |
451 | extern int flag_operator_names; | |
8d08fdba MS |
452 | |
453 | int i; | |
454 | ||
455 | /* Initialize the lookahead machinery. */ | |
456 | init_spew (); | |
457 | ||
458 | /* Make identifier nodes long enough for the language-specific slots. */ | |
459 | set_identifier_size (sizeof (struct lang_identifier)); | |
460 | decl_printable_name = lang_printable_name; | |
461 | ||
462 | init_cplus_expand (); | |
463 | ||
464 | tree_code_type | |
465 | = (char **) realloc (tree_code_type, | |
466 | sizeof (char *) * LAST_CPLUS_TREE_CODE); | |
467 | tree_code_length | |
468 | = (int *) realloc (tree_code_length, | |
469 | sizeof (int) * LAST_CPLUS_TREE_CODE); | |
470 | tree_code_name | |
471 | = (char **) realloc (tree_code_name, | |
472 | sizeof (char *) * LAST_CPLUS_TREE_CODE); | |
473 | bcopy ((char *)cplus_tree_code_type, | |
474 | (char *)(tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE), | |
475 | (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *)); | |
476 | bcopy ((char *)cplus_tree_code_length, | |
477 | (char *)(tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE), | |
478 | (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int)); | |
479 | bcopy ((char *)cplus_tree_code_name, | |
480 | (char *)(tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE), | |
481 | (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *)); | |
482 | ||
483 | opname_tab = (char **)oballoc ((int)LAST_CPLUS_TREE_CODE * sizeof (char *)); | |
484 | bzero ((char *)opname_tab, (int)LAST_CPLUS_TREE_CODE * sizeof (char *)); | |
485 | assignop_tab = (char **)oballoc ((int)LAST_CPLUS_TREE_CODE * sizeof (char *)); | |
486 | bzero ((char *)assignop_tab, (int)LAST_CPLUS_TREE_CODE * sizeof (char *)); | |
487 | ||
488 | ansi_opname[0] = get_identifier ("<invalid operator>"); | |
489 | for (i = 0; i < (int) LAST_CPLUS_TREE_CODE; i++) | |
490 | { | |
491 | ansi_opname[i] = ansi_opname[0]; | |
492 | ansi_assopname[i] = ansi_opname[0]; | |
493 | } | |
494 | ||
495 | ansi_opname[(int) MULT_EXPR] = get_identifier ("__ml"); | |
496 | IDENTIFIER_OPNAME_P (ansi_opname[(int) MULT_EXPR]) = 1; | |
497 | ansi_opname[(int) INDIRECT_REF] = ansi_opname[(int) MULT_EXPR]; | |
498 | ansi_assopname[(int) MULT_EXPR] = get_identifier ("__aml"); | |
499 | IDENTIFIER_OPNAME_P (ansi_assopname[(int) MULT_EXPR]) = 1; | |
500 | ansi_assopname[(int) INDIRECT_REF] = ansi_assopname[(int) MULT_EXPR]; | |
501 | ansi_opname[(int) TRUNC_MOD_EXPR] = get_identifier ("__md"); | |
502 | IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUNC_MOD_EXPR]) = 1; | |
503 | ansi_assopname[(int) TRUNC_MOD_EXPR] = get_identifier ("__amd"); | |
504 | IDENTIFIER_OPNAME_P (ansi_assopname[(int) TRUNC_MOD_EXPR]) = 1; | |
505 | ansi_opname[(int) CEIL_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR]; | |
506 | ansi_opname[(int) FLOOR_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR]; | |
507 | ansi_opname[(int) ROUND_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR]; | |
508 | ansi_opname[(int) MINUS_EXPR] = get_identifier ("__mi"); | |
509 | IDENTIFIER_OPNAME_P (ansi_opname[(int) MINUS_EXPR]) = 1; | |
510 | ansi_opname[(int) NEGATE_EXPR] = ansi_opname[(int) MINUS_EXPR]; | |
511 | ansi_assopname[(int) MINUS_EXPR] = get_identifier ("__ami"); | |
512 | IDENTIFIER_OPNAME_P (ansi_assopname[(int) MINUS_EXPR]) = 1; | |
513 | ansi_assopname[(int) NEGATE_EXPR] = ansi_assopname[(int) MINUS_EXPR]; | |
514 | ansi_opname[(int) RSHIFT_EXPR] = get_identifier ("__rs"); | |
515 | IDENTIFIER_OPNAME_P (ansi_opname[(int) RSHIFT_EXPR]) = 1; | |
516 | ansi_assopname[(int) RSHIFT_EXPR] = get_identifier ("__ars"); | |
517 | IDENTIFIER_OPNAME_P (ansi_assopname[(int) RSHIFT_EXPR]) = 1; | |
518 | ansi_opname[(int) NE_EXPR] = get_identifier ("__ne"); | |
519 | IDENTIFIER_OPNAME_P (ansi_opname[(int) NE_EXPR]) = 1; | |
520 | ansi_opname[(int) GT_EXPR] = get_identifier ("__gt"); | |
521 | IDENTIFIER_OPNAME_P (ansi_opname[(int) GT_EXPR]) = 1; | |
522 | ansi_opname[(int) GE_EXPR] = get_identifier ("__ge"); | |
523 | IDENTIFIER_OPNAME_P (ansi_opname[(int) GE_EXPR]) = 1; | |
524 | ansi_opname[(int) BIT_IOR_EXPR] = get_identifier ("__or"); | |
525 | IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_IOR_EXPR]) = 1; | |
526 | ansi_assopname[(int) BIT_IOR_EXPR] = get_identifier ("__aor"); | |
527 | IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_IOR_EXPR]) = 1; | |
528 | ansi_opname[(int) TRUTH_ANDIF_EXPR] = get_identifier ("__aa"); | |
529 | IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_ANDIF_EXPR]) = 1; | |
530 | ansi_opname[(int) TRUTH_NOT_EXPR] = get_identifier ("__nt"); | |
531 | IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_NOT_EXPR]) = 1; | |
532 | ansi_opname[(int) PREINCREMENT_EXPR] = get_identifier ("__pp"); | |
533 | IDENTIFIER_OPNAME_P (ansi_opname[(int) PREINCREMENT_EXPR]) = 1; | |
534 | ansi_opname[(int) POSTINCREMENT_EXPR] = ansi_opname[(int) PREINCREMENT_EXPR]; | |
535 | ansi_opname[(int) MODIFY_EXPR] = get_identifier ("__as"); | |
536 | IDENTIFIER_OPNAME_P (ansi_opname[(int) MODIFY_EXPR]) = 1; | |
537 | ansi_assopname[(int) NOP_EXPR] = ansi_opname[(int) MODIFY_EXPR]; | |
538 | ansi_opname[(int) COMPOUND_EXPR] = get_identifier ("__cm"); | |
539 | IDENTIFIER_OPNAME_P (ansi_opname[(int) COMPOUND_EXPR]) = 1; | |
540 | ansi_opname[(int) EXACT_DIV_EXPR] = get_identifier ("__dv"); | |
541 | IDENTIFIER_OPNAME_P (ansi_opname[(int) EXACT_DIV_EXPR]) = 1; | |
542 | ansi_assopname[(int) EXACT_DIV_EXPR] = get_identifier ("__adv"); | |
543 | IDENTIFIER_OPNAME_P (ansi_assopname[(int) EXACT_DIV_EXPR]) = 1; | |
544 | ansi_opname[(int) TRUNC_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR]; | |
545 | ansi_opname[(int) CEIL_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR]; | |
546 | ansi_opname[(int) FLOOR_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR]; | |
547 | ansi_opname[(int) ROUND_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR]; | |
548 | ansi_opname[(int) PLUS_EXPR] = get_identifier ("__pl"); | |
549 | ansi_assopname[(int) TRUNC_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR]; | |
550 | ansi_assopname[(int) CEIL_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR]; | |
551 | ansi_assopname[(int) FLOOR_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR]; | |
552 | ansi_assopname[(int) ROUND_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR]; | |
553 | IDENTIFIER_OPNAME_P (ansi_opname[(int) PLUS_EXPR]) = 1; | |
554 | ansi_assopname[(int) PLUS_EXPR] = get_identifier ("__apl"); | |
555 | IDENTIFIER_OPNAME_P (ansi_assopname[(int) PLUS_EXPR]) = 1; | |
556 | ansi_opname[(int) CONVERT_EXPR] = ansi_opname[(int) PLUS_EXPR]; | |
557 | ansi_assopname[(int) CONVERT_EXPR] = ansi_assopname[(int) PLUS_EXPR]; | |
558 | ansi_opname[(int) LSHIFT_EXPR] = get_identifier ("__ls"); | |
559 | IDENTIFIER_OPNAME_P (ansi_opname[(int) LSHIFT_EXPR]) = 1; | |
560 | ansi_assopname[(int) LSHIFT_EXPR] = get_identifier ("__als"); | |
561 | IDENTIFIER_OPNAME_P (ansi_assopname[(int) LSHIFT_EXPR]) = 1; | |
562 | ansi_opname[(int) EQ_EXPR] = get_identifier ("__eq"); | |
563 | IDENTIFIER_OPNAME_P (ansi_opname[(int) EQ_EXPR]) = 1; | |
564 | ansi_opname[(int) LT_EXPR] = get_identifier ("__lt"); | |
565 | IDENTIFIER_OPNAME_P (ansi_opname[(int) LT_EXPR]) = 1; | |
566 | ansi_opname[(int) LE_EXPR] = get_identifier ("__le"); | |
567 | IDENTIFIER_OPNAME_P (ansi_opname[(int) LE_EXPR]) = 1; | |
568 | ansi_opname[(int) BIT_AND_EXPR] = get_identifier ("__ad"); | |
569 | IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_AND_EXPR]) = 1; | |
570 | ansi_assopname[(int) BIT_AND_EXPR] = get_identifier ("__aad"); | |
571 | IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_AND_EXPR]) = 1; | |
572 | ansi_opname[(int) ADDR_EXPR] = ansi_opname[(int) BIT_AND_EXPR]; | |
573 | ansi_assopname[(int) ADDR_EXPR] = ansi_assopname[(int) BIT_AND_EXPR]; | |
574 | ansi_opname[(int) BIT_XOR_EXPR] = get_identifier ("__er"); | |
575 | IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_XOR_EXPR]) = 1; | |
576 | ansi_assopname[(int) BIT_XOR_EXPR] = get_identifier ("__aer"); | |
577 | IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_XOR_EXPR]) = 1; | |
578 | ansi_opname[(int) TRUTH_ORIF_EXPR] = get_identifier ("__oo"); | |
579 | IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_ORIF_EXPR]) = 1; | |
580 | ansi_opname[(int) BIT_NOT_EXPR] = get_identifier ("__co"); | |
581 | IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_NOT_EXPR]) = 1; | |
582 | ansi_opname[(int) PREDECREMENT_EXPR] = get_identifier ("__mm"); | |
583 | IDENTIFIER_OPNAME_P (ansi_opname[(int) PREDECREMENT_EXPR]) = 1; | |
584 | ansi_opname[(int) POSTDECREMENT_EXPR] = ansi_opname[(int) PREDECREMENT_EXPR]; | |
585 | ansi_opname[(int) COMPONENT_REF] = get_identifier ("__rf"); | |
586 | IDENTIFIER_OPNAME_P (ansi_opname[(int) COMPONENT_REF]) = 1; | |
587 | ansi_opname[(int) MEMBER_REF] = get_identifier ("__rm"); | |
588 | IDENTIFIER_OPNAME_P (ansi_opname[(int) MEMBER_REF]) = 1; | |
589 | ansi_opname[(int) CALL_EXPR] = get_identifier ("__cl"); | |
590 | IDENTIFIER_OPNAME_P (ansi_opname[(int) CALL_EXPR]) = 1; | |
591 | ansi_opname[(int) ARRAY_REF] = get_identifier ("__vc"); | |
592 | IDENTIFIER_OPNAME_P (ansi_opname[(int) ARRAY_REF]) = 1; | |
593 | ansi_opname[(int) NEW_EXPR] = get_identifier ("__nw"); | |
594 | IDENTIFIER_OPNAME_P (ansi_opname[(int) NEW_EXPR]) = 1; | |
595 | ansi_opname[(int) DELETE_EXPR] = get_identifier ("__dl"); | |
596 | IDENTIFIER_OPNAME_P (ansi_opname[(int) DELETE_EXPR]) = 1; | |
a28e3c7f MS |
597 | ansi_opname[(int) VEC_NEW_EXPR] = get_identifier ("__vn"); |
598 | IDENTIFIER_OPNAME_P (ansi_opname[(int) VEC_NEW_EXPR]) = 1; | |
599 | ansi_opname[(int) VEC_DELETE_EXPR] = get_identifier ("__vd"); | |
600 | IDENTIFIER_OPNAME_P (ansi_opname[(int) VEC_DELETE_EXPR]) = 1; | |
8d08fdba MS |
601 | ansi_opname[(int) TYPE_EXPR] = get_identifier ("__op"); |
602 | IDENTIFIER_OPNAME_P (ansi_opname[(int) TYPE_EXPR]) = 1; | |
603 | ||
604 | /* This is not true: these operators are not defined in ANSI, | |
605 | but we need them anyway. */ | |
606 | ansi_opname[(int) MIN_EXPR] = get_identifier ("__mn"); | |
607 | IDENTIFIER_OPNAME_P (ansi_opname[(int) MIN_EXPR]) = 1; | |
608 | ansi_opname[(int) MAX_EXPR] = get_identifier ("__mx"); | |
609 | IDENTIFIER_OPNAME_P (ansi_opname[(int) MAX_EXPR]) = 1; | |
610 | ansi_opname[(int) COND_EXPR] = get_identifier ("__cn"); | |
611 | IDENTIFIER_OPNAME_P (ansi_opname[(int) COND_EXPR]) = 1; | |
612 | ansi_opname[(int) METHOD_CALL_EXPR] = get_identifier ("__wr"); | |
613 | IDENTIFIER_OPNAME_P (ansi_opname[(int) METHOD_CALL_EXPR]) = 1; | |
614 | ||
615 | init_method (); | |
616 | init_error (); | |
617 | gcc_obstack_init (&inline_text_obstack); | |
42976354 | 618 | inline_text_firstobj = (char *) obstack_alloc (&inline_text_obstack, 0); |
8d08fdba MS |
619 | |
620 | /* Start it at 0, because check_newline is called at the very beginning | |
621 | and will increment it to 1. */ | |
622 | lineno = 0; | |
623 | input_filename = "<internal>"; | |
624 | current_function_decl = NULL; | |
625 | ||
626 | maxtoken = 40; | |
627 | token_buffer = (char *) xmalloc (maxtoken + 2); | |
628 | ||
629 | ridpointers[(int) RID_INT] = get_identifier ("int"); | |
630 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INT], | |
631 | build_tree_list (NULL_TREE, ridpointers[(int) RID_INT])); | |
2986ae00 MS |
632 | ridpointers[(int) RID_BOOL] = get_identifier ("bool"); |
633 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_BOOL], | |
634 | build_tree_list (NULL_TREE, ridpointers[(int) RID_BOOL])); | |
8d08fdba MS |
635 | ridpointers[(int) RID_CHAR] = get_identifier ("char"); |
636 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CHAR], | |
637 | build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR])); | |
638 | ridpointers[(int) RID_VOID] = get_identifier ("void"); | |
639 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOID], | |
640 | build_tree_list (NULL_TREE, ridpointers[(int) RID_VOID])); | |
641 | ridpointers[(int) RID_FLOAT] = get_identifier ("float"); | |
642 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FLOAT], | |
643 | build_tree_list (NULL_TREE, ridpointers[(int) RID_FLOAT])); | |
644 | ridpointers[(int) RID_DOUBLE] = get_identifier ("double"); | |
645 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_DOUBLE], | |
646 | build_tree_list (NULL_TREE, ridpointers[(int) RID_DOUBLE])); | |
647 | ridpointers[(int) RID_SHORT] = get_identifier ("short"); | |
648 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SHORT], | |
649 | build_tree_list (NULL_TREE, ridpointers[(int) RID_SHORT])); | |
650 | ridpointers[(int) RID_LONG] = get_identifier ("long"); | |
651 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_LONG], | |
652 | build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG])); | |
653 | ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned"); | |
654 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_UNSIGNED], | |
655 | build_tree_list (NULL_TREE, ridpointers[(int) RID_UNSIGNED])); | |
656 | ridpointers[(int) RID_SIGNED] = get_identifier ("signed"); | |
657 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SIGNED], | |
658 | build_tree_list (NULL_TREE, ridpointers[(int) RID_SIGNED])); | |
659 | ridpointers[(int) RID_INLINE] = get_identifier ("inline"); | |
660 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INLINE], | |
661 | build_tree_list (NULL_TREE, ridpointers[(int) RID_INLINE])); | |
662 | ridpointers[(int) RID_CONST] = get_identifier ("const"); | |
663 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CONST], | |
664 | build_tree_list (NULL_TREE, ridpointers[(int) RID_CONST])); | |
665 | ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile"); | |
666 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOLATILE], | |
667 | build_tree_list (NULL_TREE, ridpointers[(int) RID_VOLATILE])); | |
668 | ridpointers[(int) RID_AUTO] = get_identifier ("auto"); | |
669 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_AUTO], | |
670 | build_tree_list (NULL_TREE, ridpointers[(int) RID_AUTO])); | |
671 | ridpointers[(int) RID_STATIC] = get_identifier ("static"); | |
672 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_STATIC], | |
673 | build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC])); | |
674 | ridpointers[(int) RID_EXTERN] = get_identifier ("extern"); | |
675 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_EXTERN], | |
676 | build_tree_list (NULL_TREE, ridpointers[(int) RID_EXTERN])); | |
677 | ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef"); | |
678 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_TYPEDEF], | |
679 | build_tree_list (NULL_TREE, ridpointers[(int) RID_TYPEDEF])); | |
680 | ridpointers[(int) RID_REGISTER] = get_identifier ("register"); | |
681 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_REGISTER], | |
682 | build_tree_list (NULL_TREE, ridpointers[(int) RID_REGISTER])); | |
8eeda2ec | 683 | ridpointers[(int) RID_COMPLEX] = get_identifier ("__complex"); |
37c46b43 MS |
684 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_COMPLEX], |
685 | build_tree_list (NULL_TREE, ridpointers[(int) RID_COMPLEX])); | |
8d08fdba | 686 | |
e92cc029 | 687 | /* C++ extensions. These are probably not correctly named. */ |
8d08fdba MS |
688 | ridpointers[(int) RID_WCHAR] = get_identifier ("__wchar_t"); |
689 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_WCHAR], | |
690 | build_tree_list (NULL_TREE, ridpointers[(int) RID_WCHAR])); | |
691 | class_type_node = build_int_2 (class_type, 0); | |
692 | TREE_TYPE (class_type_node) = class_type_node; | |
693 | ridpointers[(int) RID_CLASS] = class_type_node; | |
694 | ||
695 | record_type_node = build_int_2 (record_type, 0); | |
696 | TREE_TYPE (record_type_node) = record_type_node; | |
697 | ridpointers[(int) RID_RECORD] = record_type_node; | |
698 | ||
699 | union_type_node = build_int_2 (union_type, 0); | |
700 | TREE_TYPE (union_type_node) = union_type_node; | |
701 | ridpointers[(int) RID_UNION] = union_type_node; | |
702 | ||
703 | enum_type_node = build_int_2 (enum_type, 0); | |
704 | TREE_TYPE (enum_type_node) = enum_type_node; | |
705 | ridpointers[(int) RID_ENUM] = enum_type_node; | |
706 | ||
707 | ridpointers[(int) RID_VIRTUAL] = get_identifier ("virtual"); | |
708 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VIRTUAL], | |
709 | build_tree_list (NULL_TREE, ridpointers[(int) RID_VIRTUAL])); | |
db5ae43f MS |
710 | ridpointers[(int) RID_EXPLICIT] = get_identifier ("explicit"); |
711 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_EXPLICIT], | |
712 | build_tree_list (NULL_TREE, ridpointers[(int) RID_EXPLICIT])); | |
8d08fdba MS |
713 | ridpointers[(int) RID_FRIEND] = get_identifier ("friend"); |
714 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FRIEND], | |
715 | build_tree_list (NULL_TREE, ridpointers[(int) RID_FRIEND])); | |
716 | ||
717 | ridpointers[(int) RID_PUBLIC] = get_identifier ("public"); | |
718 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_PUBLIC], | |
719 | build_tree_list (NULL_TREE, ridpointers[(int) RID_PUBLIC])); | |
720 | ridpointers[(int) RID_PRIVATE] = get_identifier ("private"); | |
721 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_PRIVATE], | |
722 | build_tree_list (NULL_TREE, ridpointers[(int) RID_PRIVATE])); | |
723 | ridpointers[(int) RID_PROTECTED] = get_identifier ("protected"); | |
724 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_PROTECTED], | |
725 | build_tree_list (NULL_TREE, ridpointers[(int) RID_PROTECTED])); | |
a4443a08 MS |
726 | ridpointers[(int) RID_TEMPLATE] = get_identifier ("template"); |
727 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_TEMPLATE], | |
728 | build_tree_list (NULL_TREE, ridpointers[(int) RID_TEMPLATE])); | |
e92cc029 | 729 | /* This is for ANSI C++. */ |
8d08fdba MS |
730 | ridpointers[(int) RID_MUTABLE] = get_identifier ("mutable"); |
731 | SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_MUTABLE], | |
732 | build_tree_list (NULL_TREE, ridpointers[(int) RID_MUTABLE])); | |
733 | ||
8d08fdba MS |
734 | /* Signature handling extensions. */ |
735 | signature_type_node = build_int_2 (signature_type, 0); | |
736 | TREE_TYPE (signature_type_node) = signature_type_node; | |
737 | ridpointers[(int) RID_SIGNATURE] = signature_type_node; | |
738 | ||
d11ad92e MS |
739 | null_node = build_int_2 (0, 0); |
740 | ridpointers[RID_NULL] = null_node; | |
c73964b2 | 741 | |
8d08fdba MS |
742 | opname_tab[(int) COMPONENT_REF] = "->"; |
743 | opname_tab[(int) MEMBER_REF] = "->*"; | |
744 | opname_tab[(int) METHOD_CALL_EXPR] = "->()"; | |
6467930b | 745 | opname_tab[(int) INDIRECT_REF] = "*"; |
8d08fdba MS |
746 | opname_tab[(int) ARRAY_REF] = "[]"; |
747 | opname_tab[(int) MODIFY_EXPR] = "="; | |
748 | opname_tab[(int) NEW_EXPR] = "new"; | |
749 | opname_tab[(int) DELETE_EXPR] = "delete"; | |
a28e3c7f MS |
750 | opname_tab[(int) VEC_NEW_EXPR] = "new []"; |
751 | opname_tab[(int) VEC_DELETE_EXPR] = "delete []"; | |
6467930b | 752 | opname_tab[(int) COND_EXPR] = "?:"; |
8d08fdba MS |
753 | opname_tab[(int) CALL_EXPR] = "()"; |
754 | opname_tab[(int) PLUS_EXPR] = "+"; | |
755 | opname_tab[(int) MINUS_EXPR] = "-"; | |
756 | opname_tab[(int) MULT_EXPR] = "*"; | |
757 | opname_tab[(int) TRUNC_DIV_EXPR] = "/"; | |
758 | opname_tab[(int) CEIL_DIV_EXPR] = "(ceiling /)"; | |
759 | opname_tab[(int) FLOOR_DIV_EXPR] = "(floor /)"; | |
760 | opname_tab[(int) ROUND_DIV_EXPR] = "(round /)"; | |
761 | opname_tab[(int) TRUNC_MOD_EXPR] = "%"; | |
762 | opname_tab[(int) CEIL_MOD_EXPR] = "(ceiling %)"; | |
763 | opname_tab[(int) FLOOR_MOD_EXPR] = "(floor %)"; | |
764 | opname_tab[(int) ROUND_MOD_EXPR] = "(round %)"; | |
765 | opname_tab[(int) NEGATE_EXPR] = "-"; | |
766 | opname_tab[(int) MIN_EXPR] = "<?"; | |
767 | opname_tab[(int) MAX_EXPR] = ">?"; | |
768 | opname_tab[(int) ABS_EXPR] = "abs"; | |
769 | opname_tab[(int) FFS_EXPR] = "ffs"; | |
770 | opname_tab[(int) LSHIFT_EXPR] = "<<"; | |
771 | opname_tab[(int) RSHIFT_EXPR] = ">>"; | |
772 | opname_tab[(int) BIT_IOR_EXPR] = "|"; | |
773 | opname_tab[(int) BIT_XOR_EXPR] = "^"; | |
774 | opname_tab[(int) BIT_AND_EXPR] = "&"; | |
775 | opname_tab[(int) BIT_ANDTC_EXPR] = "&~"; | |
776 | opname_tab[(int) BIT_NOT_EXPR] = "~"; | |
777 | opname_tab[(int) TRUTH_ANDIF_EXPR] = "&&"; | |
778 | opname_tab[(int) TRUTH_ORIF_EXPR] = "||"; | |
779 | opname_tab[(int) TRUTH_AND_EXPR] = "strict &&"; | |
780 | opname_tab[(int) TRUTH_OR_EXPR] = "strict ||"; | |
781 | opname_tab[(int) TRUTH_NOT_EXPR] = "!"; | |
782 | opname_tab[(int) LT_EXPR] = "<"; | |
783 | opname_tab[(int) LE_EXPR] = "<="; | |
784 | opname_tab[(int) GT_EXPR] = ">"; | |
785 | opname_tab[(int) GE_EXPR] = ">="; | |
786 | opname_tab[(int) EQ_EXPR] = "=="; | |
787 | opname_tab[(int) NE_EXPR] = "!="; | |
788 | opname_tab[(int) IN_EXPR] = "in"; | |
6467930b MS |
789 | opname_tab[(int) RANGE_EXPR] = "..."; |
790 | opname_tab[(int) CONVERT_EXPR] = "+"; | |
791 | opname_tab[(int) ADDR_EXPR] = "&"; | |
8d08fdba MS |
792 | opname_tab[(int) PREDECREMENT_EXPR] = "--"; |
793 | opname_tab[(int) PREINCREMENT_EXPR] = "++"; | |
794 | opname_tab[(int) POSTDECREMENT_EXPR] = "--"; | |
795 | opname_tab[(int) POSTINCREMENT_EXPR] = "++"; | |
796 | opname_tab[(int) COMPOUND_EXPR] = ","; | |
797 | ||
798 | assignop_tab[(int) NOP_EXPR] = "="; | |
799 | assignop_tab[(int) PLUS_EXPR] = "+="; | |
800 | assignop_tab[(int) CONVERT_EXPR] = "+="; | |
801 | assignop_tab[(int) MINUS_EXPR] = "-="; | |
802 | assignop_tab[(int) NEGATE_EXPR] = "-="; | |
803 | assignop_tab[(int) MULT_EXPR] = "*="; | |
804 | assignop_tab[(int) INDIRECT_REF] = "*="; | |
805 | assignop_tab[(int) TRUNC_DIV_EXPR] = "/="; | |
806 | assignop_tab[(int) EXACT_DIV_EXPR] = "(exact /=)"; | |
807 | assignop_tab[(int) CEIL_DIV_EXPR] = "(ceiling /=)"; | |
808 | assignop_tab[(int) FLOOR_DIV_EXPR] = "(floor /=)"; | |
809 | assignop_tab[(int) ROUND_DIV_EXPR] = "(round /=)"; | |
810 | assignop_tab[(int) TRUNC_MOD_EXPR] = "%="; | |
811 | assignop_tab[(int) CEIL_MOD_EXPR] = "(ceiling %=)"; | |
812 | assignop_tab[(int) FLOOR_MOD_EXPR] = "(floor %=)"; | |
813 | assignop_tab[(int) ROUND_MOD_EXPR] = "(round %=)"; | |
814 | assignop_tab[(int) MIN_EXPR] = "<?="; | |
815 | assignop_tab[(int) MAX_EXPR] = ">?="; | |
816 | assignop_tab[(int) LSHIFT_EXPR] = "<<="; | |
817 | assignop_tab[(int) RSHIFT_EXPR] = ">>="; | |
818 | assignop_tab[(int) BIT_IOR_EXPR] = "|="; | |
819 | assignop_tab[(int) BIT_XOR_EXPR] = "^="; | |
820 | assignop_tab[(int) BIT_AND_EXPR] = "&="; | |
821 | assignop_tab[(int) ADDR_EXPR] = "&="; | |
822 | ||
823 | init_filename_times (); | |
824 | ||
825 | /* Some options inhibit certain reserved words. | |
826 | Clear those words out of the hash table so they won't be recognized. */ | |
827 | #define UNSET_RESERVED_WORD(STRING) \ | |
828 | do { struct resword *s = is_reserved_word (STRING, sizeof (STRING) - 1); \ | |
829 | if (s) s->name = ""; } while (0) | |
830 | ||
8d2733ca MS |
831 | #if 0 |
832 | /* let's parse things, and if they use it, then give them an error. */ | |
6467930b | 833 | if (!flag_exceptions) |
8d08fdba | 834 | { |
8d2733ca MS |
835 | UNSET_RESERVED_WORD ("throw"); |
836 | UNSET_RESERVED_WORD ("try"); | |
8d08fdba MS |
837 | UNSET_RESERVED_WORD ("catch"); |
838 | } | |
8d2733ca | 839 | #endif |
8d08fdba | 840 | |
9e9ff709 | 841 | if (!flag_rtti || flag_no_gnu_keywords) |
8d08fdba MS |
842 | { |
843 | UNSET_RESERVED_WORD ("classof"); | |
844 | UNSET_RESERVED_WORD ("headof"); | |
845 | } | |
e1cd6e56 | 846 | if (! flag_handle_signatures || flag_no_gnu_keywords) |
8d08fdba MS |
847 | { |
848 | /* Easiest way to not recognize signature | |
849 | handling extensions... */ | |
850 | UNSET_RESERVED_WORD ("signature"); | |
851 | UNSET_RESERVED_WORD ("sigof"); | |
852 | } | |
e1cd6e56 | 853 | if (flag_no_asm || flag_no_gnu_keywords) |
8d08fdba | 854 | UNSET_RESERVED_WORD ("typeof"); |
e1cd6e56 | 855 | if (! flag_operator_names) |
db5ae43f MS |
856 | { |
857 | /* These are new ANSI keywords that may break code. */ | |
858 | UNSET_RESERVED_WORD ("and"); | |
79ff2c6c | 859 | UNSET_RESERVED_WORD ("and_eq"); |
db5ae43f MS |
860 | UNSET_RESERVED_WORD ("bitand"); |
861 | UNSET_RESERVED_WORD ("bitor"); | |
862 | UNSET_RESERVED_WORD ("compl"); | |
863 | UNSET_RESERVED_WORD ("not"); | |
79ff2c6c | 864 | UNSET_RESERVED_WORD ("not_eq"); |
db5ae43f | 865 | UNSET_RESERVED_WORD ("or"); |
79ff2c6c | 866 | UNSET_RESERVED_WORD ("or_eq"); |
db5ae43f | 867 | UNSET_RESERVED_WORD ("xor"); |
79ff2c6c | 868 | UNSET_RESERVED_WORD ("xor_eq"); |
db5ae43f | 869 | } |
8d08fdba MS |
870 | |
871 | token_count = init_parse (); | |
872 | interface_unknown = 1; | |
873 | } | |
874 | ||
875 | void | |
876 | reinit_parse_for_function () | |
877 | { | |
878 | current_base_init_list = NULL_TREE; | |
879 | current_member_init_list = NULL_TREE; | |
880 | } | |
881 | \f | |
882 | #ifdef __GNUC__ | |
883 | __inline | |
884 | #endif | |
885 | void | |
886 | yyprint (file, yychar, yylval) | |
887 | FILE *file; | |
888 | int yychar; | |
889 | YYSTYPE yylval; | |
890 | { | |
891 | tree t; | |
892 | switch (yychar) | |
893 | { | |
894 | case IDENTIFIER: | |
895 | case TYPENAME: | |
896 | case TYPESPEC: | |
897 | case PTYPENAME: | |
898 | case IDENTIFIER_DEFN: | |
899 | case TYPENAME_DEFN: | |
900 | case PTYPENAME_DEFN: | |
8d08fdba | 901 | case TYPENAME_ELLIPSIS: |
8d08fdba MS |
902 | case SCSPEC: |
903 | case PRE_PARSED_CLASS_DECL: | |
904 | t = yylval.ttype; | |
fc378698 MS |
905 | if (TREE_CODE (t) == TYPE_DECL) |
906 | { | |
907 | fprintf (file, " `%s'", DECL_NAME (t)); | |
908 | break; | |
909 | } | |
8d08fdba MS |
910 | my_friendly_assert (TREE_CODE (t) == IDENTIFIER_NODE, 224); |
911 | if (IDENTIFIER_POINTER (t)) | |
912 | fprintf (file, " `%s'", IDENTIFIER_POINTER (t)); | |
913 | break; | |
914 | case AGGR: | |
915 | if (yylval.ttype == class_type_node) | |
916 | fprintf (file, " `class'"); | |
917 | else if (yylval.ttype == record_type_node) | |
918 | fprintf (file, " `struct'"); | |
919 | else if (yylval.ttype == union_type_node) | |
920 | fprintf (file, " `union'"); | |
921 | else if (yylval.ttype == enum_type_node) | |
922 | fprintf (file, " `enum'"); | |
923 | else if (yylval.ttype == signature_type_node) | |
924 | fprintf (file, " `signature'"); | |
925 | else | |
926 | my_friendly_abort (80); | |
927 | break; | |
928 | } | |
929 | } | |
930 | ||
5566b478 | 931 | #if defined(GATHER_STATISTICS) && defined(REDUCE_LENGTH) |
8d08fdba | 932 | static int *reduce_count; |
5566b478 MS |
933 | #endif |
934 | ||
8d08fdba MS |
935 | int *token_count; |
936 | ||
72b7eeff | 937 | #if 0 |
8d08fdba MS |
938 | #define REDUCE_LENGTH (sizeof (yyr2) / sizeof (yyr2[0])) |
939 | #define TOKEN_LENGTH (256 + sizeof (yytname) / sizeof (yytname[0])) | |
72b7eeff | 940 | #endif |
8d08fdba MS |
941 | |
942 | int * | |
943 | init_parse () | |
944 | { | |
945 | #ifdef GATHER_STATISTICS | |
72b7eeff | 946 | #ifdef REDUCE_LENGTH |
8d08fdba MS |
947 | reduce_count = (int *)malloc (sizeof (int) * (REDUCE_LENGTH + 1)); |
948 | bzero (reduce_count, sizeof (int) * (REDUCE_LENGTH + 1)); | |
949 | reduce_count += 1; | |
950 | token_count = (int *)malloc (sizeof (int) * (TOKEN_LENGTH + 1)); | |
951 | bzero (token_count, sizeof (int) * (TOKEN_LENGTH + 1)); | |
952 | token_count += 1; | |
72b7eeff | 953 | #endif |
8d08fdba MS |
954 | #endif |
955 | return token_count; | |
956 | } | |
957 | ||
958 | #ifdef GATHER_STATISTICS | |
72b7eeff | 959 | #ifdef REDUCE_LENGTH |
8d08fdba MS |
960 | void |
961 | yyhook (yyn) | |
962 | int yyn; | |
963 | { | |
964 | reduce_count[yyn] += 1; | |
965 | } | |
8d08fdba MS |
966 | |
967 | static int | |
968 | reduce_cmp (p, q) | |
969 | int *p, *q; | |
970 | { | |
971 | return reduce_count[*q] - reduce_count[*p]; | |
972 | } | |
973 | ||
974 | static int | |
975 | token_cmp (p, q) | |
976 | int *p, *q; | |
977 | { | |
978 | return token_count[*q] - token_count[*p]; | |
979 | } | |
8926095f | 980 | #endif |
72b7eeff | 981 | #endif |
8d08fdba MS |
982 | |
983 | void | |
984 | print_parse_statistics () | |
985 | { | |
986 | #ifdef GATHER_STATISTICS | |
72b7eeff | 987 | #ifdef REDUCE_LENGTH |
8d08fdba MS |
988 | #if YYDEBUG != 0 |
989 | int i; | |
990 | int maxlen = REDUCE_LENGTH; | |
991 | unsigned *sorted; | |
992 | ||
993 | if (reduce_count[-1] == 0) | |
994 | return; | |
995 | ||
996 | if (TOKEN_LENGTH > REDUCE_LENGTH) | |
997 | maxlen = TOKEN_LENGTH; | |
998 | sorted = (unsigned *) alloca (sizeof (int) * maxlen); | |
999 | ||
1000 | for (i = 0; i < TOKEN_LENGTH; i++) | |
1001 | sorted[i] = i; | |
1002 | qsort (sorted, TOKEN_LENGTH, sizeof (int), token_cmp); | |
1003 | for (i = 0; i < TOKEN_LENGTH; i++) | |
1004 | { | |
e92cc029 MS |
1005 | int idx = sorted[i]; |
1006 | if (token_count[idx] == 0) | |
8d08fdba | 1007 | break; |
e92cc029 | 1008 | if (token_count[idx] < token_count[-1]) |
8d08fdba MS |
1009 | break; |
1010 | fprintf (stderr, "token %d, `%s', count = %d\n", | |
e92cc029 | 1011 | idx, yytname[YYTRANSLATE (idx)], token_count[idx]); |
8d08fdba MS |
1012 | } |
1013 | fprintf (stderr, "\n"); | |
1014 | for (i = 0; i < REDUCE_LENGTH; i++) | |
1015 | sorted[i] = i; | |
1016 | qsort (sorted, REDUCE_LENGTH, sizeof (int), reduce_cmp); | |
1017 | for (i = 0; i < REDUCE_LENGTH; i++) | |
1018 | { | |
e92cc029 MS |
1019 | int idx = sorted[i]; |
1020 | if (reduce_count[idx] == 0) | |
8d08fdba | 1021 | break; |
e92cc029 | 1022 | if (reduce_count[idx] < reduce_count[-1]) |
8d08fdba MS |
1023 | break; |
1024 | fprintf (stderr, "rule %d, line %d, count = %d\n", | |
e92cc029 | 1025 | idx, yyrline[idx], reduce_count[idx]); |
8d08fdba MS |
1026 | } |
1027 | fprintf (stderr, "\n"); | |
1028 | #endif | |
1029 | #endif | |
72b7eeff | 1030 | #endif |
8d08fdba MS |
1031 | } |
1032 | ||
1033 | /* Sets the value of the 'yydebug' variable to VALUE. | |
1034 | This is a function so we don't have to have YYDEBUG defined | |
1035 | in order to build the compiler. */ | |
e92cc029 | 1036 | |
8d08fdba MS |
1037 | void |
1038 | set_yydebug (value) | |
1039 | int value; | |
1040 | { | |
1041 | #if YYDEBUG != 0 | |
1042 | extern int yydebug; | |
1043 | yydebug = value; | |
1044 | #else | |
1045 | warning ("YYDEBUG not defined."); | |
1046 | #endif | |
1047 | } | |
1048 | ||
8d08fdba MS |
1049 | \f |
1050 | /* Functions and data structures for #pragma interface. | |
1051 | ||
1052 | `#pragma implementation' means that the main file being compiled | |
1053 | is considered to implement (provide) the classes that appear in | |
1054 | its main body. I.e., if this is file "foo.cc", and class `bar' | |
1055 | is defined in "foo.cc", then we say that "foo.cc implements bar". | |
1056 | ||
1057 | All main input files "implement" themselves automagically. | |
1058 | ||
1059 | `#pragma interface' means that unless this file (of the form "foo.h" | |
1060 | is not presently being included by file "foo.cc", the | |
1061 | CLASSTYPE_INTERFACE_ONLY bit gets set. The effect is that none | |
1062 | of the vtables nor any of the inline functions defined in foo.h | |
1063 | will ever be output. | |
1064 | ||
1065 | There are cases when we want to link files such as "defs.h" and | |
1066 | "main.cc". In this case, we give "defs.h" a `#pragma interface', | |
1067 | and "main.cc" has `#pragma implementation "defs.h"'. */ | |
1068 | ||
1069 | struct impl_files | |
1070 | { | |
1071 | char *filename; | |
1072 | struct impl_files *next; | |
1073 | }; | |
1074 | ||
1075 | static struct impl_files *impl_file_chain; | |
1076 | ||
1077 | /* Helper function to load global variables with interface | |
1078 | information. */ | |
e92cc029 | 1079 | |
8d08fdba MS |
1080 | void |
1081 | extract_interface_info () | |
1082 | { | |
1083 | tree fileinfo = 0; | |
1084 | ||
1085 | if (flag_alt_external_templates) | |
1086 | { | |
1087 | struct tinst_level *til = tinst_for_decl (); | |
1088 | ||
1089 | if (til) | |
1090 | fileinfo = get_time_identifier (til->file); | |
1091 | } | |
1092 | if (!fileinfo) | |
1093 | fileinfo = get_time_identifier (input_filename); | |
1094 | fileinfo = IDENTIFIER_CLASS_VALUE (fileinfo); | |
1095 | interface_only = TREE_INT_CST_LOW (fileinfo); | |
5566b478 | 1096 | interface_unknown = TREE_INT_CST_HIGH (fileinfo); |
8d08fdba MS |
1097 | } |
1098 | ||
51c184be | 1099 | /* Return nonzero if S is not considered part of an |
8d08fdba | 1100 | INTERFACE/IMPLEMENTATION pair. Otherwise, return 0. */ |
e92cc029 | 1101 | |
8d08fdba MS |
1102 | static int |
1103 | interface_strcmp (s) | |
1104 | char *s; | |
1105 | { | |
1106 | /* Set the interface/implementation bits for this scope. */ | |
1107 | struct impl_files *ifiles; | |
1108 | char *s1; | |
1109 | ||
8d08fdba MS |
1110 | for (ifiles = impl_file_chain; ifiles; ifiles = ifiles->next) |
1111 | { | |
1112 | char *t1 = ifiles->filename; | |
1113 | s1 = s; | |
1114 | ||
1115 | if (*s1 != *t1 || *s1 == 0) | |
1116 | continue; | |
1117 | ||
1118 | while (*s1 == *t1 && *s1 != 0) | |
1119 | s1++, t1++; | |
1120 | ||
1121 | /* A match. */ | |
1122 | if (*s1 == *t1) | |
1123 | return 0; | |
1124 | ||
1125 | /* Don't get faked out by xxx.yyy.cc vs xxx.zzz.cc. */ | |
1126 | if (index (s1, '.') || index (t1, '.')) | |
1127 | continue; | |
1128 | ||
1129 | if (*s1 == '\0' || s1[-1] != '.' || t1[-1] != '.') | |
1130 | continue; | |
1131 | ||
1132 | /* A match. */ | |
1133 | return 0; | |
1134 | } | |
1135 | ||
1136 | /* No matches. */ | |
1137 | return 1; | |
1138 | } | |
1139 | ||
bd6dd845 | 1140 | static void |
8d08fdba MS |
1141 | set_typedecl_interface_info (prev, vars) |
1142 | tree prev, vars; | |
1143 | { | |
1144 | tree id = get_time_identifier (DECL_SOURCE_FILE (vars)); | |
1145 | tree fileinfo = IDENTIFIER_CLASS_VALUE (id); | |
1146 | tree type = TREE_TYPE (vars); | |
1147 | ||
1148 | CLASSTYPE_INTERFACE_ONLY (type) = TREE_INT_CST_LOW (fileinfo) | |
b2bb2710 | 1149 | = interface_strcmp (file_name_nondirectory (DECL_SOURCE_FILE (vars))); |
8d08fdba MS |
1150 | } |
1151 | ||
bd6dd845 | 1152 | static int |
8d08fdba MS |
1153 | set_vardecl_interface_info (prev, vars) |
1154 | tree prev, vars; | |
1155 | { | |
1156 | tree type = DECL_CONTEXT (vars); | |
1157 | ||
1158 | if (CLASSTYPE_INTERFACE_KNOWN (type)) | |
1159 | { | |
1160 | if (CLASSTYPE_INTERFACE_ONLY (type)) | |
d2e5ee5c | 1161 | set_typedecl_interface_info (prev, TYPE_MAIN_DECL (type)); |
8d08fdba MS |
1162 | else |
1163 | CLASSTYPE_VTABLE_NEEDS_WRITING (type) = 1; | |
1164 | DECL_EXTERNAL (vars) = CLASSTYPE_INTERFACE_ONLY (type); | |
1165 | TREE_PUBLIC (vars) = 1; | |
fc378698 | 1166 | return 1; |
8d08fdba | 1167 | } |
fc378698 | 1168 | return 0; |
8d08fdba MS |
1169 | } |
1170 | \f | |
1171 | /* Called from the top level: if there are any pending inlines to | |
1172 | do, set up to process them now. This function sets up the first function | |
51c184be | 1173 | to be parsed; after it has been, the rule for fndef in parse.y will |
8d08fdba | 1174 | call process_next_inline to start working on the next one. */ |
e92cc029 | 1175 | |
8d08fdba MS |
1176 | void |
1177 | do_pending_inlines () | |
1178 | { | |
8d08fdba | 1179 | struct pending_inline *t; |
5566b478 | 1180 | tree context; |
8d08fdba MS |
1181 | |
1182 | /* Oops, we're still dealing with the last batch. */ | |
1183 | if (yychar == PRE_PARSED_FUNCTION_DECL) | |
1184 | return; | |
f376e137 | 1185 | |
8d08fdba MS |
1186 | /* Reverse the pending inline functions, since |
1187 | they were cons'd instead of appended. */ | |
f376e137 | 1188 | { |
9e9ff709 | 1189 | struct pending_inline *prev = 0, *tail; |
f376e137 MS |
1190 | t = pending_inlines; |
1191 | pending_inlines = 0; | |
1192 | ||
1193 | for (; t; t = tail) | |
1194 | { | |
1195 | tail = t->next; | |
eac293a1 MS |
1196 | t->next = prev; |
1197 | t->deja_vu = 1; | |
1198 | prev = t; | |
1199 | } | |
f376e137 MS |
1200 | t = prev; |
1201 | } | |
1202 | ||
1203 | if (t == 0) | |
1204 | return; | |
1205 | ||
8d08fdba | 1206 | /* Now start processing the first inline function. */ |
e76a2646 | 1207 | context = hack_decl_function_context (t->fndecl); |
5566b478 MS |
1208 | if (context) |
1209 | push_cp_function_context (context); | |
98c1c668 | 1210 | if (is_member_template (t->fndecl)) |
786b5245 | 1211 | begin_member_template_processing (t->fndecl); |
8d08fdba MS |
1212 | if (t->len > 0) |
1213 | { | |
42976354 | 1214 | feed_input (t->buf, t->len); |
8d08fdba MS |
1215 | lineno = t->lineno; |
1216 | #if 0 | |
1217 | if (input_filename != t->filename) | |
1218 | { | |
1219 | input_filename = t->filename; | |
1220 | /* Get interface/implementation back in sync. */ | |
1221 | extract_interface_info (); | |
1222 | } | |
1223 | #else | |
1224 | input_filename = t->filename; | |
1225 | interface_unknown = t->interface == 1; | |
1226 | interface_only = t->interface == 0; | |
1227 | #endif | |
1228 | yychar = PRE_PARSED_FUNCTION_DECL; | |
1229 | } | |
1230 | /* Pass back a handle on the rest of the inline functions, so that they | |
1231 | can be processed later. */ | |
1232 | yylval.ttype = build_tree_list ((tree) t, t->fndecl); | |
8d08fdba MS |
1233 | DECL_PENDING_INLINE_INFO (t->fndecl) = 0; |
1234 | } | |
1235 | ||
8d08fdba MS |
1236 | static int nextchar = -1; |
1237 | ||
1238 | /* Called from the fndecl rule in the parser when the function just parsed | |
1239 | was declared using a PRE_PARSED_FUNCTION_DECL (i.e. came from | |
1240 | do_pending_inlines). */ | |
e92cc029 | 1241 | |
8d08fdba MS |
1242 | void |
1243 | process_next_inline (t) | |
1244 | tree t; | |
1245 | { | |
5566b478 | 1246 | tree context; |
8d08fdba | 1247 | struct pending_inline *i = (struct pending_inline *) TREE_PURPOSE (t); |
98c1c668 JM |
1248 | context = hack_decl_function_context (i->fndecl); |
1249 | if (is_member_template (i->fndecl)) | |
1250 | end_member_template_processing (); | |
5566b478 MS |
1251 | if (context) |
1252 | pop_cp_function_context (context); | |
8d08fdba MS |
1253 | i = i->next; |
1254 | if (yychar == YYEMPTY) | |
1255 | yychar = yylex (); | |
1256 | if (yychar != END_OF_SAVED_INPUT) | |
1257 | { | |
1258 | error ("parse error at end of saved function text"); | |
e92cc029 | 1259 | |
8d08fdba | 1260 | /* restore_pending_input will abort unless yychar is either |
e92cc029 MS |
1261 | END_OF_SAVED_INPUT or YYEMPTY; since we already know we're |
1262 | hosed, feed back YYEMPTY. We also need to discard nextchar, | |
1263 | since that may have gotten set as well. */ | |
8d08fdba MS |
1264 | nextchar = -1; |
1265 | } | |
1266 | yychar = YYEMPTY; | |
42976354 | 1267 | end_input (); |
8d08fdba MS |
1268 | if (i && i->fndecl != NULL_TREE) |
1269 | { | |
e76a2646 | 1270 | context = hack_decl_function_context (i->fndecl); |
5566b478 MS |
1271 | if (context) |
1272 | push_cp_function_context (context); | |
98c1c668 | 1273 | if (is_member_template (i->fndecl)) |
786b5245 | 1274 | begin_member_template_processing (i->fndecl); |
42976354 | 1275 | feed_input (i->buf, i->len); |
8d08fdba MS |
1276 | lineno = i->lineno; |
1277 | input_filename = i->filename; | |
1278 | yychar = PRE_PARSED_FUNCTION_DECL; | |
1279 | yylval.ttype = build_tree_list ((tree) i, i->fndecl); | |
8d08fdba MS |
1280 | DECL_PENDING_INLINE_INFO (i->fndecl) = 0; |
1281 | } | |
1282 | if (i) | |
1283 | { | |
1284 | interface_unknown = i->interface == 1; | |
1285 | interface_only = i->interface == 0; | |
1286 | } | |
1287 | else | |
1288 | extract_interface_info (); | |
1289 | } | |
1290 | ||
1291 | /* Since inline methods can refer to text which has not yet been seen, | |
1292 | we store the text of the method in a structure which is placed in the | |
1293 | DECL_PENDING_INLINE_INFO field of the FUNCTION_DECL. | |
1294 | After parsing the body of the class definition, the FUNCTION_DECL's are | |
1295 | scanned to see which ones have this field set. Those are then digested | |
1296 | one at a time. | |
1297 | ||
1298 | This function's FUNCTION_DECL will have a bit set in its common so | |
1299 | that we know to watch out for it. */ | |
1300 | ||
1301 | static void | |
1302 | consume_string (this_obstack, matching_char) | |
1303 | register struct obstack *this_obstack; | |
1304 | int matching_char; | |
1305 | { | |
1306 | register int c; | |
1307 | int starting_lineno = lineno; | |
1308 | do | |
1309 | { | |
1310 | c = getch (); | |
1311 | if (c == EOF) | |
1312 | { | |
1313 | int save_lineno = lineno; | |
1314 | lineno = starting_lineno; | |
1315 | if (matching_char == '"') | |
1316 | error ("end of file encountered inside string constant"); | |
1317 | else | |
1318 | error ("end of file encountered inside character constant"); | |
1319 | lineno = save_lineno; | |
1320 | return; | |
1321 | } | |
1322 | if (c == '\\') | |
1323 | { | |
1324 | obstack_1grow (this_obstack, c); | |
1325 | c = getch (); | |
1326 | obstack_1grow (this_obstack, c); | |
1327 | ||
1328 | /* Make sure we continue the loop */ | |
1329 | c = 0; | |
1330 | continue; | |
1331 | } | |
1332 | if (c == '\n') | |
1333 | { | |
1334 | if (pedantic) | |
1335 | pedwarn ("ANSI C++ forbids newline in string constant"); | |
1336 | lineno++; | |
1337 | } | |
1338 | obstack_1grow (this_obstack, c); | |
1339 | } | |
1340 | while (c != matching_char); | |
1341 | } | |
1342 | ||
1343 | static int nextyychar = YYEMPTY; | |
1344 | static YYSTYPE nextyylval; | |
1345 | ||
1346 | struct pending_input { | |
1347 | int nextchar, yychar, nextyychar, eof; | |
1348 | YYSTYPE yylval, nextyylval; | |
1349 | struct obstack token_obstack; | |
1350 | int first_token; | |
1351 | }; | |
1352 | ||
1353 | struct pending_input * | |
1354 | save_pending_input () | |
1355 | { | |
1356 | struct pending_input *p; | |
1357 | p = (struct pending_input *) xmalloc (sizeof (struct pending_input)); | |
1358 | p->nextchar = nextchar; | |
1359 | p->yychar = yychar; | |
1360 | p->nextyychar = nextyychar; | |
1361 | p->yylval = yylval; | |
1362 | p->nextyylval = nextyylval; | |
1363 | p->eof = end_of_file; | |
1364 | yychar = nextyychar = YYEMPTY; | |
1365 | nextchar = -1; | |
1366 | p->first_token = first_token; | |
1367 | p->token_obstack = token_obstack; | |
1368 | ||
1369 | first_token = 0; | |
1370 | gcc_obstack_init (&token_obstack); | |
1371 | end_of_file = 0; | |
1372 | return p; | |
1373 | } | |
1374 | ||
1375 | void | |
1376 | restore_pending_input (p) | |
1377 | struct pending_input *p; | |
1378 | { | |
1379 | my_friendly_assert (nextchar == -1, 229); | |
1380 | nextchar = p->nextchar; | |
1381 | my_friendly_assert (yychar == YYEMPTY || yychar == END_OF_SAVED_INPUT, 230); | |
1382 | yychar = p->yychar; | |
1383 | my_friendly_assert (nextyychar == YYEMPTY, 231); | |
1384 | nextyychar = p->nextyychar; | |
1385 | yylval = p->yylval; | |
1386 | nextyylval = p->nextyylval; | |
1387 | first_token = p->first_token; | |
1388 | obstack_free (&token_obstack, (char *) 0); | |
1389 | token_obstack = p->token_obstack; | |
1390 | end_of_file = p->eof; | |
1391 | free (p); | |
1392 | } | |
1393 | ||
1394 | /* Return next non-whitespace input character, which may come | |
1395 | from `finput', or from `nextchar'. */ | |
e92cc029 | 1396 | |
8d08fdba MS |
1397 | static int |
1398 | yynextch () | |
1399 | { | |
1400 | int c; | |
1401 | ||
1402 | if (nextchar >= 0) | |
1403 | { | |
1404 | c = nextchar; | |
1405 | nextchar = -1; | |
1406 | } | |
1407 | else c = getch (); | |
1408 | return skip_white_space (c); | |
1409 | } | |
1410 | ||
1411 | /* Unget character CH from the input stream. | |
1412 | If RESCAN is non-zero, then we want to `see' this | |
1413 | character as the next input token. */ | |
e92cc029 | 1414 | |
8d08fdba MS |
1415 | void |
1416 | yyungetc (ch, rescan) | |
1417 | int ch; | |
1418 | int rescan; | |
1419 | { | |
1420 | /* Unget a character from the input stream. */ | |
1421 | if (yychar == YYEMPTY || rescan == 0) | |
1422 | { | |
1423 | if (nextchar >= 0) | |
1424 | put_back (nextchar); | |
1425 | nextchar = ch; | |
1426 | } | |
1427 | else | |
1428 | { | |
1429 | my_friendly_assert (nextyychar == YYEMPTY, 232); | |
1430 | nextyychar = yychar; | |
1431 | nextyylval = yylval; | |
1432 | yychar = ch; | |
1433 | } | |
1434 | } | |
1435 | ||
42976354 BK |
1436 | void |
1437 | clear_inline_text_obstack () | |
1438 | { | |
1439 | obstack_free (&inline_text_obstack, inline_text_firstobj); | |
1440 | } | |
1441 | ||
8d08fdba MS |
1442 | /* This function stores away the text for an inline function that should |
1443 | be processed later. It decides how much later, and may need to move | |
1444 | the info between obstacks; therefore, the caller should not refer to | |
5566b478 | 1445 | the T parameter after calling this function. */ |
8d08fdba MS |
1446 | |
1447 | static void | |
1448 | store_pending_inline (decl, t) | |
1449 | tree decl; | |
1450 | struct pending_inline *t; | |
1451 | { | |
8d08fdba | 1452 | t->fndecl = decl; |
5566b478 | 1453 | DECL_PENDING_INLINE_INFO (decl) = t; |
8d08fdba MS |
1454 | |
1455 | /* Because we use obstacks, we must process these in precise order. */ | |
5566b478 MS |
1456 | t->next = pending_inlines; |
1457 | pending_inlines = t; | |
8d08fdba MS |
1458 | } |
1459 | ||
8d08fdba MS |
1460 | void |
1461 | reinit_parse_for_method (yychar, decl) | |
1462 | int yychar; | |
1463 | tree decl; | |
1464 | { | |
1465 | int len; | |
1466 | int starting_lineno = lineno; | |
1467 | char *starting_filename = input_filename; | |
1468 | ||
5566b478 | 1469 | reinit_parse_for_block (yychar, &inline_text_obstack); |
8d08fdba MS |
1470 | |
1471 | len = obstack_object_size (&inline_text_obstack); | |
1472 | current_base_init_list = NULL_TREE; | |
1473 | current_member_init_list = NULL_TREE; | |
1474 | if (decl == void_type_node | |
1475 | || (current_class_type && TYPE_REDEFINED (current_class_type))) | |
1476 | { | |
1477 | /* Happens when we get two declarations of the same | |
1478 | function in the same scope. */ | |
1479 | char *buf = obstack_finish (&inline_text_obstack); | |
1480 | obstack_free (&inline_text_obstack, buf); | |
1481 | return; | |
1482 | } | |
1483 | else | |
1484 | { | |
1485 | struct pending_inline *t; | |
1486 | char *buf = obstack_finish (&inline_text_obstack); | |
1487 | ||
1488 | t = (struct pending_inline *) obstack_alloc (&inline_text_obstack, | |
1489 | sizeof (struct pending_inline)); | |
1490 | t->lineno = starting_lineno; | |
1491 | t->filename = starting_filename; | |
1492 | t->token = YYEMPTY; | |
1493 | t->token_value = 0; | |
1494 | t->buf = buf; | |
1495 | t->len = len; | |
8d08fdba | 1496 | t->deja_vu = 0; |
5566b478 | 1497 | #if 0 |
8d08fdba | 1498 | if (interface_unknown && processing_template_defn && flag_external_templates && ! DECL_IN_SYSTEM_HEADER (decl)) |
8ccc31eb | 1499 | warn_if_unknown_interface (decl); |
5566b478 | 1500 | #endif |
8d08fdba MS |
1501 | t->interface = (interface_unknown ? 1 : (interface_only ? 0 : 2)); |
1502 | store_pending_inline (decl, t); | |
1503 | } | |
1504 | } | |
1505 | ||
5566b478 MS |
1506 | /* Consume a block -- actually, a method beginning |
1507 | with `:' or `{' -- and save it away on the specified obstack. */ | |
8d08fdba | 1508 | |
49c249e1 | 1509 | void |
5566b478 | 1510 | reinit_parse_for_block (pyychar, obstackp) |
f30432d7 | 1511 | int pyychar; |
8d08fdba | 1512 | struct obstack *obstackp; |
8d08fdba MS |
1513 | { |
1514 | register int c = 0; | |
1515 | int blev = 1; | |
1516 | int starting_lineno = lineno; | |
1517 | char *starting_filename = input_filename; | |
1518 | int len; | |
1519 | int look_for_semicolon = 0; | |
1520 | int look_for_lbrac = 0; | |
1521 | ||
f30432d7 | 1522 | if (pyychar == '{') |
8d08fdba | 1523 | obstack_1grow (obstackp, '{'); |
f30432d7 | 1524 | else if (pyychar == '=') |
8d08fdba | 1525 | look_for_semicolon = 1; |
f30432d7 | 1526 | else if (pyychar == ':') |
8d08fdba | 1527 | { |
f30432d7 MS |
1528 | obstack_1grow (obstackp, pyychar); |
1529 | look_for_lbrac = 1; | |
1530 | blev = 0; | |
8d08fdba | 1531 | } |
5566b478 | 1532 | else if (pyychar == RETURN) |
f30432d7 MS |
1533 | { |
1534 | obstack_grow (obstackp, "return", 6); | |
1535 | look_for_lbrac = 1; | |
1536 | blev = 0; | |
1537 | } | |
5566b478 | 1538 | else if (pyychar == TRY) |
8d08fdba | 1539 | { |
f30432d7 | 1540 | obstack_grow (obstackp, "try", 3); |
8d08fdba MS |
1541 | look_for_lbrac = 1; |
1542 | blev = 0; | |
1543 | } | |
f30432d7 MS |
1544 | else |
1545 | { | |
5566b478 | 1546 | yyerror ("parse error in method specification"); |
f30432d7 MS |
1547 | obstack_1grow (obstackp, '{'); |
1548 | } | |
8d08fdba MS |
1549 | |
1550 | if (nextchar != EOF) | |
1551 | { | |
1552 | c = nextchar; | |
1553 | nextchar = EOF; | |
1554 | } | |
1555 | else | |
1556 | c = getch (); | |
1557 | ||
1558 | while (c != EOF) | |
1559 | { | |
1560 | int this_lineno = lineno; | |
1561 | ||
1562 | c = skip_white_space (c); | |
1563 | ||
1564 | /* Don't lose our cool if there are lots of comments. */ | |
1565 | if (lineno == this_lineno + 1) | |
1566 | obstack_1grow (obstackp, '\n'); | |
1567 | else if (lineno == this_lineno) | |
1568 | ; | |
1569 | else if (lineno - this_lineno < 10) | |
1570 | { | |
1571 | int i; | |
1572 | for (i = lineno - this_lineno; i > 0; i--) | |
1573 | obstack_1grow (obstackp, '\n'); | |
1574 | } | |
1575 | else | |
1576 | { | |
1577 | char buf[16]; | |
1578 | sprintf (buf, "\n# %d \"", lineno); | |
1579 | len = strlen (buf); | |
1580 | obstack_grow (obstackp, buf, len); | |
1581 | ||
1582 | len = strlen (input_filename); | |
1583 | obstack_grow (obstackp, input_filename, len); | |
1584 | obstack_1grow (obstackp, '\"'); | |
1585 | obstack_1grow (obstackp, '\n'); | |
1586 | } | |
1587 | ||
1588 | while (c > ' ') /* ASCII dependent... */ | |
1589 | { | |
1590 | obstack_1grow (obstackp, c); | |
1591 | if (c == '{') | |
1592 | { | |
1593 | look_for_lbrac = 0; | |
1594 | blev++; | |
1595 | } | |
1596 | else if (c == '}') | |
1597 | { | |
1598 | blev--; | |
1599 | if (blev == 0 && !look_for_semicolon) | |
f30432d7 MS |
1600 | { |
1601 | if (pyychar == TRY) | |
1602 | { | |
1603 | if (peekyylex () == CATCH) | |
1604 | { | |
1605 | yylex (); | |
1606 | obstack_grow (obstackp, " catch ", 7); | |
1607 | look_for_lbrac = 1; | |
1608 | } | |
1609 | else | |
1610 | { | |
1611 | yychar = '{'; | |
1612 | goto done; | |
1613 | } | |
1614 | } | |
1615 | else | |
1616 | { | |
1617 | goto done; | |
1618 | } | |
1619 | } | |
8d08fdba MS |
1620 | } |
1621 | else if (c == '\\') | |
1622 | { | |
1623 | /* Don't act on the next character...e.g, doing an escaped | |
1624 | double-quote. */ | |
1625 | c = getch (); | |
1626 | if (c == EOF) | |
1627 | { | |
1628 | error_with_file_and_line (starting_filename, | |
1629 | starting_lineno, | |
1630 | "end of file read inside definition"); | |
1631 | goto done; | |
1632 | } | |
1633 | obstack_1grow (obstackp, c); | |
1634 | } | |
1635 | else if (c == '\"') | |
1636 | consume_string (obstackp, c); | |
1637 | else if (c == '\'') | |
1638 | consume_string (obstackp, c); | |
1639 | else if (c == ';') | |
1640 | { | |
1641 | if (look_for_lbrac) | |
1642 | { | |
5566b478 | 1643 | error ("function body for constructor missing"); |
8d08fdba MS |
1644 | obstack_1grow (obstackp, '{'); |
1645 | obstack_1grow (obstackp, '}'); | |
1646 | len += 2; | |
1647 | goto done; | |
1648 | } | |
1649 | else if (look_for_semicolon && blev == 0) | |
1650 | goto done; | |
1651 | } | |
1652 | c = getch (); | |
1653 | } | |
1654 | ||
1655 | if (c == EOF) | |
1656 | { | |
1657 | error_with_file_and_line (starting_filename, | |
1658 | starting_lineno, | |
1659 | "end of file read inside definition"); | |
1660 | goto done; | |
1661 | } | |
1662 | else if (c != '\n') | |
1663 | { | |
1664 | obstack_1grow (obstackp, c); | |
1665 | c = getch (); | |
1666 | } | |
1667 | } | |
1668 | done: | |
1669 | obstack_1grow (obstackp, '\0'); | |
1670 | } | |
1671 | ||
42976354 BK |
1672 | /* Consume a no-commas expression -- actually, a default argument -- and |
1673 | save it away on the specified obstack. */ | |
1674 | ||
1675 | static void | |
1676 | reinit_parse_for_expr (obstackp) | |
1677 | struct obstack *obstackp; | |
1678 | { | |
1679 | register int c = 0; | |
1680 | int starting_lineno = lineno; | |
1681 | char *starting_filename = input_filename; | |
1682 | int len; | |
1683 | int look_for_semicolon = 0; | |
1684 | int look_for_lbrac = 0; | |
1685 | int plev = 0; | |
1686 | ||
1687 | if (nextchar != EOF) | |
1688 | { | |
1689 | c = nextchar; | |
1690 | nextchar = EOF; | |
1691 | } | |
1692 | else | |
1693 | c = getch (); | |
1694 | ||
1695 | while (c != EOF) | |
1696 | { | |
1697 | int this_lineno = lineno; | |
1698 | ||
1699 | c = skip_white_space (c); | |
1700 | ||
1701 | /* Don't lose our cool if there are lots of comments. */ | |
1702 | if (lineno == this_lineno + 1) | |
1703 | obstack_1grow (obstackp, '\n'); | |
1704 | else if (lineno == this_lineno) | |
1705 | ; | |
1706 | else if (lineno - this_lineno < 10) | |
1707 | { | |
1708 | int i; | |
1709 | for (i = lineno - this_lineno; i > 0; --i) | |
1710 | obstack_1grow (obstackp, '\n'); | |
1711 | } | |
1712 | else | |
1713 | { | |
1714 | char buf[16]; | |
1715 | sprintf (buf, "\n# %d \"", lineno); | |
1716 | len = strlen (buf); | |
1717 | obstack_grow (obstackp, buf, len); | |
1718 | ||
1719 | len = strlen (input_filename); | |
1720 | obstack_grow (obstackp, input_filename, len); | |
1721 | obstack_1grow (obstackp, '\"'); | |
1722 | obstack_1grow (obstackp, '\n'); | |
1723 | } | |
1724 | ||
1725 | while (c > ' ') /* ASCII dependent... */ | |
1726 | { | |
1727 | if (plev <= 0 && (c == ')' || c == ',')) | |
1728 | { | |
1729 | put_back (c); | |
1730 | goto done; | |
1731 | } | |
1732 | obstack_1grow (obstackp, c); | |
1733 | if (c == '(' || c == '[') | |
1734 | ++plev; | |
1735 | else if (c == ']' || c == ')') | |
1736 | --plev; | |
1737 | else if (c == '\\') | |
1738 | { | |
1739 | /* Don't act on the next character...e.g, doing an escaped | |
1740 | double-quote. */ | |
1741 | c = getch (); | |
1742 | if (c == EOF) | |
1743 | { | |
1744 | error_with_file_and_line (starting_filename, | |
1745 | starting_lineno, | |
1746 | "end of file read inside definition"); | |
1747 | goto done; | |
1748 | } | |
1749 | obstack_1grow (obstackp, c); | |
1750 | } | |
1751 | else if (c == '\"') | |
1752 | consume_string (obstackp, c); | |
1753 | else if (c == '\'') | |
1754 | consume_string (obstackp, c); | |
1755 | c = getch (); | |
1756 | } | |
1757 | ||
1758 | if (c == EOF) | |
1759 | { | |
1760 | error_with_file_and_line (starting_filename, | |
1761 | starting_lineno, | |
1762 | "end of file read inside definition"); | |
1763 | goto done; | |
1764 | } | |
1765 | else if (c != '\n') | |
1766 | { | |
1767 | obstack_1grow (obstackp, c); | |
1768 | c = getch (); | |
1769 | } | |
1770 | } | |
1771 | done: | |
1772 | obstack_1grow (obstackp, '\0'); | |
1773 | } | |
1774 | ||
1775 | int do_snarf_defarg; | |
1776 | ||
1777 | /* Decide whether the default argument we are about to see should be | |
1778 | gobbled up as text for later parsing. */ | |
1779 | ||
1780 | void | |
1781 | maybe_snarf_defarg () | |
1782 | { | |
1783 | if (current_class_type && TYPE_BEING_DEFINED (current_class_type)) | |
1784 | do_snarf_defarg = 1; | |
1785 | } | |
1786 | ||
1787 | /* When we see a default argument in a method declaration, we snarf it as | |
1788 | text using snarf_defarg. When we get up to namespace scope, we then go | |
1789 | through and parse all of them using do_pending_defargs. Since yacc | |
1790 | parsers are not reentrant, we retain defargs state in these two | |
1791 | variables so that subsequent calls to do_pending_defargs can resume | |
1792 | where the previous call left off. */ | |
1793 | ||
1794 | tree defarg_fns; | |
1795 | tree defarg_parm; | |
1796 | ||
1797 | tree | |
1798 | snarf_defarg () | |
1799 | { | |
1800 | int len; | |
1801 | char *buf; | |
1802 | tree arg; | |
42976354 BK |
1803 | |
1804 | reinit_parse_for_expr (&inline_text_obstack); | |
1805 | len = obstack_object_size (&inline_text_obstack); | |
1806 | buf = obstack_finish (&inline_text_obstack); | |
1807 | ||
1808 | push_obstacks (&inline_text_obstack, &inline_text_obstack); | |
1809 | arg = make_node (DEFAULT_ARG); | |
1810 | DEFARG_LENGTH (arg) = len - 1; | |
1811 | DEFARG_POINTER (arg) = buf; | |
1812 | pop_obstacks (); | |
1813 | ||
1814 | return arg; | |
1815 | } | |
1816 | ||
1817 | /* Called from grokfndecl to note a function decl with unparsed default | |
1818 | arguments for later processing. Also called from grokdeclarator | |
1819 | for function types with unparsed defargs; the call from grokfndecl | |
1820 | will always come second, so we can overwrite the entry from the type. */ | |
1821 | ||
1822 | void | |
1823 | add_defarg_fn (decl) | |
1824 | tree decl; | |
1825 | { | |
1826 | if (TREE_CODE (decl) == FUNCTION_DECL) | |
1827 | TREE_VALUE (defarg_fns) = decl; | |
1828 | else | |
1829 | { | |
1830 | push_obstacks (&inline_text_obstack, &inline_text_obstack); | |
1831 | defarg_fns = tree_cons (current_class_type, decl, defarg_fns); | |
1832 | pop_obstacks (); | |
1833 | } | |
1834 | } | |
1835 | ||
1836 | /* Helper for do_pending_defargs. Starts the parsing of a default arg. */ | |
1837 | ||
1838 | static void | |
1839 | feed_defarg (f, p) | |
1840 | tree f, p; | |
1841 | { | |
1842 | tree d = TREE_PURPOSE (p); | |
1843 | feed_input (DEFARG_POINTER (d), DEFARG_LENGTH (d)); | |
1844 | if (TREE_CODE (f) == FUNCTION_DECL) | |
1845 | { | |
1846 | lineno = DECL_SOURCE_LINE (f); | |
1847 | input_filename = DECL_SOURCE_FILE (f); | |
1848 | } | |
1849 | yychar = DEFARG_MARKER; | |
1850 | yylval.ttype = p; | |
1851 | } | |
1852 | ||
1853 | /* Helper for do_pending_defargs. Ends the parsing of a default arg. */ | |
1854 | ||
1855 | static void | |
1856 | finish_defarg () | |
1857 | { | |
1858 | if (yychar == YYEMPTY) | |
1859 | yychar = yylex (); | |
1860 | if (yychar != END_OF_SAVED_INPUT) | |
1861 | { | |
1862 | error ("parse error at end of saved function text"); | |
1863 | ||
1864 | /* restore_pending_input will abort unless yychar is either | |
1865 | END_OF_SAVED_INPUT or YYEMPTY; since we already know we're | |
1866 | hosed, feed back YYEMPTY. We also need to discard nextchar, | |
1867 | since that may have gotten set as well. */ | |
1868 | nextchar = -1; | |
1869 | } | |
1870 | yychar = YYEMPTY; | |
1871 | end_input (); | |
1872 | } | |
1873 | ||
1874 | /* Main function for deferred parsing of default arguments. Called from | |
1875 | the parser. */ | |
1876 | ||
1877 | void | |
1878 | do_pending_defargs () | |
1879 | { | |
1880 | if (defarg_parm) | |
1881 | finish_defarg (); | |
1882 | ||
1883 | for (; defarg_fns; defarg_fns = TREE_CHAIN (defarg_fns)) | |
1884 | { | |
1885 | tree defarg_fn = TREE_VALUE (defarg_fns); | |
1886 | if (defarg_parm == NULL_TREE) | |
1887 | { | |
42976354 BK |
1888 | push_nested_class (TREE_PURPOSE (defarg_fns), 1); |
1889 | pushlevel (0); | |
aa5f3bad | 1890 | if (is_member_template (defarg_fn)) |
786b5245 | 1891 | begin_member_template_processing (defarg_fn); |
42976354 BK |
1892 | |
1893 | if (TREE_CODE (defarg_fn) == FUNCTION_DECL) | |
1894 | { | |
1895 | #if 0 | |
b2bb2710 | 1896 | tree p; |
42976354 BK |
1897 | for (p = DECL_ARGUMENTS (defarg_fn); p; p = TREE_CHAIN (p)) |
1898 | pushdecl (copy_node (p)); | |
1899 | #endif | |
1900 | defarg_parm = TYPE_ARG_TYPES (TREE_TYPE (defarg_fn)); | |
1901 | } | |
1902 | else | |
1903 | defarg_parm = TYPE_ARG_TYPES (defarg_fn); | |
1904 | } | |
1905 | else | |
1906 | defarg_parm = TREE_CHAIN (defarg_parm); | |
1907 | ||
1908 | for (; defarg_parm; defarg_parm = TREE_CHAIN (defarg_parm)) | |
da20811c JM |
1909 | if (TREE_PURPOSE (defarg_parm) |
1910 | && TREE_CODE (TREE_PURPOSE (defarg_parm)) == DEFAULT_ARG) | |
42976354 | 1911 | { |
42976354 BK |
1912 | feed_defarg (defarg_fn, defarg_parm); |
1913 | ||
1914 | /* Return to the parser, which will process this defarg | |
1915 | and call us again. */ | |
1916 | return; | |
1917 | } | |
1918 | ||
aa5f3bad MM |
1919 | if (is_member_template (defarg_fn)) |
1920 | end_member_template_processing (); | |
42976354 BK |
1921 | poplevel (0, 0, 0); |
1922 | pop_nested_class (1); | |
1923 | } | |
1924 | } | |
1925 | ||
8d08fdba MS |
1926 | /* Build a default function named NAME for type TYPE. |
1927 | KIND says what to build. | |
1928 | ||
1929 | When KIND == 0, build default destructor. | |
1930 | When KIND == 1, build virtual destructor. | |
1931 | When KIND == 2, build default constructor. | |
1932 | When KIND == 3, build default X(const X&) constructor. | |
1933 | When KIND == 4, build default X(X&) constructor. | |
1934 | When KIND == 5, build default operator = (const X&). | |
1935 | When KIND == 6, build default operator = (X&). */ | |
1936 | ||
1937 | tree | |
8ccc31eb MS |
1938 | cons_up_default_function (type, full_name, kind) |
1939 | tree type, full_name; | |
8d08fdba MS |
1940 | int kind; |
1941 | { | |
1942 | extern tree void_list_node; | |
8d08fdba MS |
1943 | tree declspecs = NULL_TREE; |
1944 | tree fn, args; | |
1945 | tree argtype; | |
1946 | int retref = 0; | |
8ccc31eb | 1947 | tree name = constructor_name (full_name); |
8d08fdba | 1948 | |
8d08fdba MS |
1949 | switch (kind) |
1950 | { | |
1951 | /* Destructors. */ | |
1952 | case 1: | |
1953 | declspecs = build_decl_list (NULL_TREE, ridpointers [(int) RID_VIRTUAL]); | |
1954 | /* Fall through... */ | |
1955 | case 0: | |
1956 | name = build_parse_node (BIT_NOT_EXPR, name); | |
db5ae43f MS |
1957 | args = void_list_node; |
1958 | break; | |
1959 | ||
8d08fdba MS |
1960 | case 2: |
1961 | /* Default constructor. */ | |
1962 | args = void_list_node; | |
8d08fdba MS |
1963 | break; |
1964 | ||
1965 | case 3: | |
1966 | type = build_type_variant (type, 1, 0); | |
1967 | /* Fall through... */ | |
1968 | case 4: | |
1969 | /* According to ARM $12.8, the default copy ctor will be declared, but | |
f376e137 | 1970 | not defined, unless it's needed. */ |
8d08fdba MS |
1971 | argtype = build_reference_type (type); |
1972 | args = tree_cons (NULL_TREE, | |
1973 | build_tree_list (hash_tree_chain (argtype, NULL_TREE), | |
1974 | get_identifier ("_ctor_arg")), | |
1975 | void_list_node); | |
8d08fdba MS |
1976 | break; |
1977 | ||
1978 | case 5: | |
8d08fdba MS |
1979 | case 6: |
1980 | retref = 1; | |
6b5fbb55 | 1981 | declspecs = build_decl_list (NULL_TREE, type); |
8d08fdba | 1982 | |
824b9a4c MS |
1983 | if (kind == 5) |
1984 | type = build_type_variant (type, 1, 0); | |
1985 | ||
8d08fdba MS |
1986 | name = ansi_opname [(int) MODIFY_EXPR]; |
1987 | ||
1988 | argtype = build_reference_type (type); | |
1989 | args = tree_cons (NULL_TREE, | |
1990 | build_tree_list (hash_tree_chain (argtype, NULL_TREE), | |
1991 | get_identifier ("_ctor_arg")), | |
1992 | void_list_node); | |
8d08fdba MS |
1993 | break; |
1994 | ||
1995 | default: | |
1996 | my_friendly_abort (59); | |
1997 | } | |
1998 | ||
f376e137 MS |
1999 | declspecs = decl_tree_cons (NULL_TREE, ridpointers [(int) RID_INLINE], |
2000 | declspecs); | |
8d08fdba MS |
2001 | |
2002 | TREE_PARMLIST (args) = 1; | |
2003 | ||
2004 | { | |
c11b6f21 | 2005 | tree declarator = make_call_declarator (name, args, NULL_TREE, NULL_TREE); |
92eca640 | 2006 | int saved_processing_specialization; |
8d08fdba MS |
2007 | if (retref) |
2008 | declarator = build_parse_node (ADDR_EXPR, declarator); | |
92eca640 MM |
2009 | |
2010 | /* The following is in case we're generating the default | |
2011 | implementation in the midst of handling a specialization. */ | |
2012 | saved_processing_specialization = processing_specialization; | |
2013 | processing_specialization = 0; | |
c11b6f21 | 2014 | fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE, NULL_TREE); |
92eca640 | 2015 | processing_specialization = saved_processing_specialization; |
8d08fdba MS |
2016 | } |
2017 | ||
2018 | if (fn == void_type_node) | |
2019 | return fn; | |
2020 | ||
d11ad92e MS |
2021 | if (kind > 2) |
2022 | SET_DECL_ARTIFICIAL (TREE_CHAIN (DECL_ARGUMENTS (fn))); | |
2023 | ||
5566b478 | 2024 | #if 0 |
db5ae43f | 2025 | if (processing_template_defn) |
79ff2c6c MS |
2026 | { |
2027 | SET_DECL_IMPLICIT_INSTANTIATION (fn); | |
2028 | repo_template_used (fn); | |
2029 | } | |
5566b478 | 2030 | #endif |
3536cd7e | 2031 | |
fc378698 | 2032 | #if 0 |
db5ae43f MS |
2033 | if (CLASSTYPE_INTERFACE_KNOWN (type)) |
2034 | { | |
2035 | DECL_INTERFACE_KNOWN (fn) = 1; | |
a5894242 MS |
2036 | DECL_NOT_REALLY_EXTERN (fn) = (!CLASSTYPE_INTERFACE_ONLY (type) |
2037 | && flag_implement_inlines); | |
db5ae43f | 2038 | } |
e8abc66f | 2039 | else |
fc378698 | 2040 | #endif |
e8abc66f | 2041 | DECL_NOT_REALLY_EXTERN (fn) = 1; |
db5ae43f | 2042 | |
5566b478 | 2043 | mark_inline_for_output (fn); |
8d08fdba | 2044 | |
8d08fdba MS |
2045 | #ifdef DEBUG_DEFAULT_FUNCTIONS |
2046 | { char *fn_type = NULL; | |
2047 | tree t = name; | |
2048 | switch (kind) | |
2049 | { | |
2050 | case 0: fn_type = "default destructor"; break; | |
2051 | case 1: fn_type = "virtual destructor"; break; | |
2052 | case 2: fn_type = "default constructor"; break; | |
2053 | case 3: fn_type = "default X(const X&)"; break; | |
2054 | case 4: fn_type = "default X(X&)"; break; | |
2055 | } | |
2056 | if (fn_type) | |
2057 | { | |
2058 | if (TREE_CODE (name) == BIT_NOT_EXPR) | |
2059 | t = TREE_OPERAND (name, 0); | |
2060 | fprintf (stderr, "[[[[ %s for %s:\n%s]]]]\n", fn_type, | |
2061 | IDENTIFIER_POINTER (t), func_buf); | |
2062 | } | |
2063 | } | |
8926095f | 2064 | #endif /* DEBUG_DEFAULT_FUNCTIONS */ |
8d08fdba | 2065 | |
8d08fdba | 2066 | /* Show that this function was generated by the compiler. */ |
700f8a87 | 2067 | SET_DECL_ARTIFICIAL (fn); |
8d08fdba MS |
2068 | |
2069 | return fn; | |
2070 | } | |
2071 | ||
8d08fdba MS |
2072 | /* Heuristic to tell whether the user is missing a semicolon |
2073 | after a struct or enum declaration. Emit an error message | |
2074 | if we know the user has blown it. */ | |
e92cc029 | 2075 | |
8d08fdba MS |
2076 | void |
2077 | check_for_missing_semicolon (type) | |
2078 | tree type; | |
2079 | { | |
2080 | if (yychar < 0) | |
2081 | yychar = yylex (); | |
2082 | ||
00595019 MS |
2083 | if ((yychar > 255 |
2084 | && yychar != SCSPEC | |
2085 | && yychar != IDENTIFIER | |
a80e4195 | 2086 | && yychar != TYPENAME |
b88c08b6 | 2087 | && yychar != CV_QUALIFIER |
a80e4195 | 2088 | && yychar != SELFNAME) |
00595019 | 2089 | || end_of_file) |
8d08fdba MS |
2090 | { |
2091 | if (ANON_AGGRNAME_P (TYPE_IDENTIFIER (type))) | |
2092 | error ("semicolon missing after %s declaration", | |
2093 | TREE_CODE (type) == ENUMERAL_TYPE ? "enum" : "struct"); | |
2094 | else | |
00595019 | 2095 | cp_error ("semicolon missing after declaration of `%T'", type); |
8d08fdba MS |
2096 | shadow_tag (build_tree_list (0, type)); |
2097 | } | |
2098 | /* Could probably also hack cases where class { ... } f (); appears. */ | |
2099 | clear_anon_tags (); | |
2100 | } | |
2101 | ||
2102 | void | |
2103 | note_got_semicolon (type) | |
2104 | tree type; | |
2105 | { | |
2106 | if (TREE_CODE_CLASS (TREE_CODE (type)) != 't') | |
2107 | my_friendly_abort (60); | |
2108 | if (IS_AGGR_TYPE (type)) | |
2109 | CLASSTYPE_GOT_SEMICOLON (type) = 1; | |
2110 | } | |
2111 | ||
2112 | void | |
2113 | note_list_got_semicolon (declspecs) | |
2114 | tree declspecs; | |
2115 | { | |
2116 | tree link; | |
2117 | ||
2118 | for (link = declspecs; link; link = TREE_CHAIN (link)) | |
2119 | { | |
2120 | tree type = TREE_VALUE (link); | |
2121 | if (TREE_CODE_CLASS (TREE_CODE (type)) == 't') | |
2122 | note_got_semicolon (type); | |
2123 | } | |
2124 | clear_anon_tags (); | |
2125 | } | |
2126 | \f | |
2127 | /* If C is not whitespace, return C. | |
2128 | Otherwise skip whitespace and return first nonwhite char read. */ | |
2129 | ||
2130 | static int | |
2131 | skip_white_space (c) | |
2132 | register int c; | |
2133 | { | |
2134 | for (;;) | |
2135 | { | |
2136 | switch (c) | |
2137 | { | |
2138 | case '\n': | |
2139 | c = check_newline (); | |
2140 | break; | |
2141 | ||
2142 | case ' ': | |
2143 | case '\t': | |
2144 | case '\f': | |
2145 | case '\r': | |
2146 | case '\v': | |
2147 | case '\b': | |
2148 | do | |
2149 | c = getch (); | |
2150 | while (c == ' ' || c == '\t'); | |
2151 | break; | |
2152 | ||
2153 | case '\\': | |
2154 | c = getch (); | |
2155 | if (c == '\n') | |
2156 | lineno++; | |
2157 | else | |
2158 | error ("stray '\\' in program"); | |
2159 | c = getch (); | |
2160 | break; | |
2161 | ||
2162 | default: | |
2163 | return (c); | |
2164 | } | |
2165 | } | |
2166 | } | |
2167 | ||
2168 | ||
2169 | ||
2170 | /* Make the token buffer longer, preserving the data in it. | |
2171 | P should point to just beyond the last valid character in the old buffer. | |
2172 | The value we return is a pointer to the new buffer | |
2173 | at a place corresponding to P. */ | |
2174 | ||
2175 | static char * | |
2176 | extend_token_buffer (p) | |
2177 | char *p; | |
2178 | { | |
2179 | int offset = p - token_buffer; | |
2180 | ||
2181 | maxtoken = maxtoken * 2 + 10; | |
2182 | token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2); | |
2183 | ||
2184 | return token_buffer + offset; | |
2185 | } | |
2186 | \f | |
2187 | static int | |
2188 | get_last_nonwhite_on_line () | |
2189 | { | |
2190 | register int c; | |
2191 | ||
2192 | /* Is this the last nonwhite stuff on the line? */ | |
2193 | if (nextchar >= 0) | |
2194 | c = nextchar, nextchar = -1; | |
2195 | else | |
2196 | c = getch (); | |
2197 | ||
2198 | while (c == ' ' || c == '\t') | |
2199 | c = getch (); | |
2200 | return c; | |
2201 | } | |
2202 | ||
2203 | /* At the beginning of a line, increment the line number | |
2204 | and process any #-directive on this line. | |
2205 | If the line is a #-directive, read the entire line and return a newline. | |
2206 | Otherwise, return the line's first non-whitespace character. */ | |
2207 | ||
d18c083e MS |
2208 | int linemode; |
2209 | ||
824b9a4c | 2210 | #ifdef HANDLE_SYSV_PRAGMA |
49c249e1 | 2211 | static int handle_sysv_pragma PROTO((FILE *, int)); |
824b9a4c | 2212 | #endif |
49c249e1 | 2213 | static int handle_cp_pragma PROTO((char *)); |
a82e1b55 | 2214 | |
bd6dd845 | 2215 | static int |
8d08fdba MS |
2216 | check_newline () |
2217 | { | |
2218 | register int c; | |
2219 | register int token; | |
2220 | ||
a28e3c7f MS |
2221 | /* Read first nonwhite char on the line. Do this before incrementing the |
2222 | line number, in case we're at the end of saved text. */ | |
8d08fdba MS |
2223 | |
2224 | do | |
2225 | c = getch (); | |
2226 | while (c == ' ' || c == '\t'); | |
2227 | ||
a28e3c7f MS |
2228 | lineno++; |
2229 | ||
8d08fdba MS |
2230 | if (c != '#') |
2231 | { | |
2232 | /* If not #, return it so caller will use it. */ | |
2233 | return c; | |
2234 | } | |
2235 | ||
d18c083e MS |
2236 | /* Don't read beyond this line. */ |
2237 | linemode = 1; | |
2238 | ||
8d08fdba MS |
2239 | /* Read first nonwhite char after the `#'. */ |
2240 | ||
2241 | do | |
2242 | c = getch (); | |
2243 | while (c == ' ' || c == '\t'); | |
2244 | ||
2245 | /* If a letter follows, then if the word here is `line', skip | |
2246 | it and ignore it; otherwise, ignore the line, with an error | |
2247 | if the word isn't `pragma'. */ | |
2248 | ||
2249 | if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) | |
2250 | { | |
2251 | if (c == 'p') | |
2252 | { | |
2253 | if (getch () == 'r' | |
2254 | && getch () == 'a' | |
2255 | && getch () == 'g' | |
2256 | && getch () == 'm' | |
2257 | && getch () == 'a') | |
2258 | { | |
a82e1b55 BK |
2259 | token = real_yylex (); |
2260 | if (token == IDENTIFIER | |
2261 | && TREE_CODE (yylval.ttype) == IDENTIFIER_NODE) | |
8d08fdba | 2262 | { |
a82e1b55 BK |
2263 | /* If this is 1, we handled it; if it's -1, it was one we |
2264 | wanted but had something wrong with it. Only if it's | |
2265 | 0 was it not handled. */ | |
2266 | if (handle_cp_pragma (IDENTIFIER_POINTER (yylval.ttype))) | |
2267 | goto skipline; | |
8d08fdba | 2268 | } |
a82e1b55 BK |
2269 | else if (token == END_OF_LINE) |
2270 | goto skipline; | |
51c184be | 2271 | |
6060a796 | 2272 | #ifdef HANDLE_SYSV_PRAGMA |
a82e1b55 BK |
2273 | if (handle_sysv_pragma (finput, token)) |
2274 | goto skipline; | |
6060a796 MS |
2275 | #else |
2276 | #ifdef HANDLE_PRAGMA | |
a82e1b55 BK |
2277 | if (HANDLE_PRAGMA (finput, yylval.ttype)) |
2278 | goto skipline; | |
6060a796 MS |
2279 | #endif |
2280 | #endif | |
8d08fdba | 2281 | } |
a82e1b55 | 2282 | goto skipline; |
8d08fdba MS |
2283 | } |
2284 | else if (c == 'd') | |
2285 | { | |
2286 | if (getch () == 'e' | |
2287 | && getch () == 'f' | |
2288 | && getch () == 'i' | |
2289 | && getch () == 'n' | |
2290 | && getch () == 'e' | |
d18c083e | 2291 | && ((c = getch ()) == ' ' || c == '\t')) |
8d08fdba | 2292 | { |
faf5394a | 2293 | debug_define (lineno, get_directive_line (finput)); |
8d08fdba MS |
2294 | goto skipline; |
2295 | } | |
2296 | } | |
2297 | else if (c == 'u') | |
2298 | { | |
2299 | if (getch () == 'n' | |
2300 | && getch () == 'd' | |
2301 | && getch () == 'e' | |
2302 | && getch () == 'f' | |
d18c083e | 2303 | && ((c = getch ()) == ' ' || c == '\t')) |
8d08fdba | 2304 | { |
faf5394a | 2305 | debug_undef (lineno, get_directive_line (finput)); |
8d08fdba MS |
2306 | goto skipline; |
2307 | } | |
2308 | } | |
2309 | else if (c == 'l') | |
2310 | { | |
2311 | if (getch () == 'i' | |
2312 | && getch () == 'n' | |
2313 | && getch () == 'e' | |
2314 | && ((c = getch ()) == ' ' || c == '\t')) | |
2315 | goto linenum; | |
2316 | } | |
2317 | else if (c == 'i') | |
2318 | { | |
2319 | if (getch () == 'd' | |
2320 | && getch () == 'e' | |
2321 | && getch () == 'n' | |
2322 | && getch () == 't' | |
2323 | && ((c = getch ()) == ' ' || c == '\t')) | |
2324 | { | |
2325 | #ifdef ASM_OUTPUT_IDENT | |
2326 | extern FILE *asm_out_file; | |
2327 | #endif | |
2328 | /* #ident. The pedantic warning is now in cccp.c. */ | |
2329 | ||
2330 | /* Here we have just seen `#ident '. | |
2331 | A string constant should follow. */ | |
2332 | ||
8d08fdba | 2333 | token = real_yylex (); |
a80e4195 MS |
2334 | if (token == END_OF_LINE) |
2335 | goto skipline; | |
8d08fdba MS |
2336 | if (token != STRING |
2337 | || TREE_CODE (yylval.ttype) != STRING_CST) | |
2338 | { | |
2339 | error ("invalid #ident"); | |
2340 | goto skipline; | |
2341 | } | |
2342 | ||
2343 | if (! flag_no_ident) | |
2344 | { | |
2345 | #ifdef ASM_OUTPUT_IDENT | |
2346 | ASM_OUTPUT_IDENT (asm_out_file, | |
2347 | TREE_STRING_POINTER (yylval.ttype)); | |
2348 | #endif | |
2349 | } | |
2350 | ||
2351 | /* Skip the rest of this line. */ | |
2352 | goto skipline; | |
2353 | } | |
2354 | } | |
2355 | else if (c == 'n') | |
2356 | { | |
2357 | if (getch () == 'e' | |
2358 | && getch () == 'w' | |
2359 | && getch () == 'w' | |
2360 | && getch () == 'o' | |
2361 | && getch () == 'r' | |
2362 | && getch () == 'l' | |
2363 | && getch () == 'd' | |
2364 | && ((c = getch ()) == ' ' || c == '\t')) | |
2365 | { | |
2366 | /* Used to test incremental compilation. */ | |
2367 | sorry ("#pragma newworld"); | |
2368 | goto skipline; | |
2369 | } | |
2370 | } | |
2371 | error ("undefined or invalid # directive"); | |
2372 | goto skipline; | |
2373 | } | |
2374 | ||
2375 | linenum: | |
2376 | /* Here we have either `#line' or `# <nonletter>'. | |
2377 | In either case, it should be a line number; a digit should follow. */ | |
2378 | ||
2379 | while (c == ' ' || c == '\t') | |
2380 | c = getch (); | |
2381 | ||
2382 | /* If the # is the only nonwhite char on the line, | |
2383 | just ignore it. Check the new newline. */ | |
d18c083e MS |
2384 | if (c == EOF) |
2385 | goto skipline; | |
8d08fdba MS |
2386 | |
2387 | /* Something follows the #; read a token. */ | |
2388 | ||
2389 | put_back (c); | |
2390 | token = real_yylex (); | |
2391 | ||
2392 | if (token == CONSTANT | |
2393 | && TREE_CODE (yylval.ttype) == INTEGER_CST) | |
2394 | { | |
2395 | int old_lineno = lineno; | |
2396 | enum { act_none, act_push, act_pop } action = act_none; | |
2397 | int entering_system_header = 0; | |
2398 | int entering_c_header = 0; | |
2399 | ||
2400 | /* subtract one, because it is the following line that | |
2401 | gets the specified number */ | |
2402 | ||
2403 | int l = TREE_INT_CST_LOW (yylval.ttype) - 1; | |
2404 | c = get_last_nonwhite_on_line (); | |
d18c083e | 2405 | if (c == EOF) |
8d08fdba MS |
2406 | { |
2407 | /* No more: store the line number and check following line. */ | |
2408 | lineno = l; | |
d18c083e | 2409 | goto skipline; |
8d08fdba MS |
2410 | } |
2411 | put_back (c); | |
2412 | ||
2413 | /* More follows: it must be a string constant (filename). */ | |
2414 | ||
2415 | /* Read the string constant, but don't treat \ as special. */ | |
2416 | ignore_escape_flag = 1; | |
2417 | token = real_yylex (); | |
2418 | ignore_escape_flag = 0; | |
2419 | ||
2420 | if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST) | |
2421 | { | |
2422 | error ("invalid #line"); | |
2423 | goto skipline; | |
2424 | } | |
2425 | ||
2426 | /* Changing files again. This means currently collected time | |
2427 | is charged against header time, and body time starts back | |
2428 | at 0. */ | |
2429 | if (flag_detailed_statistics) | |
2430 | { | |
2431 | int this_time = my_get_run_time (); | |
2432 | tree time_identifier = get_time_identifier (TREE_STRING_POINTER (yylval.ttype)); | |
2433 | header_time += this_time - body_time; | |
2434 | TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time)) | |
2435 | += this_time - body_time; | |
2436 | this_filename_time = time_identifier; | |
2437 | body_time = this_time; | |
2438 | } | |
2439 | ||
8d08fdba MS |
2440 | input_filename |
2441 | = (char *) permalloc (TREE_STRING_LENGTH (yylval.ttype) + 1); | |
2442 | strcpy (input_filename, TREE_STRING_POINTER (yylval.ttype)); | |
2443 | lineno = l; | |
2444 | GNU_xref_file (input_filename); | |
2445 | ||
2446 | if (main_input_filename == 0) | |
2447 | { | |
2448 | struct impl_files *ifiles = impl_file_chain; | |
2449 | ||
2450 | if (ifiles) | |
2451 | { | |
2452 | while (ifiles->next) | |
2453 | ifiles = ifiles->next; | |
b2bb2710 | 2454 | ifiles->filename = file_name_nondirectory (input_filename); |
8d08fdba MS |
2455 | } |
2456 | ||
2457 | main_input_filename = input_filename; | |
2458 | if (write_virtuals == 3) | |
2459 | walk_vtables (set_typedecl_interface_info, set_vardecl_interface_info); | |
2460 | } | |
2461 | ||
2462 | extract_interface_info (); | |
2463 | ||
2464 | c = get_last_nonwhite_on_line (); | |
28cbf42c MS |
2465 | if (c == EOF) |
2466 | { | |
2467 | /* Update the name in the top element of input_file_stack. */ | |
2468 | if (input_file_stack) | |
2469 | input_file_stack->name = input_filename; | |
2470 | } | |
2471 | else | |
8d08fdba MS |
2472 | { |
2473 | put_back (c); | |
2474 | ||
2475 | token = real_yylex (); | |
2476 | ||
2477 | /* `1' after file name means entering new file. | |
2478 | `2' after file name means just left a file. */ | |
2479 | ||
2480 | if (token == CONSTANT | |
2481 | && TREE_CODE (yylval.ttype) == INTEGER_CST) | |
2482 | { | |
2483 | if (TREE_INT_CST_LOW (yylval.ttype) == 1) | |
2484 | action = act_push; | |
2485 | else if (TREE_INT_CST_LOW (yylval.ttype) == 2) | |
2486 | action = act_pop; | |
2487 | ||
2488 | if (action) | |
2489 | { | |
2490 | c = get_last_nonwhite_on_line (); | |
d18c083e | 2491 | if (c != EOF) |
8d08fdba MS |
2492 | { |
2493 | put_back (c); | |
2494 | token = real_yylex (); | |
2495 | } | |
2496 | } | |
2497 | } | |
2498 | ||
2499 | /* `3' after file name means this is a system header file. */ | |
2500 | ||
2501 | if (token == CONSTANT | |
2502 | && TREE_CODE (yylval.ttype) == INTEGER_CST | |
2503 | && TREE_INT_CST_LOW (yylval.ttype) == 3) | |
2504 | { | |
2505 | entering_system_header = 1; | |
2506 | ||
2507 | c = get_last_nonwhite_on_line (); | |
d18c083e | 2508 | if (c != EOF) |
8d08fdba MS |
2509 | { |
2510 | put_back (c); | |
2511 | token = real_yylex (); | |
2512 | } | |
2513 | } | |
2514 | ||
2515 | /* `4' after file name means this is a C header file. */ | |
2516 | ||
2517 | if (token == CONSTANT | |
2518 | && TREE_CODE (yylval.ttype) == INTEGER_CST | |
2519 | && TREE_INT_CST_LOW (yylval.ttype) == 4) | |
2520 | { | |
2521 | entering_c_header = 1; | |
2522 | ||
2523 | c = get_last_nonwhite_on_line (); | |
d18c083e | 2524 | if (c != EOF) |
8d08fdba MS |
2525 | { |
2526 | put_back (c); | |
2527 | token = real_yylex (); | |
2528 | } | |
2529 | } | |
2530 | ||
ddd5a7c1 | 2531 | /* Do the actions implied by the preceding numbers. */ |
8d08fdba MS |
2532 | |
2533 | if (action == act_push) | |
2534 | { | |
2535 | /* Pushing to a new file. */ | |
2536 | struct file_stack *p; | |
2537 | ||
2538 | p = (struct file_stack *) xmalloc (sizeof (struct file_stack)); | |
2539 | input_file_stack->line = old_lineno; | |
2540 | p->next = input_file_stack; | |
2541 | p->name = input_filename; | |
2542 | input_file_stack = p; | |
2543 | input_file_stack_tick++; | |
faf5394a | 2544 | debug_start_source_file (input_filename); |
8d08fdba MS |
2545 | in_system_header = entering_system_header; |
2546 | if (c_header_level) | |
2547 | ++c_header_level; | |
2548 | else if (entering_c_header) | |
2549 | { | |
2550 | c_header_level = 1; | |
2551 | ++pending_lang_change; | |
2552 | } | |
2553 | } | |
2554 | else if (action == act_pop) | |
2555 | { | |
2556 | /* Popping out of a file. */ | |
2557 | if (input_file_stack->next) | |
2558 | { | |
2559 | struct file_stack *p; | |
2560 | ||
2561 | if (c_header_level && --c_header_level == 0) | |
2562 | { | |
2563 | if (entering_c_header) | |
a292b002 | 2564 | warning ("badly nested C headers from preprocessor"); |
8d08fdba MS |
2565 | --pending_lang_change; |
2566 | } | |
8d08fdba MS |
2567 | in_system_header = entering_system_header; |
2568 | ||
2569 | p = input_file_stack; | |
2570 | input_file_stack = p->next; | |
2571 | free (p); | |
2572 | input_file_stack_tick++; | |
faf5394a | 2573 | debug_end_source_file (input_file_stack->line); |
8d08fdba MS |
2574 | } |
2575 | else | |
2576 | error ("#-lines for entering and leaving files don't match"); | |
2577 | } | |
2578 | else | |
9e9ff709 | 2579 | in_system_header = entering_system_header; |
8d08fdba MS |
2580 | } |
2581 | ||
2582 | /* If NEXTCHAR is not end of line, we don't care what it is. */ | |
d18c083e MS |
2583 | if (nextchar == EOF) |
2584 | c = EOF; | |
8d08fdba MS |
2585 | } |
2586 | else | |
2587 | error ("invalid #-line"); | |
2588 | ||
2589 | /* skip the rest of this line. */ | |
2590 | skipline: | |
d18c083e MS |
2591 | linemode = 0; |
2592 | end_of_file = 0; | |
a80e4195 | 2593 | nextchar = -1; |
8d08fdba MS |
2594 | while ((c = getch ()) != EOF && c != '\n'); |
2595 | return c; | |
2596 | } | |
2597 | ||
2598 | void | |
2599 | do_pending_lang_change () | |
2600 | { | |
2601 | for (; pending_lang_change > 0; --pending_lang_change) | |
2602 | push_lang_context (lang_name_c); | |
2603 | for (; pending_lang_change < 0; ++pending_lang_change) | |
2604 | pop_lang_context (); | |
2605 | } | |
2606 | \f | |
2607 | #if 0 | |
2608 | #define isalnum(char) (char >= 'a' ? char <= 'z' : char >= '0' ? char <= '9' || (char >= 'A' && char <= 'Z') : 0) | |
2609 | #define isdigit(char) (char >= '0' && char <= '9') | |
2610 | #else | |
2611 | #include <ctype.h> | |
2612 | #endif | |
2613 | ||
2614 | #define ENDFILE -1 /* token that represents end-of-file */ | |
2615 | ||
2616 | /* Read an escape sequence, returning its equivalent as a character, | |
2617 | or store 1 in *ignore_ptr if it is backslash-newline. */ | |
2618 | ||
2619 | static int | |
2620 | readescape (ignore_ptr) | |
2621 | int *ignore_ptr; | |
2622 | { | |
2623 | register int c = getch (); | |
2624 | register int code; | |
2625 | register unsigned count; | |
2626 | unsigned firstdig; | |
2627 | int nonnull; | |
2628 | ||
2629 | switch (c) | |
2630 | { | |
2631 | case 'x': | |
8d08fdba MS |
2632 | code = 0; |
2633 | count = 0; | |
2634 | nonnull = 0; | |
2635 | while (1) | |
2636 | { | |
2637 | c = getch (); | |
2638 | if (! isxdigit (c)) | |
2639 | { | |
2640 | put_back (c); | |
2641 | break; | |
2642 | } | |
2643 | code *= 16; | |
2644 | if (c >= 'a' && c <= 'f') | |
2645 | code += c - 'a' + 10; | |
2646 | if (c >= 'A' && c <= 'F') | |
2647 | code += c - 'A' + 10; | |
2648 | if (c >= '0' && c <= '9') | |
2649 | code += c - '0'; | |
2650 | if (code != 0 || count != 0) | |
2651 | { | |
2652 | if (count == 0) | |
2653 | firstdig = code; | |
2654 | count++; | |
2655 | } | |
2656 | nonnull = 1; | |
2657 | } | |
2658 | if (! nonnull) | |
2659 | error ("\\x used with no following hex digits"); | |
2660 | else if (count == 0) | |
2661 | /* Digits are all 0's. Ok. */ | |
2662 | ; | |
2663 | else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node) | |
2664 | || (count > 1 | |
2665 | && ((1 << (TYPE_PRECISION (integer_type_node) - (count - 1) * 4)) | |
2666 | <= firstdig))) | |
2667 | pedwarn ("hex escape out of range"); | |
2668 | return code; | |
2669 | ||
2670 | case '0': case '1': case '2': case '3': case '4': | |
2671 | case '5': case '6': case '7': | |
2672 | code = 0; | |
2673 | count = 0; | |
2674 | while ((c <= '7') && (c >= '0') && (count++ < 3)) | |
2675 | { | |
2676 | code = (code * 8) + (c - '0'); | |
2677 | c = getch (); | |
2678 | } | |
2679 | put_back (c); | |
2680 | return code; | |
2681 | ||
2682 | case '\\': case '\'': case '"': | |
2683 | return c; | |
2684 | ||
2685 | case '\n': | |
2686 | lineno++; | |
2687 | *ignore_ptr = 1; | |
2688 | return 0; | |
2689 | ||
2690 | case 'n': | |
2691 | return TARGET_NEWLINE; | |
2692 | ||
2693 | case 't': | |
2694 | return TARGET_TAB; | |
2695 | ||
2696 | case 'r': | |
2697 | return TARGET_CR; | |
2698 | ||
2699 | case 'f': | |
2700 | return TARGET_FF; | |
2701 | ||
2702 | case 'b': | |
2703 | return TARGET_BS; | |
2704 | ||
2705 | case 'a': | |
8d08fdba MS |
2706 | return TARGET_BELL; |
2707 | ||
2708 | case 'v': | |
2709 | return TARGET_VT; | |
2710 | ||
2711 | case 'e': | |
2712 | case 'E': | |
2713 | if (pedantic) | |
2714 | pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c); | |
2715 | return 033; | |
2716 | ||
2717 | case '?': | |
2718 | return c; | |
2719 | ||
2720 | /* `\(', etc, are used at beginning of line to avoid confusing Emacs. */ | |
2721 | case '(': | |
2722 | case '{': | |
2723 | case '[': | |
2724 | /* `\%' is used to prevent SCCS from getting confused. */ | |
2725 | case '%': | |
2726 | if (pedantic) | |
2727 | pedwarn ("unknown escape sequence `\\%c'", c); | |
2728 | return c; | |
2729 | } | |
2730 | if (c >= 040 && c < 0177) | |
2731 | pedwarn ("unknown escape sequence `\\%c'", c); | |
2732 | else | |
2733 | pedwarn ("unknown escape sequence: `\\' followed by char code 0x%x", c); | |
2734 | return c; | |
2735 | } | |
2736 | ||
a28e3c7f MS |
2737 | /* Value is 1 (or 2) if we should try to make the next identifier look like |
2738 | a typename (when it may be a local variable or a class variable). | |
2739 | Value is 0 if we treat this name in a default fashion. */ | |
8d08fdba MS |
2740 | int looking_for_typename = 0; |
2741 | ||
8d08fdba | 2742 | #ifdef __GNUC__ |
8d08fdba MS |
2743 | __inline |
2744 | #endif | |
2745 | int | |
2746 | identifier_type (decl) | |
2747 | tree decl; | |
2748 | { | |
5566b478 MS |
2749 | if (TREE_CODE (decl) == TEMPLATE_DECL) |
2750 | { | |
2751 | if (TREE_CODE (DECL_RESULT (decl)) == TYPE_DECL) | |
2752 | return PTYPENAME; | |
386b8a85 JM |
2753 | else if (looking_for_template) |
2754 | return PFUNCNAME; | |
2755 | } | |
2756 | if (looking_for_template && really_overloaded_fn (decl)) | |
2757 | { | |
2758 | tree t; | |
2759 | for (t = TREE_VALUE (decl); t != NULL_TREE; t = DECL_CHAIN (t)) | |
2760 | if (DECL_FUNCTION_TEMPLATE_P (t)) | |
2761 | return PFUNCNAME; | |
5566b478 | 2762 | } |
a9aedbc2 MS |
2763 | if (TREE_CODE (decl) == NAMESPACE_DECL) |
2764 | return NSNAME; | |
8d08fdba MS |
2765 | if (TREE_CODE (decl) != TYPE_DECL) |
2766 | return IDENTIFIER; | |
a80e4195 MS |
2767 | if (((got_scope && TREE_TYPE (decl) == got_scope) |
2768 | || TREE_TYPE (decl) == current_class_type) | |
2769 | && DECL_ARTIFICIAL (decl)) | |
2770 | return SELFNAME; | |
8d08fdba MS |
2771 | return TYPENAME; |
2772 | } | |
2773 | ||
2774 | void | |
2775 | see_typename () | |
2776 | { | |
f30432d7 MS |
2777 | looking_for_typename = 1; |
2778 | if (yychar < 0) | |
fc378698 | 2779 | if ((yychar = yylex ()) < 0) yychar = 0; |
8d08fdba MS |
2780 | looking_for_typename = 0; |
2781 | if (yychar == IDENTIFIER) | |
2782 | { | |
a28e3c7f | 2783 | lastiddecl = lookup_name (yylval.ttype, -2); |
8d08fdba MS |
2784 | if (lastiddecl == 0) |
2785 | { | |
2786 | if (flag_labels_ok) | |
2787 | lastiddecl = IDENTIFIER_LABEL_VALUE (yylval.ttype); | |
2788 | } | |
2789 | else | |
2790 | yychar = identifier_type (lastiddecl); | |
2791 | } | |
2792 | } | |
2793 | ||
2794 | tree | |
5566b478 | 2795 | do_identifier (token, parsing) |
8d08fdba | 2796 | register tree token; |
5566b478 | 2797 | int parsing; |
8d08fdba | 2798 | { |
5566b478 | 2799 | register tree id; |
8d08fdba | 2800 | |
5566b478 | 2801 | if (! parsing || IDENTIFIER_OPNAME_P (token)) |
72b7eeff | 2802 | id = lookup_name (token, 0); |
5566b478 MS |
2803 | else |
2804 | id = lastiddecl; | |
72b7eeff | 2805 | |
5566b478 | 2806 | if (parsing && yychar == YYEMPTY) |
8d08fdba MS |
2807 | yychar = yylex (); |
2808 | /* Scope class declarations before global | |
2809 | declarations. */ | |
2810 | if (id == IDENTIFIER_GLOBAL_VALUE (token) | |
2811 | && current_class_type != 0 | |
5566b478 | 2812 | && TYPE_SIZE (current_class_type) == 0) |
8d08fdba MS |
2813 | { |
2814 | /* Could be from one of the base classes. */ | |
2815 | tree field = lookup_field (current_class_type, token, 1, 0); | |
2816 | if (field == 0) | |
2817 | ; | |
2818 | else if (field == error_mark_node) | |
2819 | /* We have already generated the error message. | |
2820 | But we still want to return this value. */ | |
2821 | id = lookup_field (current_class_type, token, 0, 0); | |
2822 | else if (TREE_CODE (field) == VAR_DECL | |
2823 | || TREE_CODE (field) == CONST_DECL) | |
2824 | id = field; | |
2825 | else if (TREE_CODE (field) != FIELD_DECL) | |
2826 | my_friendly_abort (61); | |
2827 | else | |
2828 | { | |
2829 | cp_error ("invalid use of member `%D' from base class `%T'", field, | |
2830 | DECL_FIELD_CONTEXT (field)); | |
2831 | id = error_mark_node; | |
2832 | return id; | |
2833 | } | |
2834 | } | |
2835 | ||
8d2733ca MS |
2836 | /* Remember that this name has been used in the class definition, as per |
2837 | [class.scope0] */ | |
fc378698 | 2838 | if (id && current_class_type && parsing |
8d2733ca | 2839 | && TYPE_BEING_DEFINED (current_class_type) |
bd6dd845 MS |
2840 | && ! IDENTIFIER_CLASS_VALUE (token) |
2841 | /* Avoid breaking if we get called for a default argument that | |
2842 | refers to an overloaded method. Eventually this will not be | |
2843 | necessary, since default arguments shouldn't be parsed until | |
2844 | after the class is complete. (jason 3/12/97) */ | |
2845 | && TREE_CODE (id) != TREE_LIST) | |
8d2733ca MS |
2846 | pushdecl_class_level (id); |
2847 | ||
8d08fdba MS |
2848 | if (!id || id == error_mark_node) |
2849 | { | |
2850 | if (id == error_mark_node && current_class_type != NULL_TREE) | |
2851 | { | |
2852 | id = lookup_nested_field (token, 1); | |
2853 | /* In lookup_nested_field(), we marked this so we can gracefully | |
2854 | leave this whole mess. */ | |
2855 | if (id && id != error_mark_node && TREE_TYPE (id) == error_mark_node) | |
2856 | return id; | |
2857 | } | |
72b7eeff | 2858 | |
5566b478 MS |
2859 | if (current_template_parms) |
2860 | return build_min_nt (LOOKUP_EXPR, token, NULL_TREE); | |
2861 | else if (IDENTIFIER_OPNAME_P (token)) | |
72b7eeff MS |
2862 | { |
2863 | if (token != ansi_opname[ERROR_MARK]) | |
c73964b2 | 2864 | cp_error ("`%D' not defined", token); |
72b7eeff MS |
2865 | id = error_mark_node; |
2866 | } | |
5566b478 | 2867 | else if (parsing && (yychar == '(' || yychar == LEFT_RIGHT)) |
8d08fdba MS |
2868 | { |
2869 | id = implicitly_declare (token); | |
2870 | } | |
2871 | else if (current_function_decl == 0) | |
2872 | { | |
2873 | cp_error ("`%D' was not declared in this scope", token); | |
2874 | id = error_mark_node; | |
2875 | } | |
2876 | else | |
2877 | { | |
2878 | if (IDENTIFIER_GLOBAL_VALUE (token) != error_mark_node | |
2879 | || IDENTIFIER_ERROR_LOCUS (token) != current_function_decl) | |
2880 | { | |
2881 | static int undeclared_variable_notice; | |
2882 | ||
2883 | cp_error ("`%D' undeclared (first use this function)", token); | |
2884 | ||
2885 | if (! undeclared_variable_notice) | |
2886 | { | |
2887 | error ("(Each undeclared identifier is reported only once"); | |
2888 | error ("for each function it appears in.)"); | |
2889 | undeclared_variable_notice = 1; | |
2890 | } | |
2891 | } | |
2892 | id = error_mark_node; | |
2893 | /* Prevent repeated error messages. */ | |
2894 | IDENTIFIER_GLOBAL_VALUE (token) = error_mark_node; | |
2895 | SET_IDENTIFIER_ERROR_LOCUS (token, current_function_decl); | |
2896 | } | |
2897 | } | |
f3be9e3c PB |
2898 | |
2899 | if (TREE_CODE (id) == VAR_DECL && DECL_DEAD_FOR_LOCAL (id)) | |
2900 | { | |
2901 | tree shadowed = DECL_SHADOWED_FOR_VAR (id); | |
2ee887f2 MS |
2902 | while (shadowed != NULL_TREE && TREE_CODE (shadowed) == VAR_DECL |
2903 | && DECL_DEAD_FOR_LOCAL (shadowed)) | |
2904 | shadowed = DECL_SHADOWED_FOR_VAR (shadowed); | |
2905 | if (!shadowed) | |
2906 | shadowed = IDENTIFIER_GLOBAL_VALUE (DECL_NAME (id)); | |
f3be9e3c PB |
2907 | if (shadowed) |
2908 | { | |
2909 | if (!DECL_ERROR_REPORTED (id)) | |
2910 | { | |
2911 | warning ("name lookup of `%s' changed", | |
2912 | IDENTIFIER_POINTER (token)); | |
2913 | cp_warning_at (" matches this `%D' under current ANSI rules", | |
2914 | shadowed); | |
2915 | cp_warning_at (" matches this `%D' under old rules", id); | |
2916 | DECL_ERROR_REPORTED (id) = 1; | |
2917 | } | |
2918 | id = shadowed; | |
2919 | } | |
2920 | else if (!DECL_ERROR_REPORTED (id)) | |
2921 | { | |
2922 | static char msg[] | |
2923 | = "name lookup of `%s' changed for new ANSI `for' scoping"; | |
2924 | DECL_ERROR_REPORTED (id) = 1; | |
2925 | if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (id))) | |
2926 | { | |
2927 | error (msg, IDENTIFIER_POINTER (token)); | |
2928 | cp_error_at (" cannot use obsolete binding at `%D' because it has a destructor", id); | |
2929 | id = error_mark_node; | |
2930 | } | |
2931 | else | |
2932 | { | |
2933 | pedwarn (msg, IDENTIFIER_POINTER (token)); | |
2934 | cp_pedwarn_at (" using obsolete binding at `%D'", id); | |
2935 | } | |
2936 | } | |
2937 | } | |
8d08fdba MS |
2938 | /* TREE_USED is set in `hack_identifier'. */ |
2939 | if (TREE_CODE (id) == CONST_DECL) | |
2940 | { | |
2941 | if (IDENTIFIER_CLASS_VALUE (token) == id) | |
2942 | { | |
2943 | /* Check access. */ | |
be99da77 MS |
2944 | tree access = compute_access (TYPE_BINFO (current_class_type), id); |
2945 | if (access == access_private_node) | |
8d08fdba MS |
2946 | cp_error ("enum `%D' is private", id); |
2947 | /* protected is OK, since it's an enum of `this'. */ | |
2948 | } | |
5156628f | 2949 | if (! processing_template_decl |
5566b478 MS |
2950 | || (DECL_INITIAL (id) |
2951 | && TREE_CODE (DECL_INITIAL (id)) == TEMPLATE_CONST_PARM)) | |
2952 | id = DECL_INITIAL (id); | |
8d08fdba MS |
2953 | } |
2954 | else | |
5566b478 MS |
2955 | id = hack_identifier (id, token); |
2956 | ||
2957 | if (current_template_parms) | |
2958 | { | |
2959 | if (is_overloaded_fn (id)) | |
2960 | { | |
2961 | tree t = build_min (LOOKUP_EXPR, unknown_type_node, | |
2962 | token, get_first_fn (id)); | |
2963 | if (id != IDENTIFIER_GLOBAL_VALUE (token)) | |
2964 | TREE_OPERAND (t, 1) = error_mark_node; | |
2965 | id = t; | |
2966 | } | |
2967 | else if (! TREE_PERMANENT (id) || TREE_CODE (id) == PARM_DECL | |
2968 | || TREE_CODE (id) == USING_DECL) | |
2969 | id = build_min (LOOKUP_EXPR, TREE_TYPE (id), token, error_mark_node); | |
2970 | /* else just use the decl */ | |
2971 | } | |
2972 | ||
2973 | return id; | |
2974 | } | |
2975 | ||
2976 | tree | |
2977 | do_scoped_id (token, parsing) | |
2978 | tree token; | |
2979 | int parsing; | |
2980 | { | |
2981 | tree id = IDENTIFIER_GLOBAL_VALUE (token); | |
2982 | if (parsing && yychar == YYEMPTY) | |
2983 | yychar = yylex (); | |
2984 | if (! id) | |
2985 | { | |
5156628f | 2986 | if (processing_template_decl) |
5566b478 MS |
2987 | { |
2988 | id = build_min_nt (LOOKUP_EXPR, token, NULL_TREE); | |
2989 | LOOKUP_EXPR_GLOBAL (id) = 1; | |
2990 | return id; | |
2991 | } | |
2992 | if (parsing && yychar == '(' || yychar == LEFT_RIGHT) | |
2993 | id = implicitly_declare (token); | |
2994 | else | |
2995 | { | |
2996 | if (IDENTIFIER_GLOBAL_VALUE (token) != error_mark_node) | |
2997 | error ("undeclared variable `%s' (first use here)", | |
2998 | IDENTIFIER_POINTER (token)); | |
2999 | id = error_mark_node; | |
3000 | /* Prevent repeated error messages. */ | |
3001 | IDENTIFIER_GLOBAL_VALUE (token) = error_mark_node; | |
3002 | } | |
3003 | } | |
3004 | else | |
3005 | { | |
3006 | if (TREE_CODE (id) == ADDR_EXPR) | |
3007 | mark_used (TREE_OPERAND (id, 0)); | |
3008 | else if (TREE_CODE (id) != TREE_LIST) | |
3009 | mark_used (id); | |
3010 | } | |
5156628f | 3011 | if (TREE_CODE (id) == CONST_DECL && ! processing_template_decl) |
5566b478 MS |
3012 | { |
3013 | /* XXX CHS - should we set TREE_USED of the constant? */ | |
3014 | id = DECL_INITIAL (id); | |
3015 | /* This is to prevent an enum whose value is 0 | |
3016 | from being considered a null pointer constant. */ | |
3017 | id = build1 (NOP_EXPR, TREE_TYPE (id), id); | |
3018 | TREE_CONSTANT (id) = 1; | |
3019 | } | |
3020 | ||
5156628f | 3021 | if (processing_template_decl) |
5566b478 MS |
3022 | { |
3023 | if (is_overloaded_fn (id)) | |
3024 | { | |
3025 | id = build_min (LOOKUP_EXPR, unknown_type_node, | |
3026 | token, get_first_fn (id)); | |
3027 | LOOKUP_EXPR_GLOBAL (id) = 1; | |
3028 | } | |
3029 | /* else just use the decl */ | |
3030 | } | |
42976354 | 3031 | return convert_from_reference (id); |
8d08fdba MS |
3032 | } |
3033 | ||
3034 | tree | |
3035 | identifier_typedecl_value (node) | |
3036 | tree node; | |
3037 | { | |
3038 | tree t, type; | |
3039 | type = IDENTIFIER_TYPE_VALUE (node); | |
3040 | if (type == NULL_TREE) | |
3041 | return NULL_TREE; | |
3042 | #define do(X) \ | |
3043 | { \ | |
3044 | t = (X); \ | |
3045 | if (t && TREE_CODE (t) == TYPE_DECL && TREE_TYPE (t) == type) \ | |
3046 | return t; \ | |
3047 | } | |
3048 | do (IDENTIFIER_LOCAL_VALUE (node)); | |
3049 | do (IDENTIFIER_CLASS_VALUE (node)); | |
3050 | do (IDENTIFIER_GLOBAL_VALUE (node)); | |
3051 | #undef do | |
3052 | /* Will this one ever happen? */ | |
d2e5ee5c MS |
3053 | if (TYPE_MAIN_DECL (type)) |
3054 | return TYPE_MAIN_DECL (type); | |
8d08fdba MS |
3055 | |
3056 | /* We used to do an internal error of 62 here, but instead we will | |
3057 | handle the return of a null appropriately in the callers. */ | |
3058 | return NULL_TREE; | |
3059 | } | |
3060 | ||
8d08fdba MS |
3061 | int |
3062 | real_yylex () | |
3063 | { | |
3064 | register int c; | |
3065 | register int value; | |
3066 | int wide_flag = 0; | |
3067 | int dollar_seen = 0; | |
3068 | int i; | |
3069 | ||
3070 | if (nextchar >= 0) | |
3071 | c = nextchar, nextchar = -1; | |
3072 | else | |
3073 | c = getch (); | |
3074 | ||
3075 | /* Effectively do c = skip_white_space (c) | |
3076 | but do it faster in the usual cases. */ | |
3077 | while (1) | |
3078 | switch (c) | |
3079 | { | |
3080 | case ' ': | |
3081 | case '\t': | |
3082 | case '\f': | |
3083 | case '\v': | |
3084 | case '\b': | |
3085 | c = getch (); | |
3086 | break; | |
3087 | ||
3088 | case '\r': | |
3089 | /* Call skip_white_space so we can warn if appropriate. */ | |
3090 | ||
3091 | case '\n': | |
3092 | case '/': | |
3093 | case '\\': | |
3094 | c = skip_white_space (c); | |
3095 | default: | |
3096 | goto found_nonwhite; | |
3097 | } | |
3098 | found_nonwhite: | |
3099 | ||
3100 | token_buffer[0] = c; | |
3101 | token_buffer[1] = 0; | |
3102 | ||
3103 | /* yylloc.first_line = lineno; */ | |
3104 | ||
3105 | switch (c) | |
3106 | { | |
3107 | case EOF: | |
3108 | token_buffer[0] = '\0'; | |
3109 | end_of_file = 1; | |
3110 | if (input_redirected ()) | |
3111 | value = END_OF_SAVED_INPUT; | |
d18c083e MS |
3112 | else if (linemode) |
3113 | value = END_OF_LINE; | |
8d08fdba MS |
3114 | else |
3115 | value = ENDFILE; | |
3116 | break; | |
3117 | ||
3118 | case '$': | |
4f6140be PE |
3119 | if (! dollars_in_ident) |
3120 | error ("`$' in identifier"); | |
3121 | else if (pedantic) | |
3122 | pedwarn ("`$' in identifier"); | |
3123 | dollar_seen = 1; | |
3124 | goto letter; | |
8d08fdba MS |
3125 | |
3126 | case 'L': | |
3127 | /* Capital L may start a wide-string or wide-character constant. */ | |
3128 | { | |
3129 | register int c = getch (); | |
3130 | if (c == '\'') | |
3131 | { | |
3132 | wide_flag = 1; | |
3133 | goto char_constant; | |
3134 | } | |
3135 | if (c == '"') | |
3136 | { | |
3137 | wide_flag = 1; | |
3138 | goto string_constant; | |
3139 | } | |
3140 | put_back (c); | |
3141 | } | |
3142 | ||
3143 | case 'A': case 'B': case 'C': case 'D': case 'E': | |
3144 | case 'F': case 'G': case 'H': case 'I': case 'J': | |
3145 | case 'K': case 'M': case 'N': case 'O': | |
3146 | case 'P': case 'Q': case 'R': case 'S': case 'T': | |
3147 | case 'U': case 'V': case 'W': case 'X': case 'Y': | |
3148 | case 'Z': | |
3149 | case 'a': case 'b': case 'c': case 'd': case 'e': | |
3150 | case 'f': case 'g': case 'h': case 'i': case 'j': | |
3151 | case 'k': case 'l': case 'm': case 'n': case 'o': | |
3152 | case 'p': case 'q': case 'r': case 's': case 't': | |
3153 | case 'u': case 'v': case 'w': case 'x': case 'y': | |
3154 | case 'z': | |
3155 | case '_': | |
3156 | letter: | |
3157 | { | |
3158 | register char *p; | |
3159 | ||
3160 | p = token_buffer; | |
3161 | if (input == 0) | |
3162 | { | |
3163 | /* We know that `token_buffer' can hold at least on char, | |
3164 | so we install C immediately. | |
3165 | We may have to read the value in `putback_char', so call | |
3166 | `getch' once. */ | |
3167 | *p++ = c; | |
3168 | c = getch (); | |
3169 | ||
3170 | /* Make this run fast. We know that we are reading straight | |
3171 | from FINPUT in this case (since identifiers cannot straddle | |
3172 | input sources. */ | |
3173 | while (isalnum (c) || (c == '_') || c == '$') | |
3174 | { | |
4f6140be PE |
3175 | if (c == '$') |
3176 | { | |
3177 | if (! dollars_in_ident) | |
3178 | error ("`$' in identifier"); | |
3179 | else if (pedantic) | |
3180 | pedwarn ("`$' in identifier"); | |
3181 | } | |
3182 | ||
8d08fdba MS |
3183 | if (p >= token_buffer + maxtoken) |
3184 | p = extend_token_buffer (p); | |
3185 | ||
3186 | *p++ = c; | |
8975416c | 3187 | c = getch (); |
8d08fdba | 3188 | } |
f30432d7 MS |
3189 | |
3190 | if (linemode && c == '\n') | |
3191 | { | |
3192 | put_back (c); | |
3193 | c = EOF; | |
3194 | } | |
8d08fdba MS |
3195 | } |
3196 | else | |
3197 | { | |
3198 | /* We know that `token_buffer' can hold at least on char, | |
3199 | so we install C immediately. */ | |
3200 | *p++ = c; | |
3201 | c = getch (); | |
3202 | ||
3203 | while (isalnum (c) || (c == '_') || c == '$') | |
3204 | { | |
4f6140be PE |
3205 | if (c == '$') |
3206 | { | |
3207 | if (! dollars_in_ident) | |
3208 | error ("`$' in identifier"); | |
3209 | else if (pedantic) | |
3210 | pedwarn ("`$' in identifier"); | |
3211 | } | |
3212 | ||
8d08fdba MS |
3213 | if (p >= token_buffer + maxtoken) |
3214 | p = extend_token_buffer (p); | |
3215 | ||
3216 | *p++ = c; | |
3217 | c = getch (); | |
3218 | } | |
3219 | } | |
3220 | ||
3221 | *p = 0; | |
3222 | nextchar = c; | |
3223 | ||
3224 | value = IDENTIFIER; | |
3225 | yylval.itype = 0; | |
3226 | ||
3227 | /* Try to recognize a keyword. Uses minimum-perfect hash function */ | |
3228 | ||
3229 | { | |
3230 | register struct resword *ptr; | |
3231 | ||
3232 | if (ptr = is_reserved_word (token_buffer, p - token_buffer)) | |
3233 | { | |
3234 | if (ptr->rid) | |
3235 | { | |
3236 | tree old_ttype = ridpointers[(int) ptr->rid]; | |
3237 | ||
3238 | /* If this provides a type for us, then revert lexical | |
3239 | state to standard state. */ | |
3240 | if (TREE_CODE (old_ttype) == IDENTIFIER_NODE | |
3241 | && IDENTIFIER_GLOBAL_VALUE (old_ttype) != 0 | |
3242 | && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (old_ttype)) == TYPE_DECL) | |
3243 | looking_for_typename = 0; | |
3244 | else if (ptr->token == AGGR || ptr->token == ENUM) | |
3245 | looking_for_typename = 1; | |
3246 | ||
3247 | /* Check if this is a language-type declaration. | |
3248 | Just glimpse the next non-white character. */ | |
3249 | nextchar = skip_white_space (nextchar); | |
3250 | if (nextchar == '"') | |
3251 | { | |
3252 | /* We are looking at a string. Complain | |
3253 | if the token before the string is no `extern'. | |
3254 | ||
3255 | Could cheat some memory by placing this string | |
3256 | on the temporary_, instead of the saveable_ | |
3257 | obstack. */ | |
3258 | ||
3259 | if (ptr->rid != RID_EXTERN) | |
3260 | error ("invalid modifier `%s' for language string", | |
3261 | ptr->name); | |
3262 | real_yylex (); | |
3263 | value = EXTERN_LANG_STRING; | |
3264 | yylval.ttype = get_identifier (TREE_STRING_POINTER (yylval.ttype)); | |
3265 | break; | |
3266 | } | |
3267 | if (ptr->token == VISSPEC) | |
3268 | { | |
3269 | switch (ptr->rid) | |
3270 | { | |
3271 | case RID_PUBLIC: | |
be99da77 | 3272 | yylval.ttype = access_public_node; |
8d08fdba MS |
3273 | break; |
3274 | case RID_PRIVATE: | |
be99da77 | 3275 | yylval.ttype = access_private_node; |
8d08fdba MS |
3276 | break; |
3277 | case RID_PROTECTED: | |
be99da77 | 3278 | yylval.ttype = access_protected_node; |
8d08fdba MS |
3279 | break; |
3280 | default: | |
3281 | my_friendly_abort (63); | |
3282 | } | |
3283 | } | |
3284 | else | |
3285 | yylval.ttype = old_ttype; | |
3286 | } | |
db5ae43f MS |
3287 | else if (ptr->token == EQCOMPARE) |
3288 | { | |
3289 | yylval.code = NE_EXPR; | |
3290 | token_buffer[0] = '!'; | |
3291 | token_buffer[1] = '='; | |
3292 | token_buffer[2] = 0; | |
3293 | } | |
3294 | else if (ptr->token == ASSIGN) | |
3295 | { | |
3296 | if (strcmp ("and_eq", token_buffer) == 0) | |
3297 | { | |
3298 | yylval.code = BIT_AND_EXPR; | |
3299 | token_buffer[0] = '&'; | |
3300 | } | |
3301 | else if (strcmp ("or_eq", token_buffer) == 0) | |
3302 | { | |
3303 | yylval.code = BIT_IOR_EXPR; | |
3304 | token_buffer[0] = '|'; | |
3305 | } | |
3306 | else if (strcmp ("xor_eq", token_buffer) == 0) | |
3307 | { | |
3308 | yylval.code = BIT_XOR_EXPR; | |
3309 | token_buffer[0] = '^'; | |
3310 | } | |
3311 | token_buffer[1] = '='; | |
3312 | token_buffer[2] = 0; | |
3313 | } | |
3314 | else if (ptr->token == '&') | |
3315 | { | |
3316 | yylval.code = BIT_AND_EXPR; | |
3317 | token_buffer[0] = '&'; | |
3318 | token_buffer[1] = 0; | |
3319 | } | |
3320 | else if (ptr->token == '|') | |
3321 | { | |
3322 | yylval.code = BIT_IOR_EXPR; | |
3323 | token_buffer[0] = '|'; | |
3324 | token_buffer[1] = 0; | |
3325 | } | |
3326 | else if (ptr->token == '^') | |
3327 | { | |
3328 | yylval.code = BIT_XOR_EXPR; | |
3329 | token_buffer[0] = '^'; | |
3330 | token_buffer[1] = 0; | |
3331 | } | |
3332 | ||
8d08fdba MS |
3333 | value = (int) ptr->token; |
3334 | } | |
3335 | } | |
3336 | ||
3337 | /* If we did not find a keyword, look for an identifier | |
3338 | (or a typename). */ | |
3339 | ||
8d08fdba MS |
3340 | if (value == IDENTIFIER || value == TYPESPEC) |
3341 | GNU_xref_ref (current_function_decl, token_buffer); | |
3342 | ||
3343 | if (value == IDENTIFIER) | |
3344 | { | |
3345 | register tree tmp = get_identifier (token_buffer); | |
3346 | ||
3347 | #if !defined(VMS) && defined(JOINER) | |
3348 | /* Make sure that user does not collide with our internal | |
3349 | naming scheme. */ | |
3350 | if (JOINER == '$' | |
3351 | && dollar_seen | |
3352 | && (THIS_NAME_P (tmp) | |
3353 | || VPTR_NAME_P (tmp) | |
3354 | || DESTRUCTOR_NAME_P (tmp) | |
3355 | || VTABLE_NAME_P (tmp) | |
3356 | || TEMP_NAME_P (tmp) | |
3357 | || ANON_AGGRNAME_P (tmp) | |
3358 | || ANON_PARMNAME_P (tmp))) | |
3359 | warning ("identifier name `%s' conflicts with GNU C++ internal naming strategy", | |
3360 | token_buffer); | |
3361 | #endif | |
3362 | ||
3363 | yylval.ttype = tmp; | |
8d08fdba MS |
3364 | } |
3365 | if (value == NEW && ! global_bindings_p ()) | |
3366 | { | |
8d08fdba MS |
3367 | value = NEW; |
3368 | goto done; | |
3369 | } | |
3370 | } | |
3371 | break; | |
3372 | ||
3373 | case '.': | |
3374 | { | |
3375 | register int c1 = getch (); | |
3376 | token_buffer[0] = c; | |
3377 | token_buffer[1] = c1; | |
3378 | if (c1 == '*') | |
3379 | { | |
3380 | value = DOT_STAR; | |
3381 | token_buffer[2] = 0; | |
3382 | goto done; | |
3383 | } | |
3384 | if (c1 == '.') | |
3385 | { | |
3386 | c1 = getch (); | |
3387 | if (c1 == '.') | |
3388 | { | |
3389 | token_buffer[2] = c1; | |
3390 | token_buffer[3] = 0; | |
3391 | value = ELLIPSIS; | |
3392 | goto done; | |
3393 | } | |
f0e01782 | 3394 | error ("parse error at `..'"); |
8d08fdba MS |
3395 | } |
3396 | if (isdigit (c1)) | |
3397 | { | |
3398 | put_back (c1); | |
3399 | goto resume_numerical_scan; | |
3400 | } | |
3401 | nextchar = c1; | |
3402 | value = '.'; | |
3403 | token_buffer[1] = 0; | |
3404 | goto done; | |
3405 | } | |
3406 | case '0': case '1': | |
3407 | /* Optimize for most frequent case. */ | |
3408 | { | |
3409 | register int c1 = getch (); | |
3410 | if (! isalnum (c1) && c1 != '.') | |
3411 | { | |
3412 | /* Terminate string. */ | |
3413 | token_buffer[0] = c; | |
3414 | token_buffer[1] = 0; | |
3415 | if (c == '0') | |
3416 | yylval.ttype = integer_zero_node; | |
3417 | else | |
3418 | yylval.ttype = integer_one_node; | |
3419 | nextchar = c1; | |
3420 | value = CONSTANT; | |
3421 | goto done; | |
3422 | } | |
3423 | put_back (c1); | |
3424 | } | |
e92cc029 | 3425 | /* fall through... */ |
8d08fdba MS |
3426 | case '2': case '3': case '4': |
3427 | case '5': case '6': case '7': case '8': case '9': | |
3428 | resume_numerical_scan: | |
3429 | { | |
3430 | register char *p; | |
3431 | int base = 10; | |
3432 | int count = 0; | |
3433 | int largest_digit = 0; | |
3434 | int numdigits = 0; | |
3435 | /* for multi-precision arithmetic, | |
3436 | we actually store only HOST_BITS_PER_CHAR bits in each part. | |
3437 | The number of parts is chosen so as to be sufficient to hold | |
3438 | the enough bits to fit into the two HOST_WIDE_INTs that contain | |
3439 | the integer value (this is always at least as many bits as are | |
3440 | in a target `long long' value, but may be wider). */ | |
3441 | #define TOTAL_PARTS ((HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2 + 2) | |
3442 | int parts[TOTAL_PARTS]; | |
3443 | int overflow = 0; | |
3444 | ||
3445 | enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS} floatflag | |
3446 | = NOT_FLOAT; | |
3447 | ||
8d08fdba MS |
3448 | for (count = 0; count < TOTAL_PARTS; count++) |
3449 | parts[count] = 0; | |
3450 | ||
37c46b43 MS |
3451 | p = token_buffer; |
3452 | *p++ = c; | |
3453 | ||
8d08fdba MS |
3454 | if (c == '0') |
3455 | { | |
3456 | *p++ = (c = getch ()); | |
3457 | if ((c == 'x') || (c == 'X')) | |
3458 | { | |
3459 | base = 16; | |
3460 | *p++ = (c = getch ()); | |
3461 | } | |
3462 | /* Leading 0 forces octal unless the 0 is the only digit. */ | |
3463 | else if (c >= '0' && c <= '9') | |
3464 | { | |
3465 | base = 8; | |
3466 | numdigits++; | |
3467 | } | |
3468 | else | |
3469 | numdigits++; | |
3470 | } | |
3471 | ||
3472 | /* Read all the digits-and-decimal-points. */ | |
3473 | ||
3474 | while (c == '.' | |
3475 | || (isalnum (c) && (c != 'l') && (c != 'L') | |
3476 | && (c != 'u') && (c != 'U') | |
37c46b43 | 3477 | && c != 'i' && c != 'I' && c != 'j' && c != 'J' |
8d08fdba MS |
3478 | && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F'))))) |
3479 | { | |
3480 | if (c == '.') | |
3481 | { | |
3482 | if (base == 16) | |
3483 | error ("floating constant may not be in radix 16"); | |
37c46b43 MS |
3484 | if (floatflag == TOO_MANY_POINTS) |
3485 | /* We have already emitted an error. Don't need another. */ | |
3486 | ; | |
3487 | else if (floatflag == AFTER_POINT) | |
8d08fdba MS |
3488 | { |
3489 | error ("malformed floating constant"); | |
3490 | floatflag = TOO_MANY_POINTS; | |
37c46b43 MS |
3491 | /* Avoid another error from atof by forcing all characters |
3492 | from here on to be ignored. */ | |
3493 | p[-1] = '\0'; | |
8d08fdba MS |
3494 | } |
3495 | else | |
3496 | floatflag = AFTER_POINT; | |
3497 | ||
3498 | base = 10; | |
3499 | *p++ = c = getch (); | |
3500 | /* Accept '.' as the start of a floating-point number | |
3501 | only when it is followed by a digit. | |
3502 | Otherwise, unread the following non-digit | |
3503 | and use the '.' as a structural token. */ | |
3504 | if (p == token_buffer + 2 && !isdigit (c)) | |
3505 | { | |
3506 | if (c == '.') | |
3507 | { | |
3508 | c = getch (); | |
3509 | if (c == '.') | |
3510 | { | |
3511 | *p++ = '.'; | |
3512 | *p = '\0'; | |
3513 | value = ELLIPSIS; | |
3514 | goto done; | |
3515 | } | |
f0e01782 | 3516 | error ("parse error at `..'"); |
8d08fdba MS |
3517 | } |
3518 | nextchar = c; | |
3519 | token_buffer[1] = '\0'; | |
3520 | value = '.'; | |
3521 | goto done; | |
3522 | } | |
3523 | } | |
3524 | else | |
3525 | { | |
3526 | /* It is not a decimal point. | |
3527 | It should be a digit (perhaps a hex digit). */ | |
3528 | ||
3529 | if (isdigit (c)) | |
3530 | { | |
3531 | c = c - '0'; | |
3532 | } | |
3533 | else if (base <= 10) | |
3534 | { | |
3535 | if (c == 'e' || c == 'E') | |
3536 | { | |
3537 | base = 10; | |
3538 | floatflag = AFTER_POINT; | |
3539 | break; /* start of exponent */ | |
3540 | } | |
3541 | error ("nondigits in number and not hexadecimal"); | |
3542 | c = 0; | |
3543 | } | |
3544 | else if (c >= 'a') | |
3545 | { | |
3546 | c = c - 'a' + 10; | |
3547 | } | |
3548 | else | |
3549 | { | |
3550 | c = c - 'A' + 10; | |
3551 | } | |
3552 | if (c >= largest_digit) | |
3553 | largest_digit = c; | |
3554 | numdigits++; | |
3555 | ||
3556 | for (count = 0; count < TOTAL_PARTS; count++) | |
3557 | { | |
3558 | parts[count] *= base; | |
3559 | if (count) | |
3560 | { | |
3561 | parts[count] | |
3562 | += (parts[count-1] >> HOST_BITS_PER_CHAR); | |
3563 | parts[count-1] | |
3564 | &= (1 << HOST_BITS_PER_CHAR) - 1; | |
3565 | } | |
3566 | else | |
3567 | parts[0] += c; | |
3568 | } | |
3569 | ||
3570 | /* If the extra highest-order part ever gets anything in it, | |
3571 | the number is certainly too big. */ | |
3572 | if (parts[TOTAL_PARTS - 1] != 0) | |
3573 | overflow = 1; | |
3574 | ||
3575 | if (p >= token_buffer + maxtoken - 3) | |
3576 | p = extend_token_buffer (p); | |
3577 | *p++ = (c = getch ()); | |
3578 | } | |
3579 | } | |
3580 | ||
3581 | if (numdigits == 0) | |
3582 | error ("numeric constant with no digits"); | |
3583 | ||
3584 | if (largest_digit >= base) | |
3585 | error ("numeric constant contains digits beyond the radix"); | |
3586 | ||
3587 | /* Remove terminating char from the token buffer and delimit the string */ | |
3588 | *--p = 0; | |
3589 | ||
3590 | if (floatflag != NOT_FLOAT) | |
3591 | { | |
3592 | tree type = double_type_node; | |
37c46b43 MS |
3593 | int exceeds_double = 0; |
3594 | int imag = 0; | |
8d08fdba MS |
3595 | REAL_VALUE_TYPE value; |
3596 | jmp_buf handler; | |
3597 | ||
3598 | /* Read explicit exponent if any, and put it in tokenbuf. */ | |
3599 | ||
3600 | if ((c == 'e') || (c == 'E')) | |
3601 | { | |
3602 | if (p >= token_buffer + maxtoken - 3) | |
3603 | p = extend_token_buffer (p); | |
3604 | *p++ = c; | |
3605 | c = getch (); | |
3606 | if ((c == '+') || (c == '-')) | |
3607 | { | |
3608 | *p++ = c; | |
3609 | c = getch (); | |
3610 | } | |
3611 | if (! isdigit (c)) | |
3612 | error ("floating constant exponent has no digits"); | |
3613 | while (isdigit (c)) | |
3614 | { | |
3615 | if (p >= token_buffer + maxtoken - 3) | |
3616 | p = extend_token_buffer (p); | |
3617 | *p++ = c; | |
3618 | c = getch (); | |
3619 | } | |
3620 | } | |
3621 | ||
3622 | *p = 0; | |
3623 | errno = 0; | |
3624 | ||
3625 | /* Convert string to a double, checking for overflow. */ | |
3626 | if (setjmp (handler)) | |
3627 | { | |
3628 | error ("floating constant out of range"); | |
3629 | value = dconst0; | |
3630 | } | |
3631 | else | |
3632 | { | |
37c46b43 MS |
3633 | int fflag = 0, lflag = 0; |
3634 | /* Copy token_buffer now, while it has just the number | |
3635 | and not the suffixes; once we add `f' or `i', | |
3636 | REAL_VALUE_ATOF may not work any more. */ | |
3637 | char *copy = (char *) alloca (p - token_buffer + 1); | |
3638 | bcopy (token_buffer, copy, p - token_buffer + 1); | |
3639 | ||
8d08fdba | 3640 | set_float_handler (handler); |
8d08fdba | 3641 | |
37c46b43 | 3642 | while (1) |
8d08fdba | 3643 | { |
37c46b43 | 3644 | int lose = 0; |
8d08fdba | 3645 | |
37c46b43 MS |
3646 | /* Read the suffixes to choose a data type. */ |
3647 | switch (c) | |
3648 | { | |
3649 | case 'f': case 'F': | |
3650 | if (fflag) | |
3651 | error ("more than one `f' in numeric constant"); | |
3652 | fflag = 1; | |
3653 | break; | |
3654 | ||
3655 | case 'l': case 'L': | |
3656 | if (lflag) | |
3657 | error ("more than one `l' in numeric constant"); | |
3658 | lflag = 1; | |
3659 | break; | |
3660 | ||
3661 | case 'i': case 'I': | |
3662 | if (imag) | |
3663 | error ("more than one `i' or `j' in numeric constant"); | |
3664 | else if (pedantic) | |
3665 | pedwarn ("ANSI C++ forbids imaginary numeric constants"); | |
3666 | imag = 1; | |
3667 | break; | |
3668 | ||
3669 | default: | |
3670 | lose = 1; | |
3671 | } | |
8d08fdba | 3672 | |
37c46b43 MS |
3673 | if (lose) |
3674 | break; | |
3675 | ||
3676 | if (p >= token_buffer + maxtoken - 3) | |
3677 | p = extend_token_buffer (p); | |
3678 | *p++ = c; | |
3679 | *p = 0; | |
8975416c | 3680 | c = getch (); |
37c46b43 MS |
3681 | } |
3682 | ||
3683 | /* The second argument, machine_mode, of REAL_VALUE_ATOF | |
3684 | tells the desired precision of the binary result | |
3685 | of decimal-to-binary conversion. */ | |
3686 | ||
3687 | if (fflag) | |
3688 | { | |
3689 | if (lflag) | |
3690 | error ("both `f' and `l' in floating constant"); | |
3691 | ||
3692 | type = float_type_node; | |
3693 | value = REAL_VALUE_ATOF (copy, TYPE_MODE (type)); | |
3694 | /* A diagnostic is required here by some ANSI C testsuites. | |
3695 | This is not pedwarn, become some people don't want | |
3696 | an error for this. */ | |
3697 | if (REAL_VALUE_ISINF (value) && pedantic) | |
3698 | warning ("floating point number exceeds range of `float'"); | |
3699 | } | |
3700 | else if (lflag) | |
3701 | { | |
3702 | type = long_double_type_node; | |
3703 | value = REAL_VALUE_ATOF (copy, TYPE_MODE (type)); | |
3704 | if (REAL_VALUE_ISINF (value) && pedantic) | |
3705 | warning ("floating point number exceeds range of `long double'"); | |
3706 | } | |
3707 | else | |
3708 | { | |
3709 | value = REAL_VALUE_ATOF (copy, TYPE_MODE (type)); | |
3710 | if (REAL_VALUE_ISINF (value) && pedantic) | |
3711 | warning ("floating point number exceeds range of `double'"); | |
8d08fdba | 3712 | } |
37c46b43 | 3713 | |
8d08fdba MS |
3714 | set_float_handler (NULL_PTR); |
3715 | } | |
8d08fdba | 3716 | #ifdef ERANGE |
37c46b43 | 3717 | if (errno == ERANGE && pedantic) |
8d08fdba | 3718 | { |
37c46b43 MS |
3719 | /* ERANGE is also reported for underflow, |
3720 | so test the value to distinguish overflow from that. */ | |
3721 | if (REAL_VALUES_LESS (dconst1, value) | |
3722 | || REAL_VALUES_LESS (value, dconstm1)) | |
8d08fdba | 3723 | { |
37c46b43 MS |
3724 | pedwarn ("floating point number exceeds range of `%s'", |
3725 | IDENTIFIER_POINTER (TYPE_IDENTIFIER (type))); | |
3726 | exceeds_double = 1; | |
8d08fdba | 3727 | } |
8d08fdba | 3728 | } |
37c46b43 | 3729 | #endif |
8d08fdba | 3730 | |
37c46b43 MS |
3731 | /* If the result is not a number, assume it must have been |
3732 | due to some error message above, so silently convert | |
3733 | it to a zero. */ | |
3734 | if (REAL_VALUE_ISNAN (value)) | |
3735 | value = dconst0; | |
8d08fdba MS |
3736 | |
3737 | /* Create a node with determined type and value. */ | |
37c46b43 MS |
3738 | if (imag) |
3739 | yylval.ttype = build_complex (NULL_TREE, | |
3740 | cp_convert (type, integer_zero_node), | |
3741 | build_real (type, value)); | |
3742 | else | |
3743 | yylval.ttype = build_real (type, value); | |
8d08fdba MS |
3744 | } |
3745 | else | |
3746 | { | |
3747 | tree type; | |
3748 | HOST_WIDE_INT high, low; | |
3749 | int spec_unsigned = 0; | |
3750 | int spec_long = 0; | |
3751 | int spec_long_long = 0; | |
37c46b43 | 3752 | int spec_imag = 0; |
8d08fdba MS |
3753 | int bytes, warn; |
3754 | ||
3755 | while (1) | |
3756 | { | |
3757 | if (c == 'u' || c == 'U') | |
3758 | { | |
3759 | if (spec_unsigned) | |
3760 | error ("two `u's in integer constant"); | |
3761 | spec_unsigned = 1; | |
3762 | } | |
3763 | else if (c == 'l' || c == 'L') | |
3764 | { | |
3765 | if (spec_long) | |
3766 | { | |
3767 | if (spec_long_long) | |
3768 | error ("three `l's in integer constant"); | |
3769 | else if (pedantic) | |
3770 | pedwarn ("ANSI C++ forbids long long integer constants"); | |
3771 | spec_long_long = 1; | |
3772 | } | |
3773 | spec_long = 1; | |
3774 | } | |
37c46b43 | 3775 | else if (c == 'i' || c == 'j' || c == 'I' || c == 'J') |
8d08fdba | 3776 | { |
37c46b43 MS |
3777 | if (spec_imag) |
3778 | error ("more than one `i' or `j' in numeric constant"); | |
3779 | else if (pedantic) | |
3780 | pedwarn ("ANSI C++ forbids imaginary numeric constants"); | |
3781 | spec_imag = 1; | |
8d08fdba | 3782 | } |
37c46b43 MS |
3783 | else |
3784 | break; | |
8d08fdba MS |
3785 | if (p >= token_buffer + maxtoken - 3) |
3786 | p = extend_token_buffer (p); | |
3787 | *p++ = c; | |
8975416c | 3788 | c = getch (); |
8d08fdba MS |
3789 | } |
3790 | ||
8d08fdba MS |
3791 | /* If the constant is not long long and it won't fit in an |
3792 | unsigned long, or if the constant is long long and won't fit | |
3793 | in an unsigned long long, then warn that the constant is out | |
3794 | of range. */ | |
3795 | ||
3796 | /* ??? This assumes that long long and long integer types are | |
3797 | a multiple of 8 bits. This better than the original code | |
3798 | though which assumed that long was exactly 32 bits and long | |
3799 | long was exactly 64 bits. */ | |
3800 | ||
3801 | if (spec_long_long) | |
3802 | bytes = TYPE_PRECISION (long_long_integer_type_node) / 8; | |
3803 | else | |
3804 | bytes = TYPE_PRECISION (long_integer_type_node) / 8; | |
3805 | ||
3806 | warn = overflow; | |
3807 | for (i = bytes; i < TOTAL_PARTS; i++) | |
3808 | if (parts[i]) | |
3809 | warn = 1; | |
3810 | if (warn) | |
3811 | pedwarn ("integer constant out of range"); | |
3812 | ||
3813 | /* This is simplified by the fact that our constant | |
3814 | is always positive. */ | |
3815 | high = low = 0; | |
3816 | ||
3817 | for (i = 0; i < HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR; i++) | |
3818 | { | |
3819 | high |= ((HOST_WIDE_INT) parts[i + (HOST_BITS_PER_WIDE_INT | |
3820 | / HOST_BITS_PER_CHAR)] | |
3821 | << (i * HOST_BITS_PER_CHAR)); | |
3822 | low |= (HOST_WIDE_INT) parts[i] << (i * HOST_BITS_PER_CHAR); | |
3823 | } | |
3824 | ||
3825 | ||
3826 | yylval.ttype = build_int_2 (low, high); | |
3827 | TREE_TYPE (yylval.ttype) = long_long_unsigned_type_node; | |
3828 | ||
a3f44a13 | 3829 | /* Calculate the ANSI type. */ |
8d08fdba | 3830 | if (!spec_long && !spec_unsigned |
8d08fdba | 3831 | && int_fits_type_p (yylval.ttype, integer_type_node)) |
a3f44a13 | 3832 | type = integer_type_node; |
8d08fdba MS |
3833 | else if (!spec_long && (base != 10 || spec_unsigned) |
3834 | && int_fits_type_p (yylval.ttype, unsigned_type_node)) | |
a3f44a13 BK |
3835 | /* Nondecimal constants try unsigned even in traditional C. */ |
3836 | type = unsigned_type_node; | |
8d08fdba MS |
3837 | else if (!spec_unsigned && !spec_long_long |
3838 | && int_fits_type_p (yylval.ttype, long_integer_type_node)) | |
3839 | type = long_integer_type_node; | |
37c46b43 | 3840 | else if (! spec_long_long) |
d22c8596 | 3841 | type = long_unsigned_type_node; |
8d08fdba MS |
3842 | else if (! spec_unsigned |
3843 | /* Verify value does not overflow into sign bit. */ | |
3844 | && TREE_INT_CST_HIGH (yylval.ttype) >= 0 | |
3845 | && int_fits_type_p (yylval.ttype, | |
3846 | long_long_integer_type_node)) | |
3847 | type = long_long_integer_type_node; | |
a3f44a13 | 3848 | else |
d22c8596 | 3849 | type = long_long_unsigned_type_node; |
8d08fdba | 3850 | |
a3f44a13 BK |
3851 | if (!int_fits_type_p (yylval.ttype, type) && !warn) |
3852 | pedwarn ("integer constant out of range"); | |
8d08fdba | 3853 | |
a3f44a13 BK |
3854 | if (base == 10 && ! spec_unsigned && TREE_UNSIGNED (type)) |
3855 | warning ("decimal integer constant is so large that it is unsigned"); | |
8d08fdba | 3856 | |
a3f44a13 BK |
3857 | if (spec_imag) |
3858 | { | |
3859 | if (TYPE_PRECISION (type) | |
3860 | <= TYPE_PRECISION (integer_type_node)) | |
3861 | yylval.ttype | |
3862 | = build_complex (NULL_TREE, integer_zero_node, | |
3863 | cp_convert (integer_type_node, | |
3864 | yylval.ttype)); | |
3865 | else | |
3866 | error ("complex integer constant is too wide for `__complex int'"); | |
3867 | } | |
3868 | else | |
3869 | TREE_TYPE (yylval.ttype) = type; | |
8d08fdba MS |
3870 | } |
3871 | ||
37c46b43 MS |
3872 | put_back (c); |
3873 | *p = 0; | |
3874 | ||
8d08fdba MS |
3875 | value = CONSTANT; break; |
3876 | } | |
3877 | ||
3878 | case '\'': | |
3879 | char_constant: | |
3880 | { | |
3881 | register int result = 0; | |
3882 | register int num_chars = 0; | |
3883 | unsigned width = TYPE_PRECISION (char_type_node); | |
3884 | int max_chars; | |
3885 | ||
3886 | if (wide_flag) | |
3887 | { | |
3888 | width = WCHAR_TYPE_SIZE; | |
3889 | #ifdef MULTIBYTE_CHARS | |
3890 | max_chars = MB_CUR_MAX; | |
3891 | #else | |
3892 | max_chars = 1; | |
3893 | #endif | |
3894 | } | |
3895 | else | |
3896 | max_chars = TYPE_PRECISION (integer_type_node) / width; | |
3897 | ||
3898 | while (1) | |
3899 | { | |
3900 | tryagain: | |
3901 | ||
3902 | c = getch (); | |
3903 | ||
3904 | if (c == '\'' || c == EOF) | |
3905 | break; | |
3906 | ||
3907 | if (c == '\\') | |
3908 | { | |
3909 | int ignore = 0; | |
3910 | c = readescape (&ignore); | |
3911 | if (ignore) | |
3912 | goto tryagain; | |
3913 | if (width < HOST_BITS_PER_INT | |
3914 | && (unsigned) c >= (1 << width)) | |
e1cd6e56 | 3915 | warning ("escape sequence out of range for character"); |
8d08fdba MS |
3916 | #ifdef MAP_CHARACTER |
3917 | if (isprint (c)) | |
3918 | c = MAP_CHARACTER (c); | |
3919 | #endif | |
3920 | } | |
3921 | else if (c == '\n') | |
3922 | { | |
3923 | if (pedantic) | |
3924 | pedwarn ("ANSI C++ forbids newline in character constant"); | |
3925 | lineno++; | |
3926 | } | |
3927 | #ifdef MAP_CHARACTER | |
3928 | else | |
3929 | c = MAP_CHARACTER (c); | |
3930 | #endif | |
3931 | ||
3932 | num_chars++; | |
3933 | if (num_chars > maxtoken - 4) | |
3934 | extend_token_buffer (token_buffer); | |
3935 | ||
3936 | token_buffer[num_chars] = c; | |
3937 | ||
3938 | /* Merge character into result; ignore excess chars. */ | |
3939 | if (num_chars < max_chars + 1) | |
3940 | { | |
3941 | if (width < HOST_BITS_PER_INT) | |
3942 | result = (result << width) | (c & ((1 << width) - 1)); | |
3943 | else | |
3944 | result = c; | |
3945 | } | |
3946 | } | |
3947 | ||
3948 | token_buffer[num_chars + 1] = '\''; | |
3949 | token_buffer[num_chars + 2] = 0; | |
3950 | ||
3951 | if (c != '\'') | |
3952 | error ("malformatted character constant"); | |
3953 | else if (num_chars == 0) | |
3954 | error ("empty character constant"); | |
3955 | else if (num_chars > max_chars) | |
3956 | { | |
3957 | num_chars = max_chars; | |
3958 | error ("character constant too long"); | |
3959 | } | |
d22c8596 | 3960 | else if (num_chars != 1) |
8d08fdba MS |
3961 | warning ("multi-character character constant"); |
3962 | ||
3963 | /* If char type is signed, sign-extend the constant. */ | |
3964 | if (! wide_flag) | |
3965 | { | |
3966 | int num_bits = num_chars * width; | |
3967 | if (num_bits == 0) | |
3968 | /* We already got an error; avoid invalid shift. */ | |
3969 | yylval.ttype = build_int_2 (0, 0); | |
3970 | else if (TREE_UNSIGNED (char_type_node) | |
3971 | || ((result >> (num_bits - 1)) & 1) == 0) | |
3972 | yylval.ttype | |
3973 | = build_int_2 (result & ((unsigned HOST_WIDE_INT) ~0 | |
c6a29b1f | 3974 | >> (HOST_BITS_PER_WIDE_INT - num_bits)), |
8d08fdba MS |
3975 | 0); |
3976 | else | |
3977 | yylval.ttype | |
3978 | = build_int_2 (result | ~((unsigned HOST_WIDE_INT) ~0 | |
c6a29b1f | 3979 | >> (HOST_BITS_PER_WIDE_INT - num_bits)), |
8d08fdba MS |
3980 | -1); |
3981 | if (num_chars<=1) | |
3982 | TREE_TYPE (yylval.ttype) = char_type_node; | |
3983 | else | |
3984 | TREE_TYPE (yylval.ttype) = integer_type_node; | |
3985 | } | |
3986 | else | |
3987 | { | |
3988 | #ifdef MULTIBYTE_CHARS | |
3989 | /* Set the initial shift state and convert the next sequence. */ | |
3990 | result = 0; | |
3991 | /* In all locales L'\0' is zero and mbtowc will return zero, | |
3992 | so don't use it. */ | |
3993 | if (num_chars > 1 | |
3994 | || (num_chars == 1 && token_buffer[1] != '\0')) | |
3995 | { | |
3996 | wchar_t wc; | |
3997 | (void) mbtowc (NULL, NULL, 0); | |
3998 | if (mbtowc (& wc, token_buffer + 1, num_chars) == num_chars) | |
3999 | result = wc; | |
4000 | else | |
4001 | warning ("Ignoring invalid multibyte character"); | |
4002 | } | |
4003 | #endif | |
4004 | yylval.ttype = build_int_2 (result, 0); | |
4005 | TREE_TYPE (yylval.ttype) = wchar_type_node; | |
4006 | } | |
4007 | ||
4008 | value = CONSTANT; | |
4009 | break; | |
4010 | } | |
4011 | ||
4012 | case '"': | |
4013 | string_constant: | |
4014 | { | |
4015 | register char *p; | |
4016 | ||
4017 | c = getch (); | |
4018 | p = token_buffer + 1; | |
4019 | ||
4020 | while (c != '"' && c >= 0) | |
4021 | { | |
4022 | /* ignore_escape_flag is set for reading the filename in #line. */ | |
4023 | if (!ignore_escape_flag && c == '\\') | |
4024 | { | |
4025 | int ignore = 0; | |
4026 | c = readescape (&ignore); | |
4027 | if (ignore) | |
4028 | goto skipnewline; | |
4029 | if (!wide_flag | |
4030 | && TYPE_PRECISION (char_type_node) < HOST_BITS_PER_INT | |
4031 | && c >= ((unsigned) 1 << TYPE_PRECISION (char_type_node))) | |
e1cd6e56 | 4032 | warning ("escape sequence out of range for character"); |
8d08fdba MS |
4033 | } |
4034 | else if (c == '\n') | |
4035 | { | |
4036 | if (pedantic) | |
4037 | pedwarn ("ANSI C++ forbids newline in string constant"); | |
4038 | lineno++; | |
4039 | } | |
4040 | ||
4041 | if (p == token_buffer + maxtoken) | |
4042 | p = extend_token_buffer (p); | |
4043 | *p++ = c; | |
4044 | ||
4045 | skipnewline: | |
4046 | c = getch (); | |
4047 | if (c == EOF) { | |
fc378698 | 4048 | error ("Unterminated string"); |
8d08fdba MS |
4049 | break; |
4050 | } | |
4051 | } | |
4052 | *p = 0; | |
4053 | ||
4054 | /* We have read the entire constant. | |
4055 | Construct a STRING_CST for the result. */ | |
4056 | ||
4057 | if (wide_flag) | |
4058 | { | |
4059 | /* If this is a L"..." wide-string, convert the multibyte string | |
4060 | to a wide character string. */ | |
4061 | char *widep = (char *) alloca ((p - token_buffer) * WCHAR_BYTES); | |
4062 | int len; | |
4063 | ||
4064 | #ifdef MULTIBYTE_CHARS | |
4065 | len = mbstowcs ((wchar_t *) widep, token_buffer + 1, p - token_buffer); | |
4066 | if (len < 0 || len >= (p - token_buffer)) | |
4067 | { | |
4068 | warning ("Ignoring invalid multibyte string"); | |
4069 | len = 0; | |
4070 | } | |
4071 | bzero (widep + (len * WCHAR_BYTES), WCHAR_BYTES); | |
4072 | #else | |
4073 | { | |
8d08fdba MS |
4074 | char *wp, *cp; |
4075 | ||
30c317f5 | 4076 | wp = widep + (BYTES_BIG_ENDIAN ? WCHAR_BYTES - 1 : 0); |
8d08fdba MS |
4077 | bzero (widep, (p - token_buffer) * WCHAR_BYTES); |
4078 | for (cp = token_buffer + 1; cp < p; cp++) | |
4079 | *wp = *cp, wp += WCHAR_BYTES; | |
4080 | len = p - token_buffer - 1; | |
4081 | } | |
4082 | #endif | |
5156628f | 4083 | if (processing_template_decl) |
5566b478 | 4084 | push_obstacks (&permanent_obstack, &permanent_obstack); |
8d08fdba | 4085 | yylval.ttype = build_string ((len + 1) * WCHAR_BYTES, widep); |
5156628f | 4086 | if (processing_template_decl) |
5566b478 | 4087 | pop_obstacks (); |
8d08fdba MS |
4088 | TREE_TYPE (yylval.ttype) = wchar_array_type_node; |
4089 | } | |
4090 | else | |
4091 | { | |
5156628f | 4092 | if (processing_template_decl) |
5566b478 | 4093 | push_obstacks (&permanent_obstack, &permanent_obstack); |
8d08fdba | 4094 | yylval.ttype = build_string (p - token_buffer, token_buffer + 1); |
5156628f | 4095 | if (processing_template_decl) |
5566b478 | 4096 | pop_obstacks (); |
8d08fdba MS |
4097 | TREE_TYPE (yylval.ttype) = char_array_type_node; |
4098 | } | |
4099 | ||
4100 | *p++ = '"'; | |
4101 | *p = 0; | |
4102 | ||
4103 | value = STRING; break; | |
4104 | } | |
4105 | ||
4106 | case '+': | |
4107 | case '-': | |
4108 | case '&': | |
4109 | case '|': | |
4110 | case '<': | |
4111 | case '>': | |
4112 | case '*': | |
4113 | case '/': | |
4114 | case '%': | |
4115 | case '^': | |
4116 | case '!': | |
4117 | case '=': | |
4118 | { | |
4119 | register int c1; | |
4120 | ||
4121 | combine: | |
4122 | ||
4123 | switch (c) | |
4124 | { | |
4125 | case '+': | |
4126 | yylval.code = PLUS_EXPR; break; | |
4127 | case '-': | |
4128 | yylval.code = MINUS_EXPR; break; | |
4129 | case '&': | |
4130 | yylval.code = BIT_AND_EXPR; break; | |
4131 | case '|': | |
4132 | yylval.code = BIT_IOR_EXPR; break; | |
4133 | case '*': | |
4134 | yylval.code = MULT_EXPR; break; | |
4135 | case '/': | |
4136 | yylval.code = TRUNC_DIV_EXPR; break; | |
4137 | case '%': | |
4138 | yylval.code = TRUNC_MOD_EXPR; break; | |
4139 | case '^': | |
4140 | yylval.code = BIT_XOR_EXPR; break; | |
4141 | case LSHIFT: | |
4142 | yylval.code = LSHIFT_EXPR; break; | |
4143 | case RSHIFT: | |
4144 | yylval.code = RSHIFT_EXPR; break; | |
4145 | case '<': | |
4146 | yylval.code = LT_EXPR; break; | |
4147 | case '>': | |
4148 | yylval.code = GT_EXPR; break; | |
4149 | } | |
4150 | ||
4151 | token_buffer[1] = c1 = getch (); | |
4152 | token_buffer[2] = 0; | |
4153 | ||
4154 | if (c1 == '=') | |
4155 | { | |
4156 | switch (c) | |
4157 | { | |
4158 | case '<': | |
4159 | value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done; | |
4160 | case '>': | |
4161 | value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done; | |
4162 | case '!': | |
4163 | value = EQCOMPARE; yylval.code = NE_EXPR; goto done; | |
4164 | case '=': | |
4165 | value = EQCOMPARE; yylval.code = EQ_EXPR; goto done; | |
4166 | } | |
4167 | value = ASSIGN; goto done; | |
4168 | } | |
4169 | else if (c == c1) | |
4170 | switch (c) | |
4171 | { | |
4172 | case '+': | |
4173 | value = PLUSPLUS; goto done; | |
4174 | case '-': | |
4175 | value = MINUSMINUS; goto done; | |
4176 | case '&': | |
4177 | value = ANDAND; goto done; | |
4178 | case '|': | |
4179 | value = OROR; goto done; | |
4180 | case '<': | |
4181 | c = LSHIFT; | |
4182 | goto combine; | |
4183 | case '>': | |
4184 | c = RSHIFT; | |
4185 | goto combine; | |
4186 | } | |
4187 | else if ((c == '-') && (c1 == '>')) | |
4188 | { | |
e1cd6e56 | 4189 | nextchar = getch (); |
8d08fdba MS |
4190 | if (nextchar == '*') |
4191 | { | |
4192 | nextchar = -1; | |
4193 | value = POINTSAT_STAR; | |
4194 | } | |
4195 | else | |
4196 | value = POINTSAT; | |
4197 | goto done; | |
4198 | } | |
4199 | else if (c1 == '?' && (c == '<' || c == '>')) | |
4200 | { | |
4201 | token_buffer[3] = 0; | |
4202 | ||
4203 | c1 = getch (); | |
4204 | yylval.code = (c == '<' ? MIN_EXPR : MAX_EXPR); | |
4205 | if (c1 == '=') | |
4206 | { | |
4207 | /* <?= or >?= expression. */ | |
4208 | token_buffer[2] = c1; | |
4209 | value = ASSIGN; | |
4210 | } | |
4211 | else | |
4212 | { | |
4213 | value = MIN_MAX; | |
4214 | nextchar = c1; | |
4215 | } | |
e1cd6e56 | 4216 | if (pedantic) |
2986ae00 MS |
4217 | pedwarn ("use of `operator %s' is not standard C++", |
4218 | token_buffer); | |
8d08fdba MS |
4219 | goto done; |
4220 | } | |
e1cd6e56 MS |
4221 | /* digraphs */ |
4222 | else if (c == '<' && c1 == '%') | |
4223 | { value = '{'; goto done; } | |
4224 | else if (c == '<' && c1 == ':') | |
4225 | { value = '['; goto done; } | |
4226 | else if (c == '%' && c1 == '>') | |
4227 | { value = '}'; goto done; } | |
4228 | else if (c == '%' && c1 == ':') | |
4229 | { value = '#'; goto done; } | |
8d08fdba MS |
4230 | |
4231 | nextchar = c1; | |
4232 | token_buffer[1] = 0; | |
4233 | ||
4234 | value = c; | |
4235 | goto done; | |
4236 | } | |
4237 | ||
4238 | case ':': | |
4239 | c = getch (); | |
4240 | if (c == ':') | |
4241 | { | |
4242 | token_buffer[1] = ':'; | |
4243 | token_buffer[2] = '\0'; | |
4244 | value = SCOPE; | |
4245 | yylval.itype = 1; | |
4246 | } | |
b7484fbe MS |
4247 | else if (c == '>') |
4248 | { | |
4249 | value = ']'; | |
4250 | goto done; | |
4251 | } | |
8d08fdba MS |
4252 | else |
4253 | { | |
4254 | nextchar = c; | |
4255 | value = ':'; | |
4256 | } | |
4257 | break; | |
4258 | ||
4259 | case 0: | |
4260 | /* Don't make yyparse think this is eof. */ | |
4261 | value = 1; | |
4262 | break; | |
4263 | ||
4264 | case '(': | |
4265 | /* try, weakly, to handle casts to pointers to functions. */ | |
4266 | nextchar = skip_white_space (getch ()); | |
4267 | if (nextchar == '*') | |
4268 | { | |
4269 | int next_c = skip_white_space (getch ()); | |
4270 | if (next_c == ')') | |
4271 | { | |
4272 | nextchar = -1; | |
4273 | yylval.ttype = build1 (INDIRECT_REF, 0, 0); | |
4274 | value = PAREN_STAR_PAREN; | |
4275 | } | |
4276 | else | |
4277 | { | |
4278 | put_back (next_c); | |
4279 | value = c; | |
4280 | } | |
4281 | } | |
4282 | else if (nextchar == ')') | |
4283 | { | |
4284 | nextchar = -1; | |
4285 | yylval.ttype = NULL_TREE; | |
4286 | value = LEFT_RIGHT; | |
4287 | } | |
4288 | else value = c; | |
4289 | break; | |
4290 | ||
4291 | default: | |
4292 | value = c; | |
4293 | } | |
4294 | ||
4295 | done: | |
4296 | /* yylloc.last_line = lineno; */ | |
4297 | #ifdef GATHER_STATISTICS | |
72b7eeff | 4298 | #ifdef REDUCE_LENGTH |
8d08fdba | 4299 | token_count[value] += 1; |
72b7eeff | 4300 | #endif |
8d08fdba MS |
4301 | #endif |
4302 | ||
4303 | return value; | |
4304 | } | |
4305 | ||
be99da77 MS |
4306 | int |
4307 | is_rid (t) | |
4308 | tree t; | |
4309 | { | |
4310 | return !!is_reserved_word (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t)); | |
4311 | } | |
4312 | ||
5566b478 | 4313 | #ifdef GATHER_STATISTICS |
5156628f MS |
4314 | /* The original for tree_node_kind is in the toplevel tree.c; changes there |
4315 | need to be brought into here, unless this were actually put into a header | |
4316 | instead. */ | |
4317 | /* Statistics-gathering stuff. */ | |
4318 | typedef enum | |
4319 | { | |
4320 | d_kind, | |
4321 | t_kind, | |
4322 | b_kind, | |
4323 | s_kind, | |
4324 | r_kind, | |
4325 | e_kind, | |
4326 | c_kind, | |
4327 | id_kind, | |
4328 | op_id_kind, | |
4329 | perm_list_kind, | |
4330 | temp_list_kind, | |
4331 | vec_kind, | |
4332 | x_kind, | |
4333 | lang_decl, | |
4334 | lang_type, | |
4335 | all_kinds | |
4336 | } tree_node_kind; | |
4337 | ||
8d08fdba MS |
4338 | extern int tree_node_counts[]; |
4339 | extern int tree_node_sizes[]; | |
5566b478 | 4340 | #endif |
8d08fdba MS |
4341 | |
4342 | /* Place to save freed lang_decls which were allocated on the | |
4343 | permanent_obstack. @@ Not currently used. */ | |
4344 | tree free_lang_decl_chain; | |
4345 | ||
4346 | tree | |
4347 | build_lang_decl (code, name, type) | |
4348 | enum tree_code code; | |
4349 | tree name; | |
4350 | tree type; | |
4351 | { | |
4352 | register tree t = build_decl (code, name, type); | |
4353 | struct obstack *obstack = current_obstack; | |
4354 | register int i = sizeof (struct lang_decl) / sizeof (int); | |
4355 | register int *pi; | |
4356 | ||
4357 | if (! TREE_PERMANENT (t)) | |
4358 | obstack = saveable_obstack; | |
4359 | else | |
4360 | /* Could be that saveable is permanent and current is not. */ | |
4361 | obstack = &permanent_obstack; | |
4362 | ||
4363 | if (free_lang_decl_chain && obstack == &permanent_obstack) | |
4364 | { | |
4365 | pi = (int *)free_lang_decl_chain; | |
4366 | free_lang_decl_chain = TREE_CHAIN (free_lang_decl_chain); | |
4367 | } | |
4368 | else | |
4369 | pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl)); | |
4370 | ||
4371 | while (i > 0) | |
4372 | pi[--i] = 0; | |
4373 | ||
4374 | DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi; | |
4375 | LANG_DECL_PERMANENT ((struct lang_decl *) pi) | |
4376 | = obstack == &permanent_obstack; | |
4377 | my_friendly_assert (LANG_DECL_PERMANENT ((struct lang_decl *) pi) | |
4378 | == TREE_PERMANENT (t), 234); | |
4379 | DECL_MAIN_VARIANT (t) = t; | |
4380 | if (current_lang_name == lang_name_cplusplus) | |
d22c8596 | 4381 | DECL_LANGUAGE (t) = lang_cplusplus; |
8d08fdba MS |
4382 | else if (current_lang_name == lang_name_c) |
4383 | DECL_LANGUAGE (t) = lang_c; | |
4384 | else my_friendly_abort (64); | |
4385 | ||
4386 | #if 0 /* not yet, should get fixed properly later */ | |
4387 | if (code == TYPE_DECL) | |
4388 | { | |
4389 | tree id; | |
4390 | id = get_identifier (build_overload_name (type, 1, 1)); | |
4391 | DECL_ASSEMBLER_NAME (t) = id; | |
4392 | } | |
4393 | ||
4394 | #endif | |
4395 | #ifdef GATHER_STATISTICS | |
4396 | tree_node_counts[(int)lang_decl] += 1; | |
fc378698 | 4397 | tree_node_sizes[(int)lang_decl] += sizeof (struct lang_decl); |
8d08fdba MS |
4398 | #endif |
4399 | ||
4400 | return t; | |
4401 | } | |
4402 | ||
4403 | tree | |
4404 | build_lang_field_decl (code, name, type) | |
4405 | enum tree_code code; | |
4406 | tree name; | |
4407 | tree type; | |
4408 | { | |
4409 | extern struct obstack *current_obstack, *saveable_obstack; | |
4410 | register tree t = build_decl (code, name, type); | |
4411 | struct obstack *obstack = current_obstack; | |
4412 | register int i = sizeof (struct lang_decl_flags) / sizeof (int); | |
4413 | register int *pi; | |
4414 | #if 0 /* not yet, should get fixed properly later */ | |
4415 | ||
4416 | if (code == TYPE_DECL) | |
4417 | { | |
4418 | tree id; | |
4419 | id = get_identifier (build_overload_name (type, 1, 1)); | |
4420 | DECL_ASSEMBLER_NAME (t) = id; | |
4421 | } | |
4422 | #endif | |
4423 | ||
4424 | if (! TREE_PERMANENT (t)) | |
4425 | obstack = saveable_obstack; | |
4426 | else | |
4427 | my_friendly_assert (obstack == &permanent_obstack, 235); | |
4428 | ||
4429 | pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl_flags)); | |
4430 | while (i > 0) | |
4431 | pi[--i] = 0; | |
4432 | ||
4433 | DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi; | |
4434 | return t; | |
4435 | } | |
4436 | ||
4437 | void | |
4438 | copy_lang_decl (node) | |
4439 | tree node; | |
4440 | { | |
4441 | int size; | |
4442 | int *pi; | |
4443 | ||
5566b478 MS |
4444 | if (! DECL_LANG_SPECIFIC (node)) |
4445 | return; | |
4446 | ||
8d08fdba MS |
4447 | if (TREE_CODE (node) == FIELD_DECL) |
4448 | size = sizeof (struct lang_decl_flags); | |
4449 | else | |
4450 | size = sizeof (struct lang_decl); | |
4451 | pi = (int *)obstack_alloc (&permanent_obstack, size); | |
4452 | bcopy ((char *)DECL_LANG_SPECIFIC (node), (char *)pi, size); | |
4453 | DECL_LANG_SPECIFIC (node) = (struct lang_decl *)pi; | |
4454 | } | |
4455 | ||
4456 | tree | |
4457 | make_lang_type (code) | |
4458 | enum tree_code code; | |
4459 | { | |
4460 | extern struct obstack *current_obstack, *saveable_obstack; | |
4461 | register tree t = make_node (code); | |
4462 | struct obstack *obstack = current_obstack; | |
4463 | register int i = sizeof (struct lang_type) / sizeof (int); | |
4464 | register int *pi; | |
4465 | ||
4466 | /* Set up some flags that give proper default behavior. */ | |
4467 | IS_AGGR_TYPE (t) = 1; | |
4468 | ||
4469 | if (! TREE_PERMANENT (t)) | |
4470 | obstack = saveable_obstack; | |
4471 | else | |
4472 | my_friendly_assert (obstack == &permanent_obstack, 236); | |
4473 | ||
4474 | pi = (int *) obstack_alloc (obstack, sizeof (struct lang_type)); | |
4475 | while (i > 0) | |
4476 | pi[--i] = 0; | |
4477 | ||
4478 | TYPE_LANG_SPECIFIC (t) = (struct lang_type *) pi; | |
e66d884e | 4479 | CLASSTYPE_AS_LIST (t) = build_expr_list (NULL_TREE, t); |
8d08fdba MS |
4480 | SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, interface_unknown); |
4481 | CLASSTYPE_INTERFACE_ONLY (t) = interface_only; | |
4482 | CLASSTYPE_VBASE_SIZE (t) = integer_zero_node; | |
8926095f MS |
4483 | TYPE_BINFO (t) = make_binfo (integer_zero_node, t, NULL_TREE, NULL_TREE, |
4484 | NULL_TREE); | |
8d08fdba MS |
4485 | CLASSTYPE_BINFO_AS_LIST (t) = build_tree_list (NULL_TREE, TYPE_BINFO (t)); |
4486 | ||
4487 | /* Make sure this is laid out, for ease of use later. | |
4488 | In the presence of parse errors, the normal was of assuring | |
4489 | this might not ever get executed, so we lay it out *immediately*. */ | |
4490 | build_pointer_type (t); | |
4491 | ||
4492 | #ifdef GATHER_STATISTICS | |
4493 | tree_node_counts[(int)lang_type] += 1; | |
fc378698 | 4494 | tree_node_sizes[(int)lang_type] += sizeof (struct lang_type); |
8d08fdba MS |
4495 | #endif |
4496 | ||
4497 | return t; | |
4498 | } | |
4499 | ||
8d08fdba MS |
4500 | void |
4501 | dump_time_statistics () | |
4502 | { | |
4503 | register tree prev = 0, decl, next; | |
4504 | int this_time = my_get_run_time (); | |
4505 | TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time)) | |
4506 | += this_time - body_time; | |
4507 | ||
4508 | fprintf (stderr, "\n******\n"); | |
4509 | print_time ("header files (total)", header_time); | |
4510 | print_time ("main file (total)", this_time - body_time); | |
4511 | fprintf (stderr, "ratio = %g : 1\n", | |
4512 | (double)header_time / (double)(this_time - body_time)); | |
4513 | fprintf (stderr, "\n******\n"); | |
4514 | ||
4515 | for (decl = filename_times; decl; decl = next) | |
4516 | { | |
4517 | next = IDENTIFIER_GLOBAL_VALUE (decl); | |
4518 | IDENTIFIER_GLOBAL_VALUE (decl) = prev; | |
4519 | prev = decl; | |
4520 | } | |
4521 | ||
4522 | for (decl = prev; decl; decl = IDENTIFIER_GLOBAL_VALUE (decl)) | |
4523 | print_time (IDENTIFIER_POINTER (decl), | |
4524 | TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (decl))); | |
4525 | } | |
4526 | ||
4527 | void | |
4528 | compiler_error (s, v, v2) | |
4529 | char *s; | |
4530 | HOST_WIDE_INT v, v2; /* @@also used as pointer */ | |
4531 | { | |
4532 | char buf[1024]; | |
4533 | sprintf (buf, s, v, v2); | |
4534 | error_with_file_and_line (input_filename, lineno, "%s (compiler error)", buf); | |
4535 | } | |
8d08fdba MS |
4536 | \f |
4537 | void | |
4538 | yyerror (string) | |
4539 | char *string; | |
4540 | { | |
4541 | extern int end_of_file; | |
4542 | char buf[200]; | |
4543 | ||
4544 | strcpy (buf, string); | |
4545 | ||
4546 | /* We can't print string and character constants well | |
4547 | because the token_buffer contains the result of processing escapes. */ | |
4548 | if (end_of_file) | |
4549 | strcat (buf, input_redirected () | |
4550 | ? " at end of saved text" | |
4551 | : " at end of input"); | |
4552 | else if (token_buffer[0] == 0) | |
4553 | strcat (buf, " at null character"); | |
4554 | else if (token_buffer[0] == '"') | |
4555 | strcat (buf, " before string constant"); | |
4556 | else if (token_buffer[0] == '\'') | |
4557 | strcat (buf, " before character constant"); | |
4558 | else if (token_buffer[0] < 040 || (unsigned char) token_buffer[0] >= 0177) | |
4559 | sprintf (buf + strlen (buf), " before character 0%o", | |
4560 | (unsigned char) token_buffer[0]); | |
4561 | else | |
4562 | strcat (buf, " before `%s'"); | |
4563 | ||
4564 | error (buf, token_buffer); | |
4565 | } | |
6060a796 | 4566 | \f |
824b9a4c | 4567 | static int |
a82e1b55 BK |
4568 | handle_cp_pragma (pname) |
4569 | char *pname; | |
4570 | { | |
4571 | register int token; | |
a82e1b55 BK |
4572 | |
4573 | if (! strcmp (pname, "vtable")) | |
4574 | { | |
4575 | extern tree pending_vtables; | |
4576 | ||
4577 | /* More follows: it must be a string constant (class name). */ | |
4578 | token = real_yylex (); | |
4579 | if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST) | |
4580 | { | |
4581 | error ("invalid #pragma vtable"); | |
4582 | return -1; | |
4583 | } | |
4584 | ||
4585 | if (write_virtuals != 2) | |
4586 | { | |
4587 | warning ("use `+e2' option to enable #pragma vtable"); | |
4588 | return -1; | |
4589 | } | |
4590 | pending_vtables | |
4591 | = perm_tree_cons (NULL_TREE, | |
4592 | get_identifier (TREE_STRING_POINTER (yylval.ttype)), | |
4593 | pending_vtables); | |
a80e4195 MS |
4594 | token = real_yylex (); |
4595 | if (token != END_OF_LINE) | |
a82e1b55 BK |
4596 | warning ("trailing characters ignored"); |
4597 | return 1; | |
4598 | } | |
4599 | else if (! strcmp (pname, "unit")) | |
4600 | { | |
4601 | /* More follows: it must be a string constant (unit name). */ | |
4602 | token = real_yylex (); | |
4603 | if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST) | |
4604 | { | |
4605 | error ("invalid #pragma unit"); | |
4606 | return -1; | |
4607 | } | |
a80e4195 MS |
4608 | token = real_yylex (); |
4609 | if (token != END_OF_LINE) | |
a82e1b55 BK |
4610 | warning ("trailing characters ignored"); |
4611 | return 1; | |
4612 | } | |
4613 | else if (! strcmp (pname, "interface")) | |
4614 | { | |
4615 | tree fileinfo = IDENTIFIER_CLASS_VALUE (get_time_identifier (input_filename)); | |
a82e1b55 BK |
4616 | char *main_filename = input_filename; |
4617 | ||
b2bb2710 | 4618 | main_filename = file_name_nondirectory (main_filename); |
a82e1b55 | 4619 | |
a80e4195 MS |
4620 | token = real_yylex (); |
4621 | ||
4622 | if (token != END_OF_LINE) | |
a82e1b55 | 4623 | { |
a82e1b55 BK |
4624 | if (token != STRING |
4625 | || TREE_CODE (yylval.ttype) != STRING_CST) | |
4626 | { | |
4627 | error ("invalid `#pragma interface'"); | |
4628 | return -1; | |
4629 | } | |
4630 | main_filename = TREE_STRING_POINTER (yylval.ttype); | |
a80e4195 MS |
4631 | token = real_yylex (); |
4632 | } | |
a82e1b55 | 4633 | |
faf5394a MS |
4634 | if (token != END_OF_LINE) |
4635 | warning ("garbage after `#pragma interface' ignored"); | |
4636 | ||
c11b6f21 | 4637 | #ifndef NO_LINKAGE_HEURISTICS |
a80e4195 | 4638 | write_virtuals = 3; |
a82e1b55 | 4639 | |
a80e4195 MS |
4640 | if (impl_file_chain == 0) |
4641 | { | |
4642 | /* If this is zero at this point, then we are | |
4643 | auto-implementing. */ | |
4644 | if (main_input_filename == 0) | |
4645 | main_input_filename = input_filename; | |
a82e1b55 BK |
4646 | |
4647 | #ifdef AUTO_IMPLEMENT | |
b2bb2710 | 4648 | filename = file_name_nondirectory (main_input_filename); |
a80e4195 MS |
4649 | fi = get_time_identifier (filename); |
4650 | fi = IDENTIFIER_CLASS_VALUE (fi); | |
4651 | TREE_INT_CST_LOW (fi) = 0; | |
4652 | TREE_INT_CST_HIGH (fi) = 1; | |
4653 | /* Get default. */ | |
4654 | impl_file_chain = (struct impl_files *)permalloc (sizeof (struct impl_files)); | |
4655 | impl_file_chain->filename = filename; | |
4656 | impl_file_chain->next = 0; | |
a82e1b55 | 4657 | #endif |
a82e1b55 BK |
4658 | } |
4659 | ||
4660 | interface_only = interface_strcmp (main_filename); | |
4661 | interface_unknown = 0; | |
4662 | TREE_INT_CST_LOW (fileinfo) = interface_only; | |
4663 | TREE_INT_CST_HIGH (fileinfo) = interface_unknown; | |
c11b6f21 | 4664 | #endif /* NO_LINKAGE_HEURISTICS */ |
a82e1b55 BK |
4665 | |
4666 | return 1; | |
4667 | } | |
4668 | else if (! strcmp (pname, "implementation")) | |
4669 | { | |
4670 | tree fileinfo = IDENTIFIER_CLASS_VALUE (get_time_identifier (input_filename)); | |
a82e1b55 BK |
4671 | char *main_filename = main_input_filename ? main_input_filename : input_filename; |
4672 | ||
b2bb2710 | 4673 | main_filename = file_name_nondirectory (main_filename); |
a82e1b55 | 4674 | token = real_yylex (); |
a80e4195 | 4675 | if (token != END_OF_LINE) |
a82e1b55 | 4676 | { |
a80e4195 MS |
4677 | if (token != STRING |
4678 | || TREE_CODE (yylval.ttype) != STRING_CST) | |
4679 | { | |
4680 | error ("invalid `#pragma implementation'"); | |
4681 | return -1; | |
4682 | } | |
4683 | main_filename = TREE_STRING_POINTER (yylval.ttype); | |
a80e4195 | 4684 | token = real_yylex (); |
a82e1b55 BK |
4685 | } |
4686 | ||
faf5394a MS |
4687 | if (token != END_OF_LINE) |
4688 | warning ("garbage after `#pragma implementation' ignored"); | |
4689 | ||
c11b6f21 | 4690 | #ifndef NO_LINKAGE_HEURISTICS |
a82e1b55 BK |
4691 | if (write_virtuals == 3) |
4692 | { | |
4693 | struct impl_files *ifiles = impl_file_chain; | |
4694 | while (ifiles) | |
4695 | { | |
4696 | if (! strcmp (ifiles->filename, main_filename)) | |
4697 | break; | |
4698 | ifiles = ifiles->next; | |
4699 | } | |
4700 | if (ifiles == 0) | |
4701 | { | |
4702 | ifiles = (struct impl_files*) permalloc (sizeof (struct impl_files)); | |
4703 | ifiles->filename = main_filename; | |
4704 | ifiles->next = impl_file_chain; | |
4705 | impl_file_chain = ifiles; | |
4706 | } | |
4707 | } | |
4708 | else if ((main_input_filename != 0 | |
4709 | && ! strcmp (main_input_filename, input_filename)) | |
4710 | || ! strcmp (input_filename, main_filename)) | |
4711 | { | |
4712 | write_virtuals = 3; | |
4713 | if (impl_file_chain == 0) | |
4714 | { | |
4715 | impl_file_chain = (struct impl_files*) permalloc (sizeof (struct impl_files)); | |
4716 | impl_file_chain->filename = main_filename; | |
4717 | impl_file_chain->next = 0; | |
4718 | } | |
4719 | } | |
4720 | else | |
4721 | error ("`#pragma implementation' can only appear at top-level"); | |
4722 | interface_only = 0; | |
4723 | #if 1 | |
4724 | /* We make this non-zero so that we infer decl linkage | |
4725 | in the impl file only for variables first declared | |
4726 | in the interface file. */ | |
4727 | interface_unknown = 1; | |
4728 | #else | |
4729 | /* We make this zero so that templates in the impl | |
e92cc029 | 4730 | file will be emitted properly. */ |
a82e1b55 BK |
4731 | interface_unknown = 0; |
4732 | #endif | |
4733 | TREE_INT_CST_LOW (fileinfo) = interface_only; | |
4734 | TREE_INT_CST_HIGH (fileinfo) = interface_unknown; | |
c11b6f21 MS |
4735 | #endif /* NO_LINKAGE_HEURISTICS */ |
4736 | ||
a82e1b55 BK |
4737 | return 1; |
4738 | } | |
4739 | ||
4740 | return 0; | |
4741 | } | |
4742 | \f | |
6060a796 MS |
4743 | #ifdef HANDLE_SYSV_PRAGMA |
4744 | ||
4745 | /* Handle a #pragma directive. INPUT is the current input stream, | |
4746 | and C is a character to reread. Processes the entire input line | |
4747 | and returns a character for the caller to reread: either \n or EOF. */ | |
4748 | ||
4749 | /* This function has to be in this file, in order to get at | |
4750 | the token types. */ | |
e92cc029 | 4751 | |
824b9a4c | 4752 | static int |
a82e1b55 BK |
4753 | handle_sysv_pragma (finput, token) |
4754 | FILE *finput; | |
4755 | register int token; | |
6060a796 MS |
4756 | { |
4757 | for (;;) | |
4758 | { | |
a82e1b55 | 4759 | switch (token) |
6060a796 MS |
4760 | { |
4761 | case IDENTIFIER: | |
4762 | case TYPENAME: | |
4763 | case STRING: | |
4764 | case CONSTANT: | |
a9aedbc2 MS |
4765 | handle_pragma_token ("ignored", yylval.ttype); |
4766 | break; | |
4767 | case '(': | |
4768 | handle_pragma_token ("(", NULL_TREE); | |
4769 | break; | |
4770 | case ')': | |
4771 | handle_pragma_token (")", NULL_TREE); | |
4772 | break; | |
f3c90fd6 BK |
4773 | case ',': |
4774 | handle_pragma_token (",", NULL_TREE); | |
4775 | break; | |
a9aedbc2 MS |
4776 | case '=': |
4777 | handle_pragma_token ("=", NULL_TREE); | |
4778 | break; | |
4779 | case LEFT_RIGHT: | |
4780 | handle_pragma_token ("(", NULL_TREE); | |
4781 | handle_pragma_token (")", NULL_TREE); | |
6060a796 | 4782 | break; |
d18c083e | 4783 | case END_OF_LINE: |
6060a796 | 4784 | default: |
f30432d7 | 4785 | handle_pragma_token (NULL_PTR, NULL_TREE); |
a82e1b55 | 4786 | return 1; |
6060a796 | 4787 | } |
a80e4195 | 4788 | token = real_yylex (); |
6060a796 MS |
4789 | } |
4790 | } | |
4791 | #endif /* HANDLE_SYSV_PRAGMA */ |