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