1 /* Separate lexical analyzer for GNU C++.
2 Copyright (C) 1987, 89, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
3 Hacked by Michael Tiemann (tiemann@cygnus.com)
5 This file is part of GNU CC.
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)
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.
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
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 /* This file is the lexical analyzer for GNU C++. */
25 /* Cause the `yydebug' variable to be defined. */
28 #include <sys/types.h>
42 #ifdef MULTIBYTE_CHARS
48 extern int errno; /* needed for VAX. */
51 #define obstack_chunk_alloc xmalloc
52 #define obstack_chunk_free free
54 extern struct obstack permanent_obstack;
55 extern struct obstack *current_obstack, *saveable_obstack;
57 extern double atof ();
59 extern char *get_directive_line (); /* In c-common.c */
61 /* Given a file name X, return the nondirectory portion.
62 Keep in mind that X can be computed more than once. */
63 #ifndef FILE_NAME_NONDIRECTORY
64 #define FILE_NAME_NONDIRECTORY(X) \
65 (rindex (X, '/') != 0 ? rindex (X, '/') + 1 : X)
68 extern char *index ();
69 extern char *rindex ();
72 /* This obstack is needed to hold text. It is not safe to use
73 TOKEN_BUFFER because `check_newline' calls `yylex'. */
74 struct obstack inline_text_obstack;
78 /* Pending language change.
79 Positive is push count, negative is pop count. */
80 int pending_lang_change = 0;
82 /* Wrap the current header file in extern "C". */
83 static int c_header_level = 0;
85 extern int first_token;
86 extern struct obstack token_obstack;
88 /* ??? Don't really know where this goes yet. */
92 extern void put_back (/* int */);
93 extern int input_redirected ();
94 extern void feed_input (/* char *, int, struct obstack * */);
97 /* Holds translations from TREE_CODEs to operator name strings,
98 i.e., opname_tab[PLUS_EXPR] == "+". */
102 extern int yychar; /* the lookahead symbol */
103 extern YYSTYPE yylval; /* the semantic value of the */
104 /* lookahead symbol */
107 YYLTYPE yylloc; /* location data for the lookahead */
112 /* the declaration found for the last IDENTIFIER token read in.
113 yylex must look this up to detect typedefs, which get token type TYPENAME,
114 so it is left around in case the identifier is not a typedef but is
115 used in a context which makes it a reference to a variable. */
118 /* The elements of `ridpointers' are identifier nodes
119 for the reserved type names and storage classes.
120 It is indexed by a RID_... value. */
121 tree ridpointers[(int) RID_MAX];
123 /* We may keep statistics about how long which files took to compile. */
124 static int header_time, body_time;
125 static tree get_time_identifier ();
126 static tree filename_times;
127 static tree this_filename_time;
129 /* Array for holding counts of the numbers of tokens seen. */
130 extern int *token_count;
132 /* Return something to represent absolute declarators containing a *.
133 TARGET is the absolute declarator that the * contains.
134 TYPE_QUALS is a list of modifiers such as const or volatile
135 to apply to the pointer type, represented as identifiers.
137 We return an INDIRECT_REF whose "contents" are TARGET
138 and whose type is the modifier list. */
141 make_pointer_declarator (type_quals, target)
142 tree type_quals, target;
144 if (target && TREE_CODE (target) == IDENTIFIER_NODE
145 && ANON_AGGRNAME_P (target))
146 error ("type name expected before `*'");
147 target = build_parse_node (INDIRECT_REF, target);
148 TREE_TYPE (target) = type_quals;
152 /* Return something to represent absolute declarators containing a &.
153 TARGET is the absolute declarator that the & contains.
154 TYPE_QUALS is a list of modifiers such as const or volatile
155 to apply to the reference type, represented as identifiers.
157 We return an ADDR_EXPR whose "contents" are TARGET
158 and whose type is the modifier list. */
161 make_reference_declarator (type_quals, target)
162 tree type_quals, target;
166 if (TREE_CODE (target) == ADDR_EXPR)
168 error ("cannot declare references to references");
171 if (TREE_CODE (target) == INDIRECT_REF)
173 error ("cannot declare pointers to references");
176 if (TREE_CODE (target) == IDENTIFIER_NODE && ANON_AGGRNAME_P (target))
177 error ("type name expected before `&'");
179 target = build_parse_node (ADDR_EXPR, target);
180 TREE_TYPE (target) = type_quals;
184 /* Build names and nodes for overloaded operators. */
186 tree ansi_opname[LAST_CPLUS_TREE_CODE];
187 tree ansi_assopname[LAST_CPLUS_TREE_CODE];
190 operator_name_string (name)
193 char *opname = IDENTIFIER_POINTER (name) + 2;
197 /* Works for builtin and user defined types. */
198 if (IDENTIFIER_GLOBAL_VALUE (name)
199 && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (name)) == TYPE_DECL)
200 return IDENTIFIER_POINTER (name);
202 if (opname[0] == 'a' && opname[2] != '\0' && opname[2] != '_')
206 opname_table = ansi_assopname;
211 opname_table = ansi_opname;
214 for (i = 0; i < (int) LAST_CPLUS_TREE_CODE; i++)
216 if (opname[0] == IDENTIFIER_POINTER (opname_table[i])[2+assign]
217 && opname[1] == IDENTIFIER_POINTER (opname_table[i])[3+assign])
221 if (i == LAST_CPLUS_TREE_CODE)
222 return "<invalid operator>";
225 return assignop_tab[i];
227 return opname_tab[i];
230 int interface_only; /* whether or not current file is only for
231 interface definitions. */
232 int interface_unknown; /* whether or not we know this class
233 to behave according to #pragma interface. */
235 /* lexical analyzer */
237 /* File used for outputting assembler code. */
238 extern FILE *asm_out_file;
240 #ifndef WCHAR_TYPE_SIZE
242 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
244 #define WCHAR_TYPE_SIZE BITS_PER_WORD
248 /* Number of bytes in a wide character. */
249 #define WCHAR_BYTES (WCHAR_TYPE_SIZE / BITS_PER_UNIT)
251 static int maxtoken; /* Current nominal length of token buffer. */
252 char *token_buffer; /* Pointer to token buffer.
253 Actual allocated length is maxtoken + 2. */
257 int check_newline ();
259 /* Nonzero tells yylex to ignore \ in string constants. */
260 static int ignore_escape_flag = 0;
262 static int skip_white_space ();
265 get_time_identifier (name)
268 tree time_identifier;
269 int len = strlen (name);
270 char *buf = (char *) alloca (len + 6);
271 strcpy (buf, "file ");
272 bcopy (name, buf+5, len);
274 time_identifier = get_identifier (buf);
275 if (IDENTIFIER_LOCAL_VALUE (time_identifier) == NULL_TREE)
277 push_obstacks_nochange ();
278 end_temporary_allocation ();
279 IDENTIFIER_LOCAL_VALUE (time_identifier) = build_int_2 (0, 0);
280 IDENTIFIER_CLASS_VALUE (time_identifier) = build_int_2 (0, 1);
281 IDENTIFIER_GLOBAL_VALUE (time_identifier) = filename_times;
282 filename_times = time_identifier;
285 return time_identifier;
294 int old_quiet_flag = quiet_flag;
297 this_time = get_run_time ();
298 quiet_flag = old_quiet_flag;
302 /* Table indexed by tree code giving a string containing a character
303 classifying the tree code. Possibilities are
304 t, d, s, c, r, <, 1 and 2. See cp/tree.def for details. */
306 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
308 char *cplus_tree_code_type[] = {
314 /* Table indexed by tree code giving number of expression
315 operands beyond the fixed part of the node structure.
316 Not used for types or decls. */
318 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
320 int cplus_tree_code_length[] = {
326 /* Names of tree components.
327 Used for printing out the tree and error messages. */
328 #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
330 char *cplus_tree_code_name[] = {
336 /* toplev.c needs to call these. */
341 /* the beginning of the file is a new line; check for # */
342 /* With luck, we discover the real source file's name from that
343 and put it in input_filename. */
344 put_back (check_newline ());
345 if (flag_gnu_xref) GNU_xref_begin (input_filename);
346 init_repo (input_filename);
352 extern int errorcount, sorrycount;
353 if (flag_gnu_xref) GNU_xref_end (errorcount+sorrycount);
363 init_filename_times ()
365 this_filename_time = get_time_identifier ("<top level>");
366 if (flag_detailed_statistics)
369 body_time = my_get_run_time ();
370 TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time)) = body_time;
374 /* Change by Bryan Boreham, Kewill, Thu Jul 27 09:46:05 1989.
375 Stuck this hack in to get the files open correctly; this is called
376 in place of init_lex if we are an unexec'd binary. */
378 reinit_lang_specific ()
380 init_filename_times ();
381 reinit_search_statistics ();
389 extern char *(*decl_printable_name) ();
390 extern int flag_no_gnu_keywords;
391 extern int flag_operator_names;
395 /* Initialize the lookahead machinery. */
398 /* Make identifier nodes long enough for the language-specific slots. */
399 set_identifier_size (sizeof (struct lang_identifier));
400 decl_printable_name = lang_printable_name;
402 init_cplus_expand ();
405 = (char **) realloc (tree_code_type,
406 sizeof (char *) * LAST_CPLUS_TREE_CODE);
408 = (int *) realloc (tree_code_length,
409 sizeof (int) * LAST_CPLUS_TREE_CODE);
411 = (char **) realloc (tree_code_name,
412 sizeof (char *) * LAST_CPLUS_TREE_CODE);
413 bcopy ((char *)cplus_tree_code_type,
414 (char *)(tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE),
415 (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
416 bcopy ((char *)cplus_tree_code_length,
417 (char *)(tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE),
418 (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
419 bcopy ((char *)cplus_tree_code_name,
420 (char *)(tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
421 (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
423 opname_tab = (char **)oballoc ((int)LAST_CPLUS_TREE_CODE * sizeof (char *));
424 bzero ((char *)opname_tab, (int)LAST_CPLUS_TREE_CODE * sizeof (char *));
425 assignop_tab = (char **)oballoc ((int)LAST_CPLUS_TREE_CODE * sizeof (char *));
426 bzero ((char *)assignop_tab, (int)LAST_CPLUS_TREE_CODE * sizeof (char *));
428 ansi_opname[0] = get_identifier ("<invalid operator>");
429 for (i = 0; i < (int) LAST_CPLUS_TREE_CODE; i++)
431 ansi_opname[i] = ansi_opname[0];
432 ansi_assopname[i] = ansi_opname[0];
435 ansi_opname[(int) MULT_EXPR] = get_identifier ("__ml");
436 IDENTIFIER_OPNAME_P (ansi_opname[(int) MULT_EXPR]) = 1;
437 ansi_opname[(int) INDIRECT_REF] = ansi_opname[(int) MULT_EXPR];
438 ansi_assopname[(int) MULT_EXPR] = get_identifier ("__aml");
439 IDENTIFIER_OPNAME_P (ansi_assopname[(int) MULT_EXPR]) = 1;
440 ansi_assopname[(int) INDIRECT_REF] = ansi_assopname[(int) MULT_EXPR];
441 ansi_opname[(int) TRUNC_MOD_EXPR] = get_identifier ("__md");
442 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUNC_MOD_EXPR]) = 1;
443 ansi_assopname[(int) TRUNC_MOD_EXPR] = get_identifier ("__amd");
444 IDENTIFIER_OPNAME_P (ansi_assopname[(int) TRUNC_MOD_EXPR]) = 1;
445 ansi_opname[(int) CEIL_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
446 ansi_opname[(int) FLOOR_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
447 ansi_opname[(int) ROUND_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
448 ansi_opname[(int) MINUS_EXPR] = get_identifier ("__mi");
449 IDENTIFIER_OPNAME_P (ansi_opname[(int) MINUS_EXPR]) = 1;
450 ansi_opname[(int) NEGATE_EXPR] = ansi_opname[(int) MINUS_EXPR];
451 ansi_assopname[(int) MINUS_EXPR] = get_identifier ("__ami");
452 IDENTIFIER_OPNAME_P (ansi_assopname[(int) MINUS_EXPR]) = 1;
453 ansi_assopname[(int) NEGATE_EXPR] = ansi_assopname[(int) MINUS_EXPR];
454 ansi_opname[(int) RSHIFT_EXPR] = get_identifier ("__rs");
455 IDENTIFIER_OPNAME_P (ansi_opname[(int) RSHIFT_EXPR]) = 1;
456 ansi_assopname[(int) RSHIFT_EXPR] = get_identifier ("__ars");
457 IDENTIFIER_OPNAME_P (ansi_assopname[(int) RSHIFT_EXPR]) = 1;
458 ansi_opname[(int) NE_EXPR] = get_identifier ("__ne");
459 IDENTIFIER_OPNAME_P (ansi_opname[(int) NE_EXPR]) = 1;
460 ansi_opname[(int) GT_EXPR] = get_identifier ("__gt");
461 IDENTIFIER_OPNAME_P (ansi_opname[(int) GT_EXPR]) = 1;
462 ansi_opname[(int) GE_EXPR] = get_identifier ("__ge");
463 IDENTIFIER_OPNAME_P (ansi_opname[(int) GE_EXPR]) = 1;
464 ansi_opname[(int) BIT_IOR_EXPR] = get_identifier ("__or");
465 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_IOR_EXPR]) = 1;
466 ansi_assopname[(int) BIT_IOR_EXPR] = get_identifier ("__aor");
467 IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_IOR_EXPR]) = 1;
468 ansi_opname[(int) TRUTH_ANDIF_EXPR] = get_identifier ("__aa");
469 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_ANDIF_EXPR]) = 1;
470 ansi_opname[(int) TRUTH_NOT_EXPR] = get_identifier ("__nt");
471 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_NOT_EXPR]) = 1;
472 ansi_opname[(int) PREINCREMENT_EXPR] = get_identifier ("__pp");
473 IDENTIFIER_OPNAME_P (ansi_opname[(int) PREINCREMENT_EXPR]) = 1;
474 ansi_opname[(int) POSTINCREMENT_EXPR] = ansi_opname[(int) PREINCREMENT_EXPR];
475 ansi_opname[(int) MODIFY_EXPR] = get_identifier ("__as");
476 IDENTIFIER_OPNAME_P (ansi_opname[(int) MODIFY_EXPR]) = 1;
477 ansi_assopname[(int) NOP_EXPR] = ansi_opname[(int) MODIFY_EXPR];
478 ansi_opname[(int) COMPOUND_EXPR] = get_identifier ("__cm");
479 IDENTIFIER_OPNAME_P (ansi_opname[(int) COMPOUND_EXPR]) = 1;
480 ansi_opname[(int) EXACT_DIV_EXPR] = get_identifier ("__dv");
481 IDENTIFIER_OPNAME_P (ansi_opname[(int) EXACT_DIV_EXPR]) = 1;
482 ansi_assopname[(int) EXACT_DIV_EXPR] = get_identifier ("__adv");
483 IDENTIFIER_OPNAME_P (ansi_assopname[(int) EXACT_DIV_EXPR]) = 1;
484 ansi_opname[(int) TRUNC_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
485 ansi_opname[(int) CEIL_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
486 ansi_opname[(int) FLOOR_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
487 ansi_opname[(int) ROUND_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
488 ansi_opname[(int) PLUS_EXPR] = get_identifier ("__pl");
489 ansi_assopname[(int) TRUNC_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
490 ansi_assopname[(int) CEIL_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
491 ansi_assopname[(int) FLOOR_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
492 ansi_assopname[(int) ROUND_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
493 IDENTIFIER_OPNAME_P (ansi_opname[(int) PLUS_EXPR]) = 1;
494 ansi_assopname[(int) PLUS_EXPR] = get_identifier ("__apl");
495 IDENTIFIER_OPNAME_P (ansi_assopname[(int) PLUS_EXPR]) = 1;
496 ansi_opname[(int) CONVERT_EXPR] = ansi_opname[(int) PLUS_EXPR];
497 ansi_assopname[(int) CONVERT_EXPR] = ansi_assopname[(int) PLUS_EXPR];
498 ansi_opname[(int) LSHIFT_EXPR] = get_identifier ("__ls");
499 IDENTIFIER_OPNAME_P (ansi_opname[(int) LSHIFT_EXPR]) = 1;
500 ansi_assopname[(int) LSHIFT_EXPR] = get_identifier ("__als");
501 IDENTIFIER_OPNAME_P (ansi_assopname[(int) LSHIFT_EXPR]) = 1;
502 ansi_opname[(int) EQ_EXPR] = get_identifier ("__eq");
503 IDENTIFIER_OPNAME_P (ansi_opname[(int) EQ_EXPR]) = 1;
504 ansi_opname[(int) LT_EXPR] = get_identifier ("__lt");
505 IDENTIFIER_OPNAME_P (ansi_opname[(int) LT_EXPR]) = 1;
506 ansi_opname[(int) LE_EXPR] = get_identifier ("__le");
507 IDENTIFIER_OPNAME_P (ansi_opname[(int) LE_EXPR]) = 1;
508 ansi_opname[(int) BIT_AND_EXPR] = get_identifier ("__ad");
509 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_AND_EXPR]) = 1;
510 ansi_assopname[(int) BIT_AND_EXPR] = get_identifier ("__aad");
511 IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_AND_EXPR]) = 1;
512 ansi_opname[(int) ADDR_EXPR] = ansi_opname[(int) BIT_AND_EXPR];
513 ansi_assopname[(int) ADDR_EXPR] = ansi_assopname[(int) BIT_AND_EXPR];
514 ansi_opname[(int) BIT_XOR_EXPR] = get_identifier ("__er");
515 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_XOR_EXPR]) = 1;
516 ansi_assopname[(int) BIT_XOR_EXPR] = get_identifier ("__aer");
517 IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_XOR_EXPR]) = 1;
518 ansi_opname[(int) TRUTH_ORIF_EXPR] = get_identifier ("__oo");
519 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_ORIF_EXPR]) = 1;
520 ansi_opname[(int) BIT_NOT_EXPR] = get_identifier ("__co");
521 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_NOT_EXPR]) = 1;
522 ansi_opname[(int) PREDECREMENT_EXPR] = get_identifier ("__mm");
523 IDENTIFIER_OPNAME_P (ansi_opname[(int) PREDECREMENT_EXPR]) = 1;
524 ansi_opname[(int) POSTDECREMENT_EXPR] = ansi_opname[(int) PREDECREMENT_EXPR];
525 ansi_opname[(int) COMPONENT_REF] = get_identifier ("__rf");
526 IDENTIFIER_OPNAME_P (ansi_opname[(int) COMPONENT_REF]) = 1;
527 ansi_opname[(int) MEMBER_REF] = get_identifier ("__rm");
528 IDENTIFIER_OPNAME_P (ansi_opname[(int) MEMBER_REF]) = 1;
529 ansi_opname[(int) CALL_EXPR] = get_identifier ("__cl");
530 IDENTIFIER_OPNAME_P (ansi_opname[(int) CALL_EXPR]) = 1;
531 ansi_opname[(int) ARRAY_REF] = get_identifier ("__vc");
532 IDENTIFIER_OPNAME_P (ansi_opname[(int) ARRAY_REF]) = 1;
533 ansi_opname[(int) NEW_EXPR] = get_identifier ("__nw");
534 IDENTIFIER_OPNAME_P (ansi_opname[(int) NEW_EXPR]) = 1;
535 ansi_opname[(int) DELETE_EXPR] = get_identifier ("__dl");
536 IDENTIFIER_OPNAME_P (ansi_opname[(int) DELETE_EXPR]) = 1;
537 ansi_opname[(int) VEC_NEW_EXPR] = get_identifier ("__vn");
538 IDENTIFIER_OPNAME_P (ansi_opname[(int) VEC_NEW_EXPR]) = 1;
539 ansi_opname[(int) VEC_DELETE_EXPR] = get_identifier ("__vd");
540 IDENTIFIER_OPNAME_P (ansi_opname[(int) VEC_DELETE_EXPR]) = 1;
541 ansi_opname[(int) TYPE_EXPR] = get_identifier ("__op");
542 IDENTIFIER_OPNAME_P (ansi_opname[(int) TYPE_EXPR]) = 1;
544 /* This is not true: these operators are not defined in ANSI,
545 but we need them anyway. */
546 ansi_opname[(int) MIN_EXPR] = get_identifier ("__mn");
547 IDENTIFIER_OPNAME_P (ansi_opname[(int) MIN_EXPR]) = 1;
548 ansi_opname[(int) MAX_EXPR] = get_identifier ("__mx");
549 IDENTIFIER_OPNAME_P (ansi_opname[(int) MAX_EXPR]) = 1;
550 ansi_opname[(int) COND_EXPR] = get_identifier ("__cn");
551 IDENTIFIER_OPNAME_P (ansi_opname[(int) COND_EXPR]) = 1;
552 ansi_opname[(int) METHOD_CALL_EXPR] = get_identifier ("__wr");
553 IDENTIFIER_OPNAME_P (ansi_opname[(int) METHOD_CALL_EXPR]) = 1;
557 gcc_obstack_init (&inline_text_obstack);
559 /* Start it at 0, because check_newline is called at the very beginning
560 and will increment it to 1. */
562 input_filename = "<internal>";
563 current_function_decl = NULL;
566 token_buffer = (char *) xmalloc (maxtoken + 2);
568 ridpointers[(int) RID_INT] = get_identifier ("int");
569 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INT],
570 build_tree_list (NULL_TREE, ridpointers[(int) RID_INT]));
571 ridpointers[(int) RID_BOOL] = get_identifier ("bool");
572 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_BOOL],
573 build_tree_list (NULL_TREE, ridpointers[(int) RID_BOOL]));
574 ridpointers[(int) RID_CHAR] = get_identifier ("char");
575 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CHAR],
576 build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]));
577 ridpointers[(int) RID_VOID] = get_identifier ("void");
578 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOID],
579 build_tree_list (NULL_TREE, ridpointers[(int) RID_VOID]));
580 ridpointers[(int) RID_FLOAT] = get_identifier ("float");
581 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FLOAT],
582 build_tree_list (NULL_TREE, ridpointers[(int) RID_FLOAT]));
583 ridpointers[(int) RID_DOUBLE] = get_identifier ("double");
584 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_DOUBLE],
585 build_tree_list (NULL_TREE, ridpointers[(int) RID_DOUBLE]));
586 ridpointers[(int) RID_SHORT] = get_identifier ("short");
587 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SHORT],
588 build_tree_list (NULL_TREE, ridpointers[(int) RID_SHORT]));
589 ridpointers[(int) RID_LONG] = get_identifier ("long");
590 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_LONG],
591 build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]));
592 ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned");
593 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_UNSIGNED],
594 build_tree_list (NULL_TREE, ridpointers[(int) RID_UNSIGNED]));
595 ridpointers[(int) RID_SIGNED] = get_identifier ("signed");
596 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SIGNED],
597 build_tree_list (NULL_TREE, ridpointers[(int) RID_SIGNED]));
598 ridpointers[(int) RID_INLINE] = get_identifier ("inline");
599 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INLINE],
600 build_tree_list (NULL_TREE, ridpointers[(int) RID_INLINE]));
601 ridpointers[(int) RID_CONST] = get_identifier ("const");
602 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CONST],
603 build_tree_list (NULL_TREE, ridpointers[(int) RID_CONST]));
604 ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
605 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOLATILE],
606 build_tree_list (NULL_TREE, ridpointers[(int) RID_VOLATILE]));
607 ridpointers[(int) RID_AUTO] = get_identifier ("auto");
608 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_AUTO],
609 build_tree_list (NULL_TREE, ridpointers[(int) RID_AUTO]));
610 ridpointers[(int) RID_STATIC] = get_identifier ("static");
611 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_STATIC],
612 build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC]));
613 ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
614 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_EXTERN],
615 build_tree_list (NULL_TREE, ridpointers[(int) RID_EXTERN]));
616 ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
617 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_TYPEDEF],
618 build_tree_list (NULL_TREE, ridpointers[(int) RID_TYPEDEF]));
619 ridpointers[(int) RID_REGISTER] = get_identifier ("register");
620 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_REGISTER],
621 build_tree_list (NULL_TREE, ridpointers[(int) RID_REGISTER]));
623 /* C++ extensions. These are probably not correctly named. */
624 ridpointers[(int) RID_WCHAR] = get_identifier ("__wchar_t");
625 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_WCHAR],
626 build_tree_list (NULL_TREE, ridpointers[(int) RID_WCHAR]));
627 class_type_node = build_int_2 (class_type, 0);
628 TREE_TYPE (class_type_node) = class_type_node;
629 ridpointers[(int) RID_CLASS] = class_type_node;
631 record_type_node = build_int_2 (record_type, 0);
632 TREE_TYPE (record_type_node) = record_type_node;
633 ridpointers[(int) RID_RECORD] = record_type_node;
635 union_type_node = build_int_2 (union_type, 0);
636 TREE_TYPE (union_type_node) = union_type_node;
637 ridpointers[(int) RID_UNION] = union_type_node;
639 enum_type_node = build_int_2 (enum_type, 0);
640 TREE_TYPE (enum_type_node) = enum_type_node;
641 ridpointers[(int) RID_ENUM] = enum_type_node;
643 ridpointers[(int) RID_VIRTUAL] = get_identifier ("virtual");
644 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VIRTUAL],
645 build_tree_list (NULL_TREE, ridpointers[(int) RID_VIRTUAL]));
646 ridpointers[(int) RID_EXPLICIT] = get_identifier ("explicit");
647 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_EXPLICIT],
648 build_tree_list (NULL_TREE, ridpointers[(int) RID_EXPLICIT]));
649 ridpointers[(int) RID_FRIEND] = get_identifier ("friend");
650 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FRIEND],
651 build_tree_list (NULL_TREE, ridpointers[(int) RID_FRIEND]));
653 ridpointers[(int) RID_PUBLIC] = get_identifier ("public");
654 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_PUBLIC],
655 build_tree_list (NULL_TREE, ridpointers[(int) RID_PUBLIC]));
656 ridpointers[(int) RID_PRIVATE] = get_identifier ("private");
657 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_PRIVATE],
658 build_tree_list (NULL_TREE, ridpointers[(int) RID_PRIVATE]));
659 ridpointers[(int) RID_PROTECTED] = get_identifier ("protected");
660 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_PROTECTED],
661 build_tree_list (NULL_TREE, ridpointers[(int) RID_PROTECTED]));
662 ridpointers[(int) RID_TEMPLATE] = get_identifier ("template");
663 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_TEMPLATE],
664 build_tree_list (NULL_TREE, ridpointers[(int) RID_TEMPLATE]));
665 /* This is for ANSI C++. */
666 ridpointers[(int) RID_MUTABLE] = get_identifier ("mutable");
667 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_MUTABLE],
668 build_tree_list (NULL_TREE, ridpointers[(int) RID_MUTABLE]));
670 /* Signature handling extensions. */
671 signature_type_node = build_int_2 (signature_type, 0);
672 TREE_TYPE (signature_type_node) = signature_type_node;
673 ridpointers[(int) RID_SIGNATURE] = signature_type_node;
675 opname_tab[(int) COMPONENT_REF] = "->";
676 opname_tab[(int) MEMBER_REF] = "->*";
677 opname_tab[(int) METHOD_CALL_EXPR] = "->()";
678 opname_tab[(int) INDIRECT_REF] = "(unary *)";
679 opname_tab[(int) ARRAY_REF] = "[]";
680 opname_tab[(int) MODIFY_EXPR] = "=";
681 opname_tab[(int) NEW_EXPR] = "new";
682 opname_tab[(int) DELETE_EXPR] = "delete";
683 opname_tab[(int) VEC_NEW_EXPR] = "new []";
684 opname_tab[(int) VEC_DELETE_EXPR] = "delete []";
685 opname_tab[(int) COND_EXPR] = "... ? ... : ...";
686 opname_tab[(int) CALL_EXPR] = "()";
687 opname_tab[(int) PLUS_EXPR] = "+";
688 opname_tab[(int) MINUS_EXPR] = "-";
689 opname_tab[(int) MULT_EXPR] = "*";
690 opname_tab[(int) TRUNC_DIV_EXPR] = "/";
691 opname_tab[(int) CEIL_DIV_EXPR] = "(ceiling /)";
692 opname_tab[(int) FLOOR_DIV_EXPR] = "(floor /)";
693 opname_tab[(int) ROUND_DIV_EXPR] = "(round /)";
694 opname_tab[(int) TRUNC_MOD_EXPR] = "%";
695 opname_tab[(int) CEIL_MOD_EXPR] = "(ceiling %)";
696 opname_tab[(int) FLOOR_MOD_EXPR] = "(floor %)";
697 opname_tab[(int) ROUND_MOD_EXPR] = "(round %)";
698 opname_tab[(int) NEGATE_EXPR] = "-";
699 opname_tab[(int) MIN_EXPR] = "<?";
700 opname_tab[(int) MAX_EXPR] = ">?";
701 opname_tab[(int) ABS_EXPR] = "abs";
702 opname_tab[(int) FFS_EXPR] = "ffs";
703 opname_tab[(int) LSHIFT_EXPR] = "<<";
704 opname_tab[(int) RSHIFT_EXPR] = ">>";
705 opname_tab[(int) BIT_IOR_EXPR] = "|";
706 opname_tab[(int) BIT_XOR_EXPR] = "^";
707 opname_tab[(int) BIT_AND_EXPR] = "&";
708 opname_tab[(int) BIT_ANDTC_EXPR] = "&~";
709 opname_tab[(int) BIT_NOT_EXPR] = "~";
710 opname_tab[(int) TRUTH_ANDIF_EXPR] = "&&";
711 opname_tab[(int) TRUTH_ORIF_EXPR] = "||";
712 opname_tab[(int) TRUTH_AND_EXPR] = "strict &&";
713 opname_tab[(int) TRUTH_OR_EXPR] = "strict ||";
714 opname_tab[(int) TRUTH_NOT_EXPR] = "!";
715 opname_tab[(int) LT_EXPR] = "<";
716 opname_tab[(int) LE_EXPR] = "<=";
717 opname_tab[(int) GT_EXPR] = ">";
718 opname_tab[(int) GE_EXPR] = ">=";
719 opname_tab[(int) EQ_EXPR] = "==";
720 opname_tab[(int) NE_EXPR] = "!=";
721 opname_tab[(int) IN_EXPR] = "in";
722 opname_tab[(int) RANGE_EXPR] = "..";
723 opname_tab[(int) CONVERT_EXPR] = "(unary +)";
724 opname_tab[(int) ADDR_EXPR] = "(unary &)";
725 opname_tab[(int) PREDECREMENT_EXPR] = "--";
726 opname_tab[(int) PREINCREMENT_EXPR] = "++";
727 opname_tab[(int) POSTDECREMENT_EXPR] = "--";
728 opname_tab[(int) POSTINCREMENT_EXPR] = "++";
729 opname_tab[(int) COMPOUND_EXPR] = ",";
731 assignop_tab[(int) NOP_EXPR] = "=";
732 assignop_tab[(int) PLUS_EXPR] = "+=";
733 assignop_tab[(int) CONVERT_EXPR] = "+=";
734 assignop_tab[(int) MINUS_EXPR] = "-=";
735 assignop_tab[(int) NEGATE_EXPR] = "-=";
736 assignop_tab[(int) MULT_EXPR] = "*=";
737 assignop_tab[(int) INDIRECT_REF] = "*=";
738 assignop_tab[(int) TRUNC_DIV_EXPR] = "/=";
739 assignop_tab[(int) EXACT_DIV_EXPR] = "(exact /=)";
740 assignop_tab[(int) CEIL_DIV_EXPR] = "(ceiling /=)";
741 assignop_tab[(int) FLOOR_DIV_EXPR] = "(floor /=)";
742 assignop_tab[(int) ROUND_DIV_EXPR] = "(round /=)";
743 assignop_tab[(int) TRUNC_MOD_EXPR] = "%=";
744 assignop_tab[(int) CEIL_MOD_EXPR] = "(ceiling %=)";
745 assignop_tab[(int) FLOOR_MOD_EXPR] = "(floor %=)";
746 assignop_tab[(int) ROUND_MOD_EXPR] = "(round %=)";
747 assignop_tab[(int) MIN_EXPR] = "<?=";
748 assignop_tab[(int) MAX_EXPR] = ">?=";
749 assignop_tab[(int) LSHIFT_EXPR] = "<<=";
750 assignop_tab[(int) RSHIFT_EXPR] = ">>=";
751 assignop_tab[(int) BIT_IOR_EXPR] = "|=";
752 assignop_tab[(int) BIT_XOR_EXPR] = "^=";
753 assignop_tab[(int) BIT_AND_EXPR] = "&=";
754 assignop_tab[(int) ADDR_EXPR] = "&=";
756 init_filename_times ();
758 /* Some options inhibit certain reserved words.
759 Clear those words out of the hash table so they won't be recognized. */
760 #define UNSET_RESERVED_WORD(STRING) \
761 do { struct resword *s = is_reserved_word (STRING, sizeof (STRING) - 1); \
762 if (s) s->name = ""; } while (0)
765 /* let's parse things, and if they use it, then give them an error. */
766 if (!flag_handle_exceptions)
768 UNSET_RESERVED_WORD ("throw");
769 UNSET_RESERVED_WORD ("try");
770 UNSET_RESERVED_WORD ("catch");
774 if (!flag_rtti || flag_no_gnu_keywords)
776 UNSET_RESERVED_WORD ("classof");
777 UNSET_RESERVED_WORD ("headof");
779 if (! flag_handle_signatures || flag_no_gnu_keywords)
781 /* Easiest way to not recognize signature
782 handling extensions... */
783 UNSET_RESERVED_WORD ("signature");
784 UNSET_RESERVED_WORD ("sigof");
786 if (flag_no_asm || flag_no_gnu_keywords)
787 UNSET_RESERVED_WORD ("typeof");
788 if (! flag_operator_names)
790 /* These are new ANSI keywords that may break code. */
791 UNSET_RESERVED_WORD ("and");
792 UNSET_RESERVED_WORD ("and_eq");
793 UNSET_RESERVED_WORD ("bitand");
794 UNSET_RESERVED_WORD ("bitor");
795 UNSET_RESERVED_WORD ("compl");
796 UNSET_RESERVED_WORD ("not");
797 UNSET_RESERVED_WORD ("not_eq");
798 UNSET_RESERVED_WORD ("or");
799 UNSET_RESERVED_WORD ("or_eq");
800 UNSET_RESERVED_WORD ("xor");
801 UNSET_RESERVED_WORD ("xor_eq");
803 if (! flag_traditional)
804 UNSET_RESERVED_WORD ("overload");
806 token_count = init_parse ();
807 interface_unknown = 1;
811 reinit_parse_for_function ()
813 current_base_init_list = NULL_TREE;
814 current_member_init_list = NULL_TREE;
821 yyprint (file, yychar, yylval)
833 case IDENTIFIER_DEFN:
836 case TYPENAME_ELLIPSIS:
838 case PRE_PARSED_CLASS_DECL:
840 if (TREE_CODE (t) == TYPE_DECL)
842 fprintf (file, " `%s'", DECL_NAME (t));
845 my_friendly_assert (TREE_CODE (t) == IDENTIFIER_NODE, 224);
846 if (IDENTIFIER_POINTER (t))
847 fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
850 if (yylval.ttype == class_type_node)
851 fprintf (file, " `class'");
852 else if (yylval.ttype == record_type_node)
853 fprintf (file, " `struct'");
854 else if (yylval.ttype == union_type_node)
855 fprintf (file, " `union'");
856 else if (yylval.ttype == enum_type_node)
857 fprintf (file, " `enum'");
858 else if (yylval.ttype == signature_type_node)
859 fprintf (file, " `signature'");
861 my_friendly_abort (80);
866 #if defined(GATHER_STATISTICS) && defined(REDUCE_LENGTH)
867 static int *reduce_count;
873 #define REDUCE_LENGTH (sizeof (yyr2) / sizeof (yyr2[0]))
874 #define TOKEN_LENGTH (256 + sizeof (yytname) / sizeof (yytname[0]))
880 #ifdef GATHER_STATISTICS
882 reduce_count = (int *)malloc (sizeof (int) * (REDUCE_LENGTH + 1));
883 bzero (reduce_count, sizeof (int) * (REDUCE_LENGTH + 1));
885 token_count = (int *)malloc (sizeof (int) * (TOKEN_LENGTH + 1));
886 bzero (token_count, sizeof (int) * (TOKEN_LENGTH + 1));
893 #ifdef GATHER_STATISTICS
899 reduce_count[yyn] += 1;
906 return reduce_count[*q] - reduce_count[*p];
913 return token_count[*q] - token_count[*p];
919 print_parse_statistics ()
921 #ifdef GATHER_STATISTICS
925 int maxlen = REDUCE_LENGTH;
928 if (reduce_count[-1] == 0)
931 if (TOKEN_LENGTH > REDUCE_LENGTH)
932 maxlen = TOKEN_LENGTH;
933 sorted = (unsigned *) alloca (sizeof (int) * maxlen);
935 for (i = 0; i < TOKEN_LENGTH; i++)
937 qsort (sorted, TOKEN_LENGTH, sizeof (int), token_cmp);
938 for (i = 0; i < TOKEN_LENGTH; i++)
940 int index = sorted[i];
941 if (token_count[index] == 0)
943 if (token_count[index] < token_count[-1])
945 fprintf (stderr, "token %d, `%s', count = %d\n",
946 index, yytname[YYTRANSLATE (index)], token_count[index]);
948 fprintf (stderr, "\n");
949 for (i = 0; i < REDUCE_LENGTH; i++)
951 qsort (sorted, REDUCE_LENGTH, sizeof (int), reduce_cmp);
952 for (i = 0; i < REDUCE_LENGTH; i++)
954 int index = sorted[i];
955 if (reduce_count[index] == 0)
957 if (reduce_count[index] < reduce_count[-1])
959 fprintf (stderr, "rule %d, line %d, count = %d\n",
960 index, yyrline[index], reduce_count[index]);
962 fprintf (stderr, "\n");
968 /* Sets the value of the 'yydebug' variable to VALUE.
969 This is a function so we don't have to have YYDEBUG defined
970 in order to build the compiler. */
979 warning ("YYDEBUG not defined.");
984 /* Functions and data structures for #pragma interface.
986 `#pragma implementation' means that the main file being compiled
987 is considered to implement (provide) the classes that appear in
988 its main body. I.e., if this is file "foo.cc", and class `bar'
989 is defined in "foo.cc", then we say that "foo.cc implements bar".
991 All main input files "implement" themselves automagically.
993 `#pragma interface' means that unless this file (of the form "foo.h"
994 is not presently being included by file "foo.cc", the
995 CLASSTYPE_INTERFACE_ONLY bit gets set. The effect is that none
996 of the vtables nor any of the inline functions defined in foo.h
999 There are cases when we want to link files such as "defs.h" and
1000 "main.cc". In this case, we give "defs.h" a `#pragma interface',
1001 and "main.cc" has `#pragma implementation "defs.h"'. */
1006 struct impl_files *next;
1009 static struct impl_files *impl_file_chain;
1011 /* Helper function to load global variables with interface
1014 extract_interface_info ()
1018 if (flag_alt_external_templates)
1020 struct tinst_level *til = tinst_for_decl ();
1023 fileinfo = get_time_identifier (til->file);
1026 fileinfo = get_time_identifier (input_filename);
1027 fileinfo = IDENTIFIER_CLASS_VALUE (fileinfo);
1028 interface_only = TREE_INT_CST_LOW (fileinfo);
1029 interface_unknown = TREE_INT_CST_HIGH (fileinfo);
1032 /* Return nonzero if S is not considered part of an
1033 INTERFACE/IMPLEMENTATION pair. Otherwise, return 0. */
1035 interface_strcmp (s)
1038 /* Set the interface/implementation bits for this scope. */
1039 struct impl_files *ifiles;
1042 for (ifiles = impl_file_chain; ifiles; ifiles = ifiles->next)
1044 char *t1 = ifiles->filename;
1047 if (*s1 != *t1 || *s1 == 0)
1050 while (*s1 == *t1 && *s1 != 0)
1057 /* Don't get faked out by xxx.yyy.cc vs xxx.zzz.cc. */
1058 if (index (s1, '.') || index (t1, '.'))
1061 if (*s1 == '\0' || s1[-1] != '.' || t1[-1] != '.')
1073 set_typedecl_interface_info (prev, vars)
1076 tree id = get_time_identifier (DECL_SOURCE_FILE (vars));
1077 tree fileinfo = IDENTIFIER_CLASS_VALUE (id);
1078 tree type = TREE_TYPE (vars);
1080 CLASSTYPE_INTERFACE_ONLY (type) = TREE_INT_CST_LOW (fileinfo)
1081 = interface_strcmp (FILE_NAME_NONDIRECTORY (DECL_SOURCE_FILE (vars)));
1085 set_vardecl_interface_info (prev, vars)
1088 tree type = DECL_CONTEXT (vars);
1090 if (CLASSTYPE_INTERFACE_KNOWN (type))
1092 if (CLASSTYPE_INTERFACE_ONLY (type))
1093 set_typedecl_interface_info (prev, TYPE_NAME (type));
1095 CLASSTYPE_VTABLE_NEEDS_WRITING (type) = 1;
1096 DECL_EXTERNAL (vars) = CLASSTYPE_INTERFACE_ONLY (type);
1097 TREE_PUBLIC (vars) = 1;
1103 /* Called from the top level: if there are any pending inlines to
1104 do, set up to process them now. This function sets up the first function
1105 to be parsed; after it has been, the rule for fndef in parse.y will
1106 call process_next_inline to start working on the next one. */
1108 do_pending_inlines ()
1110 struct pending_inline *t;
1113 /* Oops, we're still dealing with the last batch. */
1114 if (yychar == PRE_PARSED_FUNCTION_DECL)
1117 /* Reverse the pending inline functions, since
1118 they were cons'd instead of appended. */
1120 struct pending_inline *prev = 0, *tail;
1121 t = pending_inlines;
1122 pending_inlines = 0;
1137 /* Now start processing the first inline function. */
1138 context = hack_decl_function_context (t->fndecl);
1140 push_cp_function_context (context);
1143 feed_input (t->buf, t->len, t->can_free ? &inline_text_obstack : 0);
1146 if (input_filename != t->filename)
1148 input_filename = t->filename;
1149 /* Get interface/implementation back in sync. */
1150 extract_interface_info ();
1153 input_filename = t->filename;
1154 interface_unknown = t->interface == 1;
1155 interface_only = t->interface == 0;
1157 yychar = PRE_PARSED_FUNCTION_DECL;
1159 /* Pass back a handle on the rest of the inline functions, so that they
1160 can be processed later. */
1161 yylval.ttype = build_tree_list ((tree) t, t->fndecl);
1162 DECL_PENDING_INLINE_INFO (t->fndecl) = 0;
1165 extern struct pending_input *to_be_restored;
1166 static int nextchar = -1;
1168 /* Called from the fndecl rule in the parser when the function just parsed
1169 was declared using a PRE_PARSED_FUNCTION_DECL (i.e. came from
1170 do_pending_inlines). */
1172 process_next_inline (t)
1176 struct pending_inline *i = (struct pending_inline *) TREE_PURPOSE (t);
1177 context = hack_decl_function_context (i->fndecl);
1179 pop_cp_function_context (context);
1181 if (yychar == YYEMPTY)
1183 if (yychar != END_OF_SAVED_INPUT)
1185 error ("parse error at end of saved function text");
1186 /* restore_pending_input will abort unless yychar is either
1187 * END_OF_SAVED_INPUT or YYEMPTY; since we already know we're
1188 * hosed, feed back YYEMPTY.
1189 * We also need to discard nextchar, since that may have gotten
1195 if (to_be_restored == 0)
1196 my_friendly_abort (123);
1197 restore_pending_input (to_be_restored);
1199 if (i && i->fndecl != NULL_TREE)
1201 context = hack_decl_function_context (i->fndecl);
1203 push_cp_function_context (context);
1204 feed_input (i->buf, i->len, i->can_free ? &inline_text_obstack : 0);
1206 input_filename = i->filename;
1207 yychar = PRE_PARSED_FUNCTION_DECL;
1208 yylval.ttype = build_tree_list ((tree) i, i->fndecl);
1209 DECL_PENDING_INLINE_INFO (i->fndecl) = 0;
1213 interface_unknown = i->interface == 1;
1214 interface_only = i->interface == 0;
1217 extract_interface_info ();
1220 /* Since inline methods can refer to text which has not yet been seen,
1221 we store the text of the method in a structure which is placed in the
1222 DECL_PENDING_INLINE_INFO field of the FUNCTION_DECL.
1223 After parsing the body of the class definition, the FUNCTION_DECL's are
1224 scanned to see which ones have this field set. Those are then digested
1227 This function's FUNCTION_DECL will have a bit set in its common so
1228 that we know to watch out for it. */
1231 consume_string (this_obstack, matching_char)
1232 register struct obstack *this_obstack;
1236 int starting_lineno = lineno;
1242 int save_lineno = lineno;
1243 lineno = starting_lineno;
1244 if (matching_char == '"')
1245 error ("end of file encountered inside string constant");
1247 error ("end of file encountered inside character constant");
1248 lineno = save_lineno;
1253 obstack_1grow (this_obstack, c);
1255 obstack_1grow (this_obstack, c);
1257 /* Make sure we continue the loop */
1264 pedwarn ("ANSI C++ forbids newline in string constant");
1267 obstack_1grow (this_obstack, c);
1269 while (c != matching_char);
1272 static int nextyychar = YYEMPTY;
1273 static YYSTYPE nextyylval;
1275 struct pending_input {
1276 int nextchar, yychar, nextyychar, eof;
1277 YYSTYPE yylval, nextyylval;
1278 struct obstack token_obstack;
1282 struct pending_input *
1283 save_pending_input ()
1285 struct pending_input *p;
1286 p = (struct pending_input *) xmalloc (sizeof (struct pending_input));
1287 p->nextchar = nextchar;
1289 p->nextyychar = nextyychar;
1291 p->nextyylval = nextyylval;
1292 p->eof = end_of_file;
1293 yychar = nextyychar = YYEMPTY;
1295 p->first_token = first_token;
1296 p->token_obstack = token_obstack;
1299 gcc_obstack_init (&token_obstack);
1305 restore_pending_input (p)
1306 struct pending_input *p;
1308 my_friendly_assert (nextchar == -1, 229);
1309 nextchar = p->nextchar;
1310 my_friendly_assert (yychar == YYEMPTY || yychar == END_OF_SAVED_INPUT, 230);
1312 my_friendly_assert (nextyychar == YYEMPTY, 231);
1313 nextyychar = p->nextyychar;
1315 nextyylval = p->nextyylval;
1316 first_token = p->first_token;
1317 obstack_free (&token_obstack, (char *) 0);
1318 token_obstack = p->token_obstack;
1319 end_of_file = p->eof;
1323 /* Return next non-whitespace input character, which may come
1324 from `finput', or from `nextchar'. */
1336 return skip_white_space (c);
1339 /* Unget character CH from the input stream.
1340 If RESCAN is non-zero, then we want to `see' this
1341 character as the next input token. */
1343 yyungetc (ch, rescan)
1347 /* Unget a character from the input stream. */
1348 if (yychar == YYEMPTY || rescan == 0)
1351 put_back (nextchar);
1356 my_friendly_assert (nextyychar == YYEMPTY, 232);
1357 nextyychar = yychar;
1358 nextyylval = yylval;
1363 /* This function stores away the text for an inline function that should
1364 be processed later. It decides how much later, and may need to move
1365 the info between obstacks; therefore, the caller should not refer to
1366 the T parameter after calling this function. */
1369 store_pending_inline (decl, t)
1371 struct pending_inline *t;
1374 DECL_PENDING_INLINE_INFO (decl) = t;
1376 /* Because we use obstacks, we must process these in precise order. */
1377 t->next = pending_inlines;
1378 pending_inlines = t;
1381 void reinit_parse_for_block ();
1384 reinit_parse_for_method (yychar, decl)
1389 int starting_lineno = lineno;
1390 char *starting_filename = input_filename;
1392 reinit_parse_for_block (yychar, &inline_text_obstack);
1394 len = obstack_object_size (&inline_text_obstack);
1395 current_base_init_list = NULL_TREE;
1396 current_member_init_list = NULL_TREE;
1397 if (decl == void_type_node
1398 || (current_class_type && TYPE_REDEFINED (current_class_type)))
1400 /* Happens when we get two declarations of the same
1401 function in the same scope. */
1402 char *buf = obstack_finish (&inline_text_obstack);
1403 obstack_free (&inline_text_obstack, buf);
1408 struct pending_inline *t;
1409 char *buf = obstack_finish (&inline_text_obstack);
1411 t = (struct pending_inline *) obstack_alloc (&inline_text_obstack,
1412 sizeof (struct pending_inline));
1413 t->lineno = starting_lineno;
1414 t->filename = starting_filename;
1422 if (interface_unknown && processing_template_defn && flag_external_templates && ! DECL_IN_SYSTEM_HEADER (decl))
1423 warn_if_unknown_interface (decl);
1425 t->interface = (interface_unknown ? 1 : (interface_only ? 0 : 2));
1426 store_pending_inline (decl, t);
1430 /* Consume a block -- actually, a method beginning
1431 with `:' or `{' -- and save it away on the specified obstack. */
1434 reinit_parse_for_block (pyychar, obstackp)
1436 struct obstack *obstackp;
1440 int starting_lineno = lineno;
1441 char *starting_filename = input_filename;
1443 int look_for_semicolon = 0;
1444 int look_for_lbrac = 0;
1447 obstack_1grow (obstackp, '{');
1448 else if (pyychar == '=')
1449 look_for_semicolon = 1;
1450 else if (pyychar == ':')
1452 obstack_1grow (obstackp, pyychar);
1456 else if (pyychar == RETURN)
1458 obstack_grow (obstackp, "return", 6);
1462 else if (pyychar == TRY)
1464 obstack_grow (obstackp, "try", 3);
1470 yyerror ("parse error in method specification");
1471 obstack_1grow (obstackp, '{');
1474 if (nextchar != EOF)
1484 int this_lineno = lineno;
1486 c = skip_white_space (c);
1488 /* Don't lose our cool if there are lots of comments. */
1489 if (lineno == this_lineno + 1)
1490 obstack_1grow (obstackp, '\n');
1491 else if (lineno == this_lineno)
1493 else if (lineno - this_lineno < 10)
1496 for (i = lineno - this_lineno; i > 0; i--)
1497 obstack_1grow (obstackp, '\n');
1502 sprintf (buf, "\n# %d \"", lineno);
1504 obstack_grow (obstackp, buf, len);
1506 len = strlen (input_filename);
1507 obstack_grow (obstackp, input_filename, len);
1508 obstack_1grow (obstackp, '\"');
1509 obstack_1grow (obstackp, '\n');
1512 while (c > ' ') /* ASCII dependent... */
1514 obstack_1grow (obstackp, c);
1523 if (blev == 0 && !look_for_semicolon)
1527 if (peekyylex () == CATCH)
1530 obstack_grow (obstackp, " catch ", 7);
1547 /* Don't act on the next character...e.g, doing an escaped
1552 error_with_file_and_line (starting_filename,
1554 "end of file read inside definition");
1557 obstack_1grow (obstackp, c);
1560 consume_string (obstackp, c);
1562 consume_string (obstackp, c);
1567 error ("function body for constructor missing");
1568 obstack_1grow (obstackp, '{');
1569 obstack_1grow (obstackp, '}');
1573 else if (look_for_semicolon && blev == 0)
1581 error_with_file_and_line (starting_filename,
1583 "end of file read inside definition");
1588 obstack_1grow (obstackp, c);
1593 obstack_1grow (obstackp, '\0');
1596 /* Build a default function named NAME for type TYPE.
1597 KIND says what to build.
1599 When KIND == 0, build default destructor.
1600 When KIND == 1, build virtual destructor.
1601 When KIND == 2, build default constructor.
1602 When KIND == 3, build default X(const X&) constructor.
1603 When KIND == 4, build default X(X&) constructor.
1604 When KIND == 5, build default operator = (const X&).
1605 When KIND == 6, build default operator = (X&). */
1608 cons_up_default_function (type, full_name, kind)
1609 tree type, full_name;
1612 extern tree void_list_node;
1613 tree declspecs = NULL_TREE;
1617 tree name = constructor_name (full_name);
1623 declspecs = build_decl_list (NULL_TREE, ridpointers [(int) RID_VIRTUAL]);
1624 /* Fall through... */
1626 name = build_parse_node (BIT_NOT_EXPR, name);
1627 args = void_list_node;
1631 /* Default constructor. */
1632 args = void_list_node;
1636 type = build_type_variant (type, 1, 0);
1637 /* Fall through... */
1639 /* According to ARM $12.8, the default copy ctor will be declared, but
1640 not defined, unless it's needed. */
1641 argtype = build_reference_type (type);
1642 args = tree_cons (NULL_TREE,
1643 build_tree_list (hash_tree_chain (argtype, NULL_TREE),
1644 get_identifier ("_ctor_arg")),
1649 type = build_type_variant (type, 1, 0);
1650 /* Fall through... */
1653 declspecs = build_decl_list (NULL_TREE, type);
1655 name = ansi_opname [(int) MODIFY_EXPR];
1657 argtype = build_reference_type (type);
1658 args = tree_cons (NULL_TREE,
1659 build_tree_list (hash_tree_chain (argtype, NULL_TREE),
1660 get_identifier ("_ctor_arg")),
1665 my_friendly_abort (59);
1668 declspecs = decl_tree_cons (NULL_TREE, ridpointers [(int) RID_INLINE],
1671 TREE_PARMLIST (args) = 1;
1674 tree declarator = build_parse_node (CALL_EXPR, name, args, NULL_TREE);
1676 declarator = build_parse_node (ADDR_EXPR, declarator);
1678 fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE,
1679 NULL_TREE, NULL_TREE);
1682 if (fn == void_type_node)
1686 if (processing_template_defn)
1688 SET_DECL_IMPLICIT_INSTANTIATION (fn);
1689 repo_template_used (fn);
1694 if (CLASSTYPE_INTERFACE_KNOWN (type))
1696 DECL_INTERFACE_KNOWN (fn) = 1;
1697 DECL_NOT_REALLY_EXTERN (fn) = (!CLASSTYPE_INTERFACE_ONLY (type)
1698 && flag_implement_inlines);
1702 DECL_NOT_REALLY_EXTERN (fn) = 1;
1704 mark_inline_for_output (fn);
1706 #ifdef DEBUG_DEFAULT_FUNCTIONS
1707 { char *fn_type = NULL;
1711 case 0: fn_type = "default destructor"; break;
1712 case 1: fn_type = "virtual destructor"; break;
1713 case 2: fn_type = "default constructor"; break;
1714 case 3: fn_type = "default X(const X&)"; break;
1715 case 4: fn_type = "default X(X&)"; break;
1719 if (TREE_CODE (name) == BIT_NOT_EXPR)
1720 t = TREE_OPERAND (name, 0);
1721 fprintf (stderr, "[[[[ %s for %s:\n%s]]]]\n", fn_type,
1722 IDENTIFIER_POINTER (t), func_buf);
1725 #endif /* DEBUG_DEFAULT_FUNCTIONS */
1727 /* Show that this function was generated by the compiler. */
1728 SET_DECL_ARTIFICIAL (fn);
1733 /* Heuristic to tell whether the user is missing a semicolon
1734 after a struct or enum declaration. Emit an error message
1735 if we know the user has blown it. */
1737 check_for_missing_semicolon (type)
1745 && yychar != IDENTIFIER
1746 && yychar != TYPENAME
1747 && yychar != SELFNAME)
1750 if (ANON_AGGRNAME_P (TYPE_IDENTIFIER (type)))
1751 error ("semicolon missing after %s declaration",
1752 TREE_CODE (type) == ENUMERAL_TYPE ? "enum" : "struct");
1754 cp_error ("semicolon missing after declaration of `%T'", type);
1755 shadow_tag (build_tree_list (0, type));
1757 /* Could probably also hack cases where class { ... } f (); appears. */
1762 note_got_semicolon (type)
1765 if (TREE_CODE_CLASS (TREE_CODE (type)) != 't')
1766 my_friendly_abort (60);
1767 if (IS_AGGR_TYPE (type))
1768 CLASSTYPE_GOT_SEMICOLON (type) = 1;
1772 note_list_got_semicolon (declspecs)
1777 for (link = declspecs; link; link = TREE_CHAIN (link))
1779 tree type = TREE_VALUE (link);
1780 if (TREE_CODE_CLASS (TREE_CODE (type)) == 't')
1781 note_got_semicolon (type);
1786 /* If C is not whitespace, return C.
1787 Otherwise skip whitespace and return first nonwhite char read. */
1790 skip_white_space (c)
1798 c = check_newline ();
1809 while (c == ' ' || c == '\t');
1817 error ("stray '\\' in program");
1829 /* Make the token buffer longer, preserving the data in it.
1830 P should point to just beyond the last valid character in the old buffer.
1831 The value we return is a pointer to the new buffer
1832 at a place corresponding to P. */
1835 extend_token_buffer (p)
1838 int offset = p - token_buffer;
1840 maxtoken = maxtoken * 2 + 10;
1841 token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2);
1843 return token_buffer + offset;
1847 get_last_nonwhite_on_line ()
1851 /* Is this the last nonwhite stuff on the line? */
1853 c = nextchar, nextchar = -1;
1857 while (c == ' ' || c == '\t')
1862 /* At the beginning of a line, increment the line number
1863 and process any #-directive on this line.
1864 If the line is a #-directive, read the entire line and return a newline.
1865 Otherwise, return the line's first non-whitespace character. */
1869 int handle_cp_pragma ();
1877 /* Read first nonwhite char on the line. Do this before incrementing the
1878 line number, in case we're at the end of saved text. */
1882 while (c == ' ' || c == '\t');
1888 /* If not #, return it so caller will use it. */
1892 /* Don't read beyond this line. */
1895 /* Read first nonwhite char after the `#'. */
1899 while (c == ' ' || c == '\t');
1901 /* If a letter follows, then if the word here is `line', skip
1902 it and ignore it; otherwise, ignore the line, with an error
1903 if the word isn't `pragma'. */
1905 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
1915 token = real_yylex ();
1916 if (token == IDENTIFIER
1917 && TREE_CODE (yylval.ttype) == IDENTIFIER_NODE)
1919 /* If this is 1, we handled it; if it's -1, it was one we
1920 wanted but had something wrong with it. Only if it's
1921 0 was it not handled. */
1922 if (handle_cp_pragma (IDENTIFIER_POINTER (yylval.ttype)))
1925 else if (token == END_OF_LINE)
1928 #ifdef HANDLE_SYSV_PRAGMA
1929 if (handle_sysv_pragma (finput, token))
1932 #ifdef HANDLE_PRAGMA
1933 if (HANDLE_PRAGMA (finput, yylval.ttype))
1947 && ((c = getch ()) == ' ' || c == '\t'))
1949 #ifdef DWARF_DEBUGGING_INFO
1950 if ((debug_info_level == DINFO_LEVEL_VERBOSE)
1951 && (write_symbols == DWARF_DEBUG))
1952 dwarfout_define (lineno, get_directive_line (finput));
1953 #endif /* DWARF_DEBUGGING_INFO */
1963 && ((c = getch ()) == ' ' || c == '\t'))
1965 #ifdef DWARF_DEBUGGING_INFO
1966 if ((debug_info_level == DINFO_LEVEL_VERBOSE)
1967 && (write_symbols == DWARF_DEBUG))
1968 dwarfout_undef (lineno, get_directive_line (finput));
1969 #endif /* DWARF_DEBUGGING_INFO */
1978 && ((c = getch ()) == ' ' || c == '\t'))
1987 && ((c = getch ()) == ' ' || c == '\t'))
1989 #ifdef ASM_OUTPUT_IDENT
1990 extern FILE *asm_out_file;
1992 /* #ident. The pedantic warning is now in cccp.c. */
1994 /* Here we have just seen `#ident '.
1995 A string constant should follow. */
1997 token = real_yylex ();
1998 if (token == END_OF_LINE)
2001 || TREE_CODE (yylval.ttype) != STRING_CST)
2003 error ("invalid #ident");
2007 if (! flag_no_ident)
2009 #ifdef ASM_OUTPUT_IDENT
2010 ASM_OUTPUT_IDENT (asm_out_file,
2011 TREE_STRING_POINTER (yylval.ttype));
2015 /* Skip the rest of this line. */
2028 && ((c = getch ()) == ' ' || c == '\t'))
2030 /* Used to test incremental compilation. */
2031 sorry ("#pragma newworld");
2035 error ("undefined or invalid # directive");
2040 /* Here we have either `#line' or `# <nonletter>'.
2041 In either case, it should be a line number; a digit should follow. */
2043 while (c == ' ' || c == '\t')
2046 /* If the # is the only nonwhite char on the line,
2047 just ignore it. Check the new newline. */
2051 /* Something follows the #; read a token. */
2054 token = real_yylex ();
2056 if (token == CONSTANT
2057 && TREE_CODE (yylval.ttype) == INTEGER_CST)
2059 int old_lineno = lineno;
2060 enum { act_none, act_push, act_pop } action = act_none;
2061 int entering_system_header = 0;
2062 int entering_c_header = 0;
2064 /* subtract one, because it is the following line that
2065 gets the specified number */
2067 int l = TREE_INT_CST_LOW (yylval.ttype) - 1;
2068 c = get_last_nonwhite_on_line ();
2071 /* No more: store the line number and check following line. */
2077 /* More follows: it must be a string constant (filename). */
2079 /* Read the string constant, but don't treat \ as special. */
2080 ignore_escape_flag = 1;
2081 token = real_yylex ();
2082 ignore_escape_flag = 0;
2084 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
2086 error ("invalid #line");
2090 /* Changing files again. This means currently collected time
2091 is charged against header time, and body time starts back
2093 if (flag_detailed_statistics)
2095 int this_time = my_get_run_time ();
2096 tree time_identifier = get_time_identifier (TREE_STRING_POINTER (yylval.ttype));
2097 header_time += this_time - body_time;
2098 TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time))
2099 += this_time - body_time;
2100 this_filename_time = time_identifier;
2101 body_time = this_time;
2105 = (char *) permalloc (TREE_STRING_LENGTH (yylval.ttype) + 1);
2106 strcpy (input_filename, TREE_STRING_POINTER (yylval.ttype));
2108 GNU_xref_file (input_filename);
2110 if (main_input_filename == 0)
2112 struct impl_files *ifiles = impl_file_chain;
2116 while (ifiles->next)
2117 ifiles = ifiles->next;
2118 ifiles->filename = FILE_NAME_NONDIRECTORY (input_filename);
2121 main_input_filename = input_filename;
2122 if (write_virtuals == 3)
2123 walk_vtables (set_typedecl_interface_info, set_vardecl_interface_info);
2126 extract_interface_info ();
2128 c = get_last_nonwhite_on_line ();
2131 /* Update the name in the top element of input_file_stack. */
2132 if (input_file_stack)
2133 input_file_stack->name = input_filename;
2139 token = real_yylex ();
2141 /* `1' after file name means entering new file.
2142 `2' after file name means just left a file. */
2144 if (token == CONSTANT
2145 && TREE_CODE (yylval.ttype) == INTEGER_CST)
2147 if (TREE_INT_CST_LOW (yylval.ttype) == 1)
2149 else if (TREE_INT_CST_LOW (yylval.ttype) == 2)
2154 c = get_last_nonwhite_on_line ();
2158 token = real_yylex ();
2163 /* `3' after file name means this is a system header file. */
2165 if (token == CONSTANT
2166 && TREE_CODE (yylval.ttype) == INTEGER_CST
2167 && TREE_INT_CST_LOW (yylval.ttype) == 3)
2169 entering_system_header = 1;
2171 c = get_last_nonwhite_on_line ();
2175 token = real_yylex ();
2179 /* `4' after file name means this is a C header file. */
2181 if (token == CONSTANT
2182 && TREE_CODE (yylval.ttype) == INTEGER_CST
2183 && TREE_INT_CST_LOW (yylval.ttype) == 4)
2185 entering_c_header = 1;
2187 c = get_last_nonwhite_on_line ();
2191 token = real_yylex ();
2195 /* Do the actions implied by the preceding numbers. */
2197 if (action == act_push)
2199 /* Pushing to a new file. */
2200 struct file_stack *p;
2202 p = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2203 input_file_stack->line = old_lineno;
2204 p->next = input_file_stack;
2205 p->name = input_filename;
2206 input_file_stack = p;
2207 input_file_stack_tick++;
2208 #ifdef DBX_DEBUGGING_INFO
2209 if (write_symbols == DBX_DEBUG)
2210 dbxout_start_new_source_file (input_filename);
2212 #ifdef DWARF_DEBUGGING_INFO
2213 if (debug_info_level == DINFO_LEVEL_VERBOSE
2214 && write_symbols == DWARF_DEBUG)
2215 dwarfout_start_new_source_file (input_filename);
2216 #endif /* DWARF_DEBUGGING_INFO */
2217 in_system_header = entering_system_header;
2220 else if (entering_c_header)
2223 ++pending_lang_change;
2226 else if (action == act_pop)
2228 /* Popping out of a file. */
2229 if (input_file_stack->next)
2231 struct file_stack *p;
2233 if (c_header_level && --c_header_level == 0)
2235 if (entering_c_header)
2236 warning ("badly nested C headers from preprocessor");
2237 --pending_lang_change;
2239 in_system_header = entering_system_header;
2241 p = input_file_stack;
2242 input_file_stack = p->next;
2244 input_file_stack_tick++;
2245 #ifdef DBX_DEBUGGING_INFO
2246 if (write_symbols == DBX_DEBUG)
2247 dbxout_resume_previous_source_file ();
2249 #ifdef DWARF_DEBUGGING_INFO
2250 if (debug_info_level == DINFO_LEVEL_VERBOSE
2251 && write_symbols == DWARF_DEBUG)
2252 dwarfout_resume_previous_source_file (input_file_stack->line);
2253 #endif /* DWARF_DEBUGGING_INFO */
2256 error ("#-lines for entering and leaving files don't match");
2259 in_system_header = entering_system_header;
2262 /* If NEXTCHAR is not end of line, we don't care what it is. */
2263 if (nextchar == EOF)
2267 error ("invalid #-line");
2269 /* skip the rest of this line. */
2274 while ((c = getch ()) != EOF && c != '\n');
2279 do_pending_lang_change ()
2281 for (; pending_lang_change > 0; --pending_lang_change)
2282 push_lang_context (lang_name_c);
2283 for (; pending_lang_change < 0; ++pending_lang_change)
2284 pop_lang_context ();
2288 #define isalnum(char) (char >= 'a' ? char <= 'z' : char >= '0' ? char <= '9' || (char >= 'A' && char <= 'Z') : 0)
2289 #define isdigit(char) (char >= '0' && char <= '9')
2294 #define ENDFILE -1 /* token that represents end-of-file */
2296 /* Read an escape sequence, returning its equivalent as a character,
2297 or store 1 in *ignore_ptr if it is backslash-newline. */
2300 readescape (ignore_ptr)
2303 register int c = getch ();
2305 register unsigned count;
2312 if (warn_traditional)
2313 warning ("the meaning of `\\x' varies with -traditional");
2315 if (flag_traditional)
2330 if (c >= 'a' && c <= 'f')
2331 code += c - 'a' + 10;
2332 if (c >= 'A' && c <= 'F')
2333 code += c - 'A' + 10;
2334 if (c >= '0' && c <= '9')
2336 if (code != 0 || count != 0)
2345 error ("\\x used with no following hex digits");
2346 else if (count == 0)
2347 /* Digits are all 0's. Ok. */
2349 else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node)
2351 && ((1 << (TYPE_PRECISION (integer_type_node) - (count - 1) * 4))
2353 pedwarn ("hex escape out of range");
2356 case '0': case '1': case '2': case '3': case '4':
2357 case '5': case '6': case '7':
2360 while ((c <= '7') && (c >= '0') && (count++ < 3))
2362 code = (code * 8) + (c - '0');
2368 case '\\': case '\'': case '"':
2377 return TARGET_NEWLINE;
2392 if (warn_traditional)
2393 warning ("the meaning of `\\a' varies with -traditional");
2395 if (flag_traditional)
2405 pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c);
2411 /* `\(', etc, are used at beginning of line to avoid confusing Emacs. */
2415 /* `\%' is used to prevent SCCS from getting confused. */
2418 pedwarn ("unknown escape sequence `\\%c'", c);
2421 if (c >= 040 && c < 0177)
2422 pedwarn ("unknown escape sequence `\\%c'", c);
2424 pedwarn ("unknown escape sequence: `\\' followed by char code 0x%x", c);
2428 /* Value is 1 (or 2) if we should try to make the next identifier look like
2429 a typename (when it may be a local variable or a class variable).
2430 Value is 0 if we treat this name in a default fashion. */
2431 int looking_for_typename = 0;
2434 /* NO LONGER USED: Value is -1 if we must not see a type name. */
2436 dont_see_typename ()
2438 looking_for_typename = -1;
2439 if (yychar == TYPENAME || yychar == PTYPENAME)
2441 yychar = IDENTIFIER;
2448 extern __inline int identifier_type ();
2452 identifier_type (decl)
2455 if (TREE_CODE (decl) == TEMPLATE_DECL)
2457 if (TREE_CODE (DECL_RESULT (decl)) == TYPE_DECL)
2460 if (TREE_CODE (decl) == NAMESPACE_DECL)
2462 if (TREE_CODE (decl) != TYPE_DECL)
2464 if (((got_scope && TREE_TYPE (decl) == got_scope)
2465 || TREE_TYPE (decl) == current_class_type)
2466 && DECL_ARTIFICIAL (decl))
2474 looking_for_typename = 1;
2476 if ((yychar = yylex ()) < 0) yychar = 0;
2477 looking_for_typename = 0;
2478 if (yychar == IDENTIFIER)
2480 lastiddecl = lookup_name (yylval.ttype, -2);
2481 if (lastiddecl == 0)
2484 lastiddecl = IDENTIFIER_LABEL_VALUE (yylval.ttype);
2487 yychar = identifier_type (lastiddecl);
2492 do_identifier (token, parsing)
2493 register tree token;
2498 if (! parsing || IDENTIFIER_OPNAME_P (token))
2499 id = lookup_name (token, 0);
2503 if (parsing && yychar == YYEMPTY)
2505 /* Scope class declarations before global
2507 if (id == IDENTIFIER_GLOBAL_VALUE (token)
2508 && current_class_type != 0
2509 && TYPE_SIZE (current_class_type) == 0)
2511 /* Could be from one of the base classes. */
2512 tree field = lookup_field (current_class_type, token, 1, 0);
2515 else if (field == error_mark_node)
2516 /* We have already generated the error message.
2517 But we still want to return this value. */
2518 id = lookup_field (current_class_type, token, 0, 0);
2519 else if (TREE_CODE (field) == VAR_DECL
2520 || TREE_CODE (field) == CONST_DECL)
2522 else if (TREE_CODE (field) != FIELD_DECL)
2523 my_friendly_abort (61);
2526 cp_error ("invalid use of member `%D' from base class `%T'", field,
2527 DECL_FIELD_CONTEXT (field));
2528 id = error_mark_node;
2533 /* Remember that this name has been used in the class definition, as per
2535 if (id && current_class_type && parsing
2536 && TYPE_BEING_DEFINED (current_class_type)
2537 && ! IDENTIFIER_CLASS_VALUE (token))
2538 pushdecl_class_level (id);
2540 if (!id || id == error_mark_node)
2542 if (id == error_mark_node && current_class_type != NULL_TREE)
2544 id = lookup_nested_field (token, 1);
2545 /* In lookup_nested_field(), we marked this so we can gracefully
2546 leave this whole mess. */
2547 if (id && id != error_mark_node && TREE_TYPE (id) == error_mark_node)
2551 if (current_template_parms)
2552 return build_min_nt (LOOKUP_EXPR, token, NULL_TREE);
2553 else if (IDENTIFIER_OPNAME_P (token))
2555 if (token != ansi_opname[ERROR_MARK])
2556 cp_error ("operator %O not defined", token);
2557 id = error_mark_node;
2559 else if (parsing && (yychar == '(' || yychar == LEFT_RIGHT))
2561 id = implicitly_declare (token);
2563 else if (current_function_decl == 0)
2565 cp_error ("`%D' was not declared in this scope", token);
2566 id = error_mark_node;
2570 if (IDENTIFIER_GLOBAL_VALUE (token) != error_mark_node
2571 || IDENTIFIER_ERROR_LOCUS (token) != current_function_decl)
2573 static int undeclared_variable_notice;
2575 cp_error ("`%D' undeclared (first use this function)", token);
2577 if (! undeclared_variable_notice)
2579 error ("(Each undeclared identifier is reported only once");
2580 error ("for each function it appears in.)");
2581 undeclared_variable_notice = 1;
2584 id = error_mark_node;
2585 /* Prevent repeated error messages. */
2586 IDENTIFIER_GLOBAL_VALUE (token) = error_mark_node;
2587 SET_IDENTIFIER_ERROR_LOCUS (token, current_function_decl);
2591 if (TREE_CODE (id) == VAR_DECL && DECL_DEAD_FOR_LOCAL (id))
2593 tree shadowed = DECL_SHADOWED_FOR_VAR (id);
2594 while (shadowed != NULL_TREE && TREE_CODE (shadowed) == VAR_DECL
2595 && DECL_DEAD_FOR_LOCAL (shadowed))
2596 shadowed = DECL_SHADOWED_FOR_VAR (shadowed);
2598 shadowed = IDENTIFIER_GLOBAL_VALUE (DECL_NAME (id));
2601 if (!DECL_ERROR_REPORTED (id))
2603 warning ("name lookup of `%s' changed",
2604 IDENTIFIER_POINTER (token));
2605 cp_warning_at (" matches this `%D' under current ANSI rules",
2607 cp_warning_at (" matches this `%D' under old rules", id);
2608 DECL_ERROR_REPORTED (id) = 1;
2612 else if (!DECL_ERROR_REPORTED (id))
2615 = "name lookup of `%s' changed for new ANSI `for' scoping";
2616 DECL_ERROR_REPORTED (id) = 1;
2617 if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (id)))
2619 error (msg, IDENTIFIER_POINTER (token));
2620 cp_error_at (" cannot use obsolete binding at `%D' because it has a destructor", id);
2621 id = error_mark_node;
2625 pedwarn (msg, IDENTIFIER_POINTER (token));
2626 cp_pedwarn_at (" using obsolete binding at `%D'", id);
2630 /* TREE_USED is set in `hack_identifier'. */
2631 if (TREE_CODE (id) == CONST_DECL)
2633 if (IDENTIFIER_CLASS_VALUE (token) == id)
2636 tree access = compute_access (TYPE_BINFO (current_class_type), id);
2637 if (access == access_private_node)
2638 cp_error ("enum `%D' is private", id);
2639 /* protected is OK, since it's an enum of `this'. */
2641 if (! current_template_parms
2642 || (DECL_INITIAL (id)
2643 && TREE_CODE (DECL_INITIAL (id)) == TEMPLATE_CONST_PARM))
2644 id = DECL_INITIAL (id);
2647 id = hack_identifier (id, token);
2649 if (current_template_parms)
2651 if (is_overloaded_fn (id))
2653 tree t = build_min (LOOKUP_EXPR, unknown_type_node,
2654 token, get_first_fn (id));
2655 if (id != IDENTIFIER_GLOBAL_VALUE (token))
2656 TREE_OPERAND (t, 1) = error_mark_node;
2659 else if (! TREE_PERMANENT (id) || TREE_CODE (id) == PARM_DECL
2660 || TREE_CODE (id) == USING_DECL)
2661 id = build_min (LOOKUP_EXPR, TREE_TYPE (id), token, error_mark_node);
2662 /* else just use the decl */
2669 do_scoped_id (token, parsing)
2673 tree id = IDENTIFIER_GLOBAL_VALUE (token);
2674 if (parsing && yychar == YYEMPTY)
2678 if (current_template_parms)
2680 id = build_min_nt (LOOKUP_EXPR, token, NULL_TREE);
2681 LOOKUP_EXPR_GLOBAL (id) = 1;
2684 if (parsing && yychar == '(' || yychar == LEFT_RIGHT)
2685 id = implicitly_declare (token);
2688 if (IDENTIFIER_GLOBAL_VALUE (token) != error_mark_node)
2689 error ("undeclared variable `%s' (first use here)",
2690 IDENTIFIER_POINTER (token));
2691 id = error_mark_node;
2692 /* Prevent repeated error messages. */
2693 IDENTIFIER_GLOBAL_VALUE (token) = error_mark_node;
2698 if (TREE_CODE (id) == ADDR_EXPR)
2699 mark_used (TREE_OPERAND (id, 0));
2700 else if (TREE_CODE (id) != TREE_LIST)
2703 if (TREE_CODE (id) == CONST_DECL && ! current_template_parms)
2705 /* XXX CHS - should we set TREE_USED of the constant? */
2706 id = DECL_INITIAL (id);
2707 /* This is to prevent an enum whose value is 0
2708 from being considered a null pointer constant. */
2709 id = build1 (NOP_EXPR, TREE_TYPE (id), id);
2710 TREE_CONSTANT (id) = 1;
2713 if (current_template_parms)
2715 if (is_overloaded_fn (id))
2717 id = build_min (LOOKUP_EXPR, unknown_type_node,
2718 token, get_first_fn (id));
2719 LOOKUP_EXPR_GLOBAL (id) = 1;
2721 /* else just use the decl */
2727 identifier_typedecl_value (node)
2731 type = IDENTIFIER_TYPE_VALUE (node);
2732 if (type == NULL_TREE)
2737 if (t && TREE_CODE (t) == TYPE_DECL && TREE_TYPE (t) == type) \
2740 do (IDENTIFIER_LOCAL_VALUE (node));
2741 do (IDENTIFIER_CLASS_VALUE (node));
2742 do (IDENTIFIER_GLOBAL_VALUE (node));
2744 /* Will this one ever happen? */
2745 if (TYPE_NAME (type))
2746 return TYPE_NAME (type);
2748 /* We used to do an internal error of 62 here, but instead we will
2749 handle the return of a null appropriately in the callers. */
2758 char long_long_flag;
2761 struct try_type type_sequence[] =
2763 { &integer_type_node, 0, 0, 0},
2764 { &unsigned_type_node, 1, 0, 0},
2765 { &long_integer_type_node, 0, 1, 0},
2766 { &long_unsigned_type_node, 1, 1, 0},
2767 { &long_long_integer_type_node, 0, 1, 1},
2768 { &long_long_unsigned_type_node, 1, 1, 1}
2777 int dollar_seen = 0;
2781 c = nextchar, nextchar = -1;
2785 /* Effectively do c = skip_white_space (c)
2786 but do it faster in the usual cases. */
2799 /* Call skip_white_space so we can warn if appropriate. */
2804 c = skip_white_space (c);
2806 goto found_nonwhite;
2810 token_buffer[0] = c;
2811 token_buffer[1] = 0;
2813 /* yylloc.first_line = lineno; */
2818 token_buffer[0] = '\0';
2820 if (input_redirected ())
2821 value = END_OF_SAVED_INPUT;
2823 value = END_OF_LINE;
2829 if (dollars_in_ident)
2838 /* Capital L may start a wide-string or wide-character constant. */
2840 register int c = getch ();
2849 goto string_constant;
2854 case 'A': case 'B': case 'C': case 'D': case 'E':
2855 case 'F': case 'G': case 'H': case 'I': case 'J':
2856 case 'K': case 'M': case 'N': case 'O':
2857 case 'P': case 'Q': case 'R': case 'S': case 'T':
2858 case 'U': case 'V': case 'W': case 'X': case 'Y':
2860 case 'a': case 'b': case 'c': case 'd': case 'e':
2861 case 'f': case 'g': case 'h': case 'i': case 'j':
2862 case 'k': case 'l': case 'm': case 'n': case 'o':
2863 case 'p': case 'q': case 'r': case 's': case 't':
2864 case 'u': case 'v': case 'w': case 'x': case 'y':
2874 /* We know that `token_buffer' can hold at least on char,
2875 so we install C immediately.
2876 We may have to read the value in `putback_char', so call
2881 /* Make this run fast. We know that we are reading straight
2882 from FINPUT in this case (since identifiers cannot straddle
2884 while (isalnum (c) || (c == '_') || c == '$')
2886 if (c == '$' && ! dollars_in_ident)
2888 if (p >= token_buffer + maxtoken)
2889 p = extend_token_buffer (p);
2895 if (linemode && c == '\n')
2903 /* We know that `token_buffer' can hold at least on char,
2904 so we install C immediately. */
2908 while (isalnum (c) || (c == '_') || c == '$')
2910 if (c == '$' && ! dollars_in_ident)
2912 if (p >= token_buffer + maxtoken)
2913 p = extend_token_buffer (p);
2926 /* Try to recognize a keyword. Uses minimum-perfect hash function */
2929 register struct resword *ptr;
2931 if (ptr = is_reserved_word (token_buffer, p - token_buffer))
2935 tree old_ttype = ridpointers[(int) ptr->rid];
2937 /* If this provides a type for us, then revert lexical
2938 state to standard state. */
2939 if (TREE_CODE (old_ttype) == IDENTIFIER_NODE
2940 && IDENTIFIER_GLOBAL_VALUE (old_ttype) != 0
2941 && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (old_ttype)) == TYPE_DECL)
2942 looking_for_typename = 0;
2943 else if (ptr->token == AGGR || ptr->token == ENUM)
2944 looking_for_typename = 1;
2946 /* Check if this is a language-type declaration.
2947 Just glimpse the next non-white character. */
2948 nextchar = skip_white_space (nextchar);
2949 if (nextchar == '"')
2951 /* We are looking at a string. Complain
2952 if the token before the string is no `extern'.
2954 Could cheat some memory by placing this string
2955 on the temporary_, instead of the saveable_
2958 if (ptr->rid != RID_EXTERN)
2959 error ("invalid modifier `%s' for language string",
2962 value = EXTERN_LANG_STRING;
2963 yylval.ttype = get_identifier (TREE_STRING_POINTER (yylval.ttype));
2966 if (ptr->token == VISSPEC)
2971 yylval.ttype = access_public_node;
2974 yylval.ttype = access_private_node;
2977 yylval.ttype = access_protected_node;
2980 my_friendly_abort (63);
2984 yylval.ttype = old_ttype;
2986 else if (ptr->token == EQCOMPARE)
2988 yylval.code = NE_EXPR;
2989 token_buffer[0] = '!';
2990 token_buffer[1] = '=';
2991 token_buffer[2] = 0;
2993 else if (ptr->token == ASSIGN)
2995 if (strcmp ("and_eq", token_buffer) == 0)
2997 yylval.code = BIT_AND_EXPR;
2998 token_buffer[0] = '&';
3000 else if (strcmp ("or_eq", token_buffer) == 0)
3002 yylval.code = BIT_IOR_EXPR;
3003 token_buffer[0] = '|';
3005 else if (strcmp ("xor_eq", token_buffer) == 0)
3007 yylval.code = BIT_XOR_EXPR;
3008 token_buffer[0] = '^';
3010 token_buffer[1] = '=';
3011 token_buffer[2] = 0;
3013 else if (ptr->token == '&')
3015 yylval.code = BIT_AND_EXPR;
3016 token_buffer[0] = '&';
3017 token_buffer[1] = 0;
3019 else if (ptr->token == '|')
3021 yylval.code = BIT_IOR_EXPR;
3022 token_buffer[0] = '|';
3023 token_buffer[1] = 0;
3025 else if (ptr->token == '^')
3027 yylval.code = BIT_XOR_EXPR;
3028 token_buffer[0] = '^';
3029 token_buffer[1] = 0;
3031 else if (ptr->token == NAMESPACE)
3035 warning ("namespaces are mostly broken in this version of g++");
3040 value = (int) ptr->token;
3044 /* If we did not find a keyword, look for an identifier
3047 if (strcmp ("catch", token_buffer) == 0
3048 || strcmp ("throw", token_buffer) == 0
3049 || strcmp ("try", token_buffer) == 0)
3051 static int did_warn = 0;
3052 if (! did_warn && ! flag_handle_exceptions)
3054 pedwarn ("`catch', `throw', and `try' are all C++ reserved words");
3059 if (value == IDENTIFIER || value == TYPESPEC)
3060 GNU_xref_ref (current_function_decl, token_buffer);
3062 if (value == IDENTIFIER)
3064 register tree tmp = get_identifier (token_buffer);
3066 #if !defined(VMS) && defined(JOINER)
3067 /* Make sure that user does not collide with our internal
3071 && (THIS_NAME_P (tmp)
3072 || VPTR_NAME_P (tmp)
3073 || DESTRUCTOR_NAME_P (tmp)
3074 || VTABLE_NAME_P (tmp)
3075 || TEMP_NAME_P (tmp)
3076 || ANON_AGGRNAME_P (tmp)
3077 || ANON_PARMNAME_P (tmp)))
3078 warning ("identifier name `%s' conflicts with GNU C++ internal naming strategy",
3084 /* A user-invisible read-only initialized variable
3085 should be replaced by its value. We only handle strings
3086 since that's the only case used in C (and C++). */
3087 /* Note we go right after the local value for the identifier
3088 (e.g., __FUNCTION__ or __PRETTY_FUNCTION__). We used to
3089 call lookup_name, but that could result in an error about
3091 tmp = IDENTIFIER_LOCAL_VALUE (yylval.ttype);
3092 if (tmp != NULL_TREE
3093 && TREE_CODE (tmp) == VAR_DECL
3094 && DECL_IGNORED_P (tmp)
3095 && TREE_READONLY (tmp)
3096 && DECL_INITIAL (tmp) != NULL_TREE
3097 && TREE_CODE (DECL_INITIAL (tmp)) == STRING_CST)
3099 yylval.ttype = DECL_INITIAL (tmp);
3103 if (value == NEW && ! global_bindings_p ())
3113 register int c1 = getch ();
3114 token_buffer[0] = c;
3115 token_buffer[1] = c1;
3119 token_buffer[2] = 0;
3127 token_buffer[2] = c1;
3128 token_buffer[3] = 0;
3132 error ("parse error at `..'");
3137 goto resume_numerical_scan;
3141 token_buffer[1] = 0;
3145 /* Optimize for most frequent case. */
3147 register int c1 = getch ();
3148 if (! isalnum (c1) && c1 != '.')
3150 /* Terminate string. */
3151 token_buffer[0] = c;
3152 token_buffer[1] = 0;
3154 yylval.ttype = integer_zero_node;
3156 yylval.ttype = integer_one_node;
3163 /* fall through... */
3164 case '2': case '3': case '4':
3165 case '5': case '6': case '7': case '8': case '9':
3166 resume_numerical_scan:
3171 int largest_digit = 0;
3173 /* for multi-precision arithmetic,
3174 we actually store only HOST_BITS_PER_CHAR bits in each part.
3175 The number of parts is chosen so as to be sufficient to hold
3176 the enough bits to fit into the two HOST_WIDE_INTs that contain
3177 the integer value (this is always at least as many bits as are
3178 in a target `long long' value, but may be wider). */
3179 #define TOTAL_PARTS ((HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2 + 2)
3180 int parts[TOTAL_PARTS];
3183 enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS} floatflag
3189 for (count = 0; count < TOTAL_PARTS; count++)
3194 *p++ = (c = getch ());
3195 if ((c == 'x') || (c == 'X'))
3198 *p++ = (c = getch ());
3200 /* Leading 0 forces octal unless the 0 is the only digit. */
3201 else if (c >= '0' && c <= '9')
3210 /* Read all the digits-and-decimal-points. */
3213 || (isalnum (c) && (c != 'l') && (c != 'L')
3214 && (c != 'u') && (c != 'U')
3215 && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
3220 error ("floating constant may not be in radix 16");
3221 if (floatflag == AFTER_POINT)
3223 error ("malformed floating constant");
3224 floatflag = TOO_MANY_POINTS;
3227 floatflag = AFTER_POINT;
3230 *p++ = c = getch ();
3231 /* Accept '.' as the start of a floating-point number
3232 only when it is followed by a digit.
3233 Otherwise, unread the following non-digit
3234 and use the '.' as a structural token. */
3235 if (p == token_buffer + 2 && !isdigit (c))
3247 error ("parse error at `..'");
3250 token_buffer[1] = '\0';
3257 /* It is not a decimal point.
3258 It should be a digit (perhaps a hex digit). */
3264 else if (base <= 10)
3266 if (c == 'e' || c == 'E')
3269 floatflag = AFTER_POINT;
3270 break; /* start of exponent */
3272 error ("nondigits in number and not hexadecimal");
3283 if (c >= largest_digit)
3287 for (count = 0; count < TOTAL_PARTS; count++)
3289 parts[count] *= base;
3293 += (parts[count-1] >> HOST_BITS_PER_CHAR);
3295 &= (1 << HOST_BITS_PER_CHAR) - 1;
3301 /* If the extra highest-order part ever gets anything in it,
3302 the number is certainly too big. */
3303 if (parts[TOTAL_PARTS - 1] != 0)
3306 if (p >= token_buffer + maxtoken - 3)
3307 p = extend_token_buffer (p);
3308 *p++ = (c = getch ());
3313 error ("numeric constant with no digits");
3315 if (largest_digit >= base)
3316 error ("numeric constant contains digits beyond the radix");
3318 /* Remove terminating char from the token buffer and delimit the string */
3321 if (floatflag != NOT_FLOAT)
3323 tree type = double_type_node;
3326 int garbage_chars = 0;
3327 REAL_VALUE_TYPE value;
3330 /* Read explicit exponent if any, and put it in tokenbuf. */
3332 if ((c == 'e') || (c == 'E'))
3334 if (p >= token_buffer + maxtoken - 3)
3335 p = extend_token_buffer (p);
3338 if ((c == '+') || (c == '-'))
3344 error ("floating constant exponent has no digits");
3347 if (p >= token_buffer + maxtoken - 3)
3348 p = extend_token_buffer (p);
3357 /* Convert string to a double, checking for overflow. */
3358 if (setjmp (handler))
3360 error ("floating constant out of range");
3365 set_float_handler (handler);
3366 /* The second argument, machine_mode, of REAL_VALUE_ATOF
3367 tells the desired precision of the binary result of
3368 decimal-to-binary conversion. */
3370 /* Read the suffixes to choose a data type. */
3374 type = float_type_node;
3375 value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
3380 type = long_double_type_node;
3381 value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
3386 value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
3388 set_float_handler (NULL_PTR);
3391 && (REAL_VALUE_ISINF (value)
3393 || (TARGET_FLOAT_FORMAT != IEEE_FLOAT_FORMAT
3395 /* ERANGE is also reported for underflow, so test the
3396 value to distinguish overflow from that. */
3397 && (REAL_VALUES_LESS (dconst1, value)
3398 || REAL_VALUES_LESS (value, dconstm1)))
3402 pedwarn ("floating point number exceeds range of `%s'",
3403 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
3405 /* Note: garbage_chars is -1 if first char is *not* garbage. */
3408 if (c == 'f' || c == 'F')
3411 error ("two `f's in floating constant");
3414 if (c == 'l' || c == 'L')
3417 error ("two `l's in floating constant");
3420 if (p >= token_buffer + maxtoken - 3)
3421 p = extend_token_buffer (p);
3427 if (garbage_chars > 0)
3428 error ("garbage at end of number");
3430 /* Create a node with determined type and value. */
3431 yylval.ttype = build_real (type, value);
3439 HOST_WIDE_INT high, low;
3440 int spec_unsigned = 0;
3442 int spec_long_long = 0;
3447 if (c == 'u' || c == 'U')
3450 error ("two `u's in integer constant");
3453 else if (c == 'l' || c == 'L')
3458 error ("three `l's in integer constant");
3460 pedwarn ("ANSI C++ forbids long long integer constants");
3469 error ("garbage at end of number");
3472 if (p >= token_buffer + maxtoken - 3)
3473 p = extend_token_buffer (p);
3480 if (p >= token_buffer + maxtoken - 3)
3481 p = extend_token_buffer (p);
3488 /* If the constant is not long long and it won't fit in an
3489 unsigned long, or if the constant is long long and won't fit
3490 in an unsigned long long, then warn that the constant is out
3493 /* ??? This assumes that long long and long integer types are
3494 a multiple of 8 bits. This better than the original code
3495 though which assumed that long was exactly 32 bits and long
3496 long was exactly 64 bits. */
3499 bytes = TYPE_PRECISION (long_long_integer_type_node) / 8;
3501 bytes = TYPE_PRECISION (long_integer_type_node) / 8;
3504 for (i = bytes; i < TOTAL_PARTS; i++)
3508 pedwarn ("integer constant out of range");
3510 /* This is simplified by the fact that our constant
3511 is always positive. */
3514 for (i = 0; i < HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR; i++)
3516 high |= ((HOST_WIDE_INT) parts[i + (HOST_BITS_PER_WIDE_INT
3517 / HOST_BITS_PER_CHAR)]
3518 << (i * HOST_BITS_PER_CHAR));
3519 low |= (HOST_WIDE_INT) parts[i] << (i * HOST_BITS_PER_CHAR);
3523 yylval.ttype = build_int_2 (low, high);
3524 TREE_TYPE (yylval.ttype) = long_long_unsigned_type_node;
3527 /* Find the first allowable type that the value fits in. */
3529 for (i = 0; i < sizeof (type_sequence) / sizeof (type_sequence[0]);
3531 if (!(spec_long && !type_sequence[i].long_flag)
3532 && !(spec_long_long && !type_sequence[i].long_long_flag)
3533 && !(spec_unsigned && !type_sequence[i].unsigned_flag)
3534 /* A hex or octal constant traditionally is unsigned. */
3535 && !(base != 10 && flag_traditional
3536 && !type_sequence[i].unsigned_flag)
3537 /* A decimal constant can't be unsigned int
3538 unless explicitly specified. */
3539 && !(base == 10 && !spec_unsigned
3540 && *type_sequence[i].node_var == unsigned_type_node))
3541 if (int_fits_type_p (yylval.ttype, *type_sequence[i].node_var))
3543 type = *type_sequence[i].node_var;
3546 if (flag_traditional && type == long_unsigned_type_node
3548 type = long_integer_type_node;
3552 type = long_long_integer_type_node;
3553 warning ("integer constant out of range");
3556 /* Warn about some cases where the type of a given constant
3557 changes from traditional C to ANSI C. */
3558 if (warn_traditional)
3560 tree other_type = 0;
3562 /* This computation is the same as the previous one
3563 except that flag_traditional is used backwards. */
3564 for (i = 0; i < sizeof (type_sequence) / sizeof (type_sequence[0]);
3566 if (!(spec_long && !type_sequence[i].long_flag)
3567 && !(spec_long_long && !type_sequence[i].long_long_flag)
3568 && !(spec_unsigned && !type_sequence[i].unsigned_flag)
3569 /* A hex or octal constant traditionally is unsigned. */
3570 && !(base != 10 && !flag_traditional
3571 && !type_sequence[i].unsigned_flag)
3572 /* A decimal constant can't be unsigned int
3573 unless explicitly specified. */
3574 && !(base == 10 && !spec_unsigned
3575 && *type_sequence[i].node_var == unsigned_type_node))
3576 if (int_fits_type_p (yylval.ttype, *type_sequence[i].node_var))
3578 other_type = *type_sequence[i].node_var;
3581 if (!flag_traditional && type == long_unsigned_type_node
3583 type = long_integer_type_node;
3585 if (other_type != 0 && other_type != type)
3587 if (flag_traditional)
3588 warning ("type of integer constant would be different without -traditional");
3590 warning ("type of integer constant would be different with -traditional");
3595 if (!spec_long && !spec_unsigned
3596 && !(flag_traditional && base != 10)
3597 && int_fits_type_p (yylval.ttype, integer_type_node))
3600 if (warn_traditional && base != 10)
3601 warning ("small nondecimal constant becomes signed in ANSI C++");
3603 type = integer_type_node;
3605 else if (!spec_long && (base != 10 || spec_unsigned)
3606 && int_fits_type_p (yylval.ttype, unsigned_type_node))
3608 /* Nondecimal constants try unsigned even in traditional C. */
3609 type = unsigned_type_node;
3612 else if (!spec_unsigned && !spec_long_long
3613 && int_fits_type_p (yylval.ttype, long_integer_type_node))
3614 type = long_integer_type_node;
3616 else if (! spec_long_long
3617 && int_fits_type_p (yylval.ttype,
3618 long_unsigned_type_node))
3621 if (warn_traditional && !spec_unsigned)
3622 warning ("large integer constant becomes unsigned in ANSI C++");
3624 if (flag_traditional && !spec_unsigned)
3625 type = long_integer_type_node;
3627 type = long_unsigned_type_node;
3630 else if (! spec_unsigned
3631 /* Verify value does not overflow into sign bit. */
3632 && TREE_INT_CST_HIGH (yylval.ttype) >= 0
3633 && int_fits_type_p (yylval.ttype,
3634 long_long_integer_type_node))
3635 type = long_long_integer_type_node;
3637 else if (int_fits_type_p (yylval.ttype,
3638 long_long_unsigned_type_node))
3641 if (warn_traditional && !spec_unsigned)
3642 warning ("large nondecimal constant is unsigned in ANSI C++");
3645 if (flag_traditional && !spec_unsigned)
3646 type = long_long_integer_type_node;
3648 type = long_long_unsigned_type_node;
3653 type = long_long_integer_type_node;
3654 warning ("integer constant out of range");
3656 if (base == 10 && ! spec_unsigned && TREE_UNSIGNED (type))
3657 warning ("decimal integer constant is so large that it is unsigned");
3661 TREE_TYPE (yylval.ttype) = type;
3665 value = CONSTANT; break;
3671 register int result = 0;
3672 register int num_chars = 0;
3673 unsigned width = TYPE_PRECISION (char_type_node);
3678 width = WCHAR_TYPE_SIZE;
3679 #ifdef MULTIBYTE_CHARS
3680 max_chars = MB_CUR_MAX;
3686 max_chars = TYPE_PRECISION (integer_type_node) / width;
3694 if (c == '\'' || c == EOF)
3700 c = readescape (&ignore);
3703 if (width < HOST_BITS_PER_INT
3704 && (unsigned) c >= (1 << width))
3705 warning ("escape sequence out of range for character");
3706 #ifdef MAP_CHARACTER
3708 c = MAP_CHARACTER (c);
3714 pedwarn ("ANSI C++ forbids newline in character constant");
3717 #ifdef MAP_CHARACTER
3719 c = MAP_CHARACTER (c);
3723 if (num_chars > maxtoken - 4)
3724 extend_token_buffer (token_buffer);
3726 token_buffer[num_chars] = c;
3728 /* Merge character into result; ignore excess chars. */
3729 if (num_chars < max_chars + 1)
3731 if (width < HOST_BITS_PER_INT)
3732 result = (result << width) | (c & ((1 << width) - 1));
3738 token_buffer[num_chars + 1] = '\'';
3739 token_buffer[num_chars + 2] = 0;
3742 error ("malformatted character constant");
3743 else if (num_chars == 0)
3744 error ("empty character constant");
3745 else if (num_chars > max_chars)
3747 num_chars = max_chars;
3748 error ("character constant too long");
3750 else if (num_chars != 1 && ! flag_traditional)
3751 warning ("multi-character character constant");
3753 /* If char type is signed, sign-extend the constant. */
3756 int num_bits = num_chars * width;
3758 /* We already got an error; avoid invalid shift. */
3759 yylval.ttype = build_int_2 (0, 0);
3760 else if (TREE_UNSIGNED (char_type_node)
3761 || ((result >> (num_bits - 1)) & 1) == 0)
3763 = build_int_2 (result & ((unsigned HOST_WIDE_INT) ~0
3764 >> (HOST_BITS_PER_WIDE_INT - num_bits)),
3768 = build_int_2 (result | ~((unsigned HOST_WIDE_INT) ~0
3769 >> (HOST_BITS_PER_WIDE_INT - num_bits)),
3772 TREE_TYPE (yylval.ttype) = char_type_node;
3774 TREE_TYPE (yylval.ttype) = integer_type_node;
3778 #ifdef MULTIBYTE_CHARS
3779 /* Set the initial shift state and convert the next sequence. */
3781 /* In all locales L'\0' is zero and mbtowc will return zero,
3784 || (num_chars == 1 && token_buffer[1] != '\0'))
3787 (void) mbtowc (NULL, NULL, 0);
3788 if (mbtowc (& wc, token_buffer + 1, num_chars) == num_chars)
3791 warning ("Ignoring invalid multibyte character");
3794 yylval.ttype = build_int_2 (result, 0);
3795 TREE_TYPE (yylval.ttype) = wchar_type_node;
3808 p = token_buffer + 1;
3810 while (c != '"' && c >= 0)
3812 /* ignore_escape_flag is set for reading the filename in #line. */
3813 if (!ignore_escape_flag && c == '\\')
3816 c = readescape (&ignore);
3820 && TYPE_PRECISION (char_type_node) < HOST_BITS_PER_INT
3821 && c >= ((unsigned) 1 << TYPE_PRECISION (char_type_node)))
3822 warning ("escape sequence out of range for character");
3827 pedwarn ("ANSI C++ forbids newline in string constant");
3831 if (p == token_buffer + maxtoken)
3832 p = extend_token_buffer (p);
3838 error ("Unterminated string");
3844 /* We have read the entire constant.
3845 Construct a STRING_CST for the result. */
3849 /* If this is a L"..." wide-string, convert the multibyte string
3850 to a wide character string. */
3851 char *widep = (char *) alloca ((p - token_buffer) * WCHAR_BYTES);
3854 #ifdef MULTIBYTE_CHARS
3855 len = mbstowcs ((wchar_t *) widep, token_buffer + 1, p - token_buffer);
3856 if (len < 0 || len >= (p - token_buffer))
3858 warning ("Ignoring invalid multibyte string");
3861 bzero (widep + (len * WCHAR_BYTES), WCHAR_BYTES);
3864 union { long l; char c[sizeof (long)]; } u;
3868 /* Determine whether host is little or big endian. */
3870 big_endian = u.c[sizeof (long) - 1];
3871 wp = widep + (big_endian ? WCHAR_BYTES - 1 : 0);
3873 bzero (widep, (p - token_buffer) * WCHAR_BYTES);
3874 for (cp = token_buffer + 1; cp < p; cp++)
3875 *wp = *cp, wp += WCHAR_BYTES;
3876 len = p - token_buffer - 1;
3879 if (current_template_parms)
3880 push_obstacks (&permanent_obstack, &permanent_obstack);
3881 yylval.ttype = build_string ((len + 1) * WCHAR_BYTES, widep);
3882 if (current_template_parms)
3884 TREE_TYPE (yylval.ttype) = wchar_array_type_node;
3888 if (current_template_parms)
3889 push_obstacks (&permanent_obstack, &permanent_obstack);
3890 yylval.ttype = build_string (p - token_buffer, token_buffer + 1);
3891 if (current_template_parms)
3893 TREE_TYPE (yylval.ttype) = char_array_type_node;
3899 value = STRING; break;
3922 yylval.code = PLUS_EXPR; break;
3924 yylval.code = MINUS_EXPR; break;
3926 yylval.code = BIT_AND_EXPR; break;
3928 yylval.code = BIT_IOR_EXPR; break;
3930 yylval.code = MULT_EXPR; break;
3932 yylval.code = TRUNC_DIV_EXPR; break;
3934 yylval.code = TRUNC_MOD_EXPR; break;
3936 yylval.code = BIT_XOR_EXPR; break;
3938 yylval.code = LSHIFT_EXPR; break;
3940 yylval.code = RSHIFT_EXPR; break;
3942 yylval.code = LT_EXPR; break;
3944 yylval.code = GT_EXPR; break;
3947 token_buffer[1] = c1 = getch ();
3948 token_buffer[2] = 0;
3955 value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done;
3957 value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done;
3959 value = EQCOMPARE; yylval.code = NE_EXPR; goto done;
3961 value = EQCOMPARE; yylval.code = EQ_EXPR; goto done;
3963 value = ASSIGN; goto done;
3969 value = PLUSPLUS; goto done;
3971 value = MINUSMINUS; goto done;
3973 value = ANDAND; goto done;
3975 value = OROR; goto done;
3983 else if ((c == '-') && (c1 == '>'))
3985 nextchar = getch ();
3986 if (nextchar == '*')
3989 value = POINTSAT_STAR;
3995 else if (c1 == '?' && (c == '<' || c == '>'))
3997 token_buffer[3] = 0;
4000 yylval.code = (c == '<' ? MIN_EXPR : MAX_EXPR);
4003 /* <?= or >?= expression. */
4004 token_buffer[2] = c1;
4013 pedwarn ("use of `operator %s' is not standard C++",
4018 else if (c == '<' && c1 == '%')
4019 { value = '{'; goto done; }
4020 else if (c == '<' && c1 == ':')
4021 { value = '['; goto done; }
4022 else if (c == '%' && c1 == '>')
4023 { value = '}'; goto done; }
4024 else if (c == '%' && c1 == ':')
4025 { value = '#'; goto done; }
4028 token_buffer[1] = 0;
4038 token_buffer[1] = ':';
4039 token_buffer[2] = '\0';
4056 /* Don't make yyparse think this is eof. */
4061 /* try, weakly, to handle casts to pointers to functions. */
4062 nextchar = skip_white_space (getch ());
4063 if (nextchar == '*')
4065 int next_c = skip_white_space (getch ());
4069 yylval.ttype = build1 (INDIRECT_REF, 0, 0);
4070 value = PAREN_STAR_PAREN;
4078 else if (nextchar == ')')
4081 yylval.ttype = NULL_TREE;
4092 /* yylloc.last_line = lineno; */
4093 #ifdef GATHER_STATISTICS
4094 #ifdef REDUCE_LENGTH
4095 token_count[value] += 1;
4106 return !!is_reserved_word (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t));
4109 #ifdef GATHER_STATISTICS
4110 extern int tree_node_counts[];
4111 extern int tree_node_sizes[];
4114 /* Place to save freed lang_decls which were allocated on the
4115 permanent_obstack. @@ Not currently used. */
4116 tree free_lang_decl_chain;
4119 build_lang_decl (code, name, type)
4120 enum tree_code code;
4124 register tree t = build_decl (code, name, type);
4125 struct obstack *obstack = current_obstack;
4126 register int i = sizeof (struct lang_decl) / sizeof (int);
4129 if (! TREE_PERMANENT (t))
4130 obstack = saveable_obstack;
4132 /* Could be that saveable is permanent and current is not. */
4133 obstack = &permanent_obstack;
4135 if (free_lang_decl_chain && obstack == &permanent_obstack)
4137 pi = (int *)free_lang_decl_chain;
4138 free_lang_decl_chain = TREE_CHAIN (free_lang_decl_chain);
4141 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
4146 DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
4147 LANG_DECL_PERMANENT ((struct lang_decl *) pi)
4148 = obstack == &permanent_obstack;
4149 my_friendly_assert (LANG_DECL_PERMANENT ((struct lang_decl *) pi)
4150 == TREE_PERMANENT (t), 234);
4151 DECL_MAIN_VARIANT (t) = t;
4152 if (current_lang_name == lang_name_cplusplus)
4154 DECL_LANGUAGE (t) = lang_cplusplus;
4156 #ifndef NO_AUTO_OVERLOAD
4157 if (code == FUNCTION_DECL && name != 0
4158 && ! (IDENTIFIER_LENGTH (name) == 4
4159 && IDENTIFIER_POINTER (name)[0] == 'm'
4160 && strcmp (IDENTIFIER_POINTER (name), "main") == 0)
4161 && ! (IDENTIFIER_LENGTH (name) > 10
4162 && IDENTIFIER_POINTER (name)[0] == '_'
4163 && IDENTIFIER_POINTER (name)[1] == '_'
4164 && strncmp (IDENTIFIER_POINTER (name)+2, "builtin_", 8) == 0))
4165 TREE_OVERLOADED (name) = 1;
4169 else if (current_lang_name == lang_name_c)
4170 DECL_LANGUAGE (t) = lang_c;
4171 else my_friendly_abort (64);
4173 #if 0 /* not yet, should get fixed properly later */
4174 if (code == TYPE_DECL)
4177 id = get_identifier (build_overload_name (type, 1, 1));
4178 DECL_ASSEMBLER_NAME (t) = id;
4182 #ifdef GATHER_STATISTICS
4183 tree_node_counts[(int)lang_decl] += 1;
4184 tree_node_sizes[(int)lang_decl] += sizeof (struct lang_decl);
4191 build_lang_field_decl (code, name, type)
4192 enum tree_code code;
4196 extern struct obstack *current_obstack, *saveable_obstack;
4197 register tree t = build_decl (code, name, type);
4198 struct obstack *obstack = current_obstack;
4199 register int i = sizeof (struct lang_decl_flags) / sizeof (int);
4201 #if 0 /* not yet, should get fixed properly later */
4203 if (code == TYPE_DECL)
4206 id = get_identifier (build_overload_name (type, 1, 1));
4207 DECL_ASSEMBLER_NAME (t) = id;
4211 if (! TREE_PERMANENT (t))
4212 obstack = saveable_obstack;
4214 my_friendly_assert (obstack == &permanent_obstack, 235);
4216 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl_flags));
4220 DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
4225 copy_lang_decl (node)
4231 if (! DECL_LANG_SPECIFIC (node))
4234 if (TREE_CODE (node) == FIELD_DECL)
4235 size = sizeof (struct lang_decl_flags);
4237 size = sizeof (struct lang_decl);
4238 pi = (int *)obstack_alloc (&permanent_obstack, size);
4239 bcopy ((char *)DECL_LANG_SPECIFIC (node), (char *)pi, size);
4240 DECL_LANG_SPECIFIC (node) = (struct lang_decl *)pi;
4244 make_lang_type (code)
4245 enum tree_code code;
4247 extern struct obstack *current_obstack, *saveable_obstack;
4248 register tree t = make_node (code);
4249 struct obstack *obstack = current_obstack;
4250 register int i = sizeof (struct lang_type) / sizeof (int);
4253 /* Set up some flags that give proper default behavior. */
4254 IS_AGGR_TYPE (t) = 1;
4256 if (! TREE_PERMANENT (t))
4257 obstack = saveable_obstack;
4259 my_friendly_assert (obstack == &permanent_obstack, 236);
4261 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_type));
4265 TYPE_LANG_SPECIFIC (t) = (struct lang_type *) pi;
4266 CLASSTYPE_AS_LIST (t) = build_tree_list (NULL_TREE, t);
4267 SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, interface_unknown);
4268 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
4269 CLASSTYPE_VBASE_SIZE (t) = integer_zero_node;
4270 TYPE_BINFO (t) = make_binfo (integer_zero_node, t, NULL_TREE, NULL_TREE,
4272 CLASSTYPE_BINFO_AS_LIST (t) = build_tree_list (NULL_TREE, TYPE_BINFO (t));
4274 /* Make sure this is laid out, for ease of use later.
4275 In the presence of parse errors, the normal was of assuring
4276 this might not ever get executed, so we lay it out *immediately*. */
4277 build_pointer_type (t);
4279 #ifdef GATHER_STATISTICS
4280 tree_node_counts[(int)lang_type] += 1;
4281 tree_node_sizes[(int)lang_type] += sizeof (struct lang_type);
4288 copy_decl_lang_specific (decl)
4291 extern struct obstack *current_obstack, *saveable_obstack;
4292 register int *old = (int *)DECL_LANG_SPECIFIC (decl);
4293 struct obstack *obstack = current_obstack;
4294 register int i = sizeof (struct lang_decl) / sizeof (int);
4297 if (! TREE_PERMANENT (decl))
4298 obstack = saveable_obstack;
4300 my_friendly_assert (obstack == &permanent_obstack, 237);
4302 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
4306 DECL_LANG_SPECIFIC (decl) = (struct lang_decl *) pi;
4308 #ifdef GATHER_STATISTICS
4309 tree_node_counts[(int)lang_decl] += 1;
4310 tree_node_sizes[(int)lang_decl] += sizeof (struct lang_decl);
4315 dump_time_statistics ()
4317 register tree prev = 0, decl, next;
4318 int this_time = my_get_run_time ();
4319 TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time))
4320 += this_time - body_time;
4322 fprintf (stderr, "\n******\n");
4323 print_time ("header files (total)", header_time);
4324 print_time ("main file (total)", this_time - body_time);
4325 fprintf (stderr, "ratio = %g : 1\n",
4326 (double)header_time / (double)(this_time - body_time));
4327 fprintf (stderr, "\n******\n");
4329 for (decl = filename_times; decl; decl = next)
4331 next = IDENTIFIER_GLOBAL_VALUE (decl);
4332 IDENTIFIER_GLOBAL_VALUE (decl) = prev;
4336 for (decl = prev; decl; decl = IDENTIFIER_GLOBAL_VALUE (decl))
4337 print_time (IDENTIFIER_POINTER (decl),
4338 TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (decl)));
4342 compiler_error (s, v, v2)
4344 HOST_WIDE_INT v, v2; /* @@also used as pointer */
4347 sprintf (buf, s, v, v2);
4348 error_with_file_and_line (input_filename, lineno, "%s (compiler error)", buf);
4355 extern int end_of_file;
4358 strcpy (buf, string);
4360 /* We can't print string and character constants well
4361 because the token_buffer contains the result of processing escapes. */
4363 strcat (buf, input_redirected ()
4364 ? " at end of saved text"
4365 : " at end of input");
4366 else if (token_buffer[0] == 0)
4367 strcat (buf, " at null character");
4368 else if (token_buffer[0] == '"')
4369 strcat (buf, " before string constant");
4370 else if (token_buffer[0] == '\'')
4371 strcat (buf, " before character constant");
4372 else if (token_buffer[0] < 040 || (unsigned char) token_buffer[0] >= 0177)
4373 sprintf (buf + strlen (buf), " before character 0%o",
4374 (unsigned char) token_buffer[0]);
4376 strcat (buf, " before `%s'");
4378 error (buf, token_buffer);
4382 handle_cp_pragma (pname)
4387 if (! strcmp (pname, "vtable"))
4389 extern tree pending_vtables;
4391 /* More follows: it must be a string constant (class name). */
4392 token = real_yylex ();
4393 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
4395 error ("invalid #pragma vtable");
4399 if (write_virtuals != 2)
4401 warning ("use `+e2' option to enable #pragma vtable");
4405 = perm_tree_cons (NULL_TREE,
4406 get_identifier (TREE_STRING_POINTER (yylval.ttype)),
4408 token = real_yylex ();
4409 if (token != END_OF_LINE)
4410 warning ("trailing characters ignored");
4413 else if (! strcmp (pname, "unit"))
4415 /* More follows: it must be a string constant (unit name). */
4416 token = real_yylex ();
4417 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
4419 error ("invalid #pragma unit");
4422 token = real_yylex ();
4423 if (token != END_OF_LINE)
4424 warning ("trailing characters ignored");
4427 else if (! strcmp (pname, "interface"))
4429 tree fileinfo = IDENTIFIER_CLASS_VALUE (get_time_identifier (input_filename));
4430 int warned_already = 0;
4431 char *main_filename = input_filename;
4433 main_filename = FILE_NAME_NONDIRECTORY (main_filename);
4435 token = real_yylex ();
4437 if (token != END_OF_LINE)
4440 || TREE_CODE (yylval.ttype) != STRING_CST)
4442 error ("invalid `#pragma interface'");
4445 main_filename = TREE_STRING_POINTER (yylval.ttype);
4448 while (token != END_OF_LINE)
4450 if (!warned_already && extra_warnings)
4452 warning ("garbage after `#pragma interface' ignored");
4455 token = real_yylex ();
4460 if (impl_file_chain == 0)
4462 /* If this is zero at this point, then we are
4463 auto-implementing. */
4464 if (main_input_filename == 0)
4465 main_input_filename = input_filename;
4467 #ifdef AUTO_IMPLEMENT
4468 filename = FILE_NAME_NONDIRECTORY (main_input_filename);
4469 fi = get_time_identifier (filename);
4470 fi = IDENTIFIER_CLASS_VALUE (fi);
4471 TREE_INT_CST_LOW (fi) = 0;
4472 TREE_INT_CST_HIGH (fi) = 1;
4474 impl_file_chain = (struct impl_files *)permalloc (sizeof (struct impl_files));
4475 impl_file_chain->filename = filename;
4476 impl_file_chain->next = 0;
4480 interface_only = interface_strcmp (main_filename);
4481 interface_unknown = 0;
4482 TREE_INT_CST_LOW (fileinfo) = interface_only;
4483 TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
4487 else if (! strcmp (pname, "implementation"))
4489 tree fileinfo = IDENTIFIER_CLASS_VALUE (get_time_identifier (input_filename));
4490 int warned_already = 0;
4491 char *main_filename = main_input_filename ? main_input_filename : input_filename;
4493 main_filename = FILE_NAME_NONDIRECTORY (main_filename);
4494 token = real_yylex ();
4495 if (token != END_OF_LINE)
4498 || TREE_CODE (yylval.ttype) != STRING_CST)
4500 error ("invalid `#pragma implementation'");
4503 main_filename = TREE_STRING_POINTER (yylval.ttype);
4506 while (token != END_OF_LINE)
4508 if (!warned_already && extra_warnings)
4510 warning ("garbage after `#pragma implementation' ignored");
4513 token = real_yylex ();
4516 if (write_virtuals == 3)
4518 struct impl_files *ifiles = impl_file_chain;
4521 if (! strcmp (ifiles->filename, main_filename))
4523 ifiles = ifiles->next;
4527 ifiles = (struct impl_files*) permalloc (sizeof (struct impl_files));
4528 ifiles->filename = main_filename;
4529 ifiles->next = impl_file_chain;
4530 impl_file_chain = ifiles;
4533 else if ((main_input_filename != 0
4534 && ! strcmp (main_input_filename, input_filename))
4535 || ! strcmp (input_filename, main_filename))
4538 if (impl_file_chain == 0)
4540 impl_file_chain = (struct impl_files*) permalloc (sizeof (struct impl_files));
4541 impl_file_chain->filename = main_filename;
4542 impl_file_chain->next = 0;
4546 error ("`#pragma implementation' can only appear at top-level");
4549 /* We make this non-zero so that we infer decl linkage
4550 in the impl file only for variables first declared
4551 in the interface file. */
4552 interface_unknown = 1;
4554 /* We make this zero so that templates in the impl
4555 file will be emitted properly. */
4556 interface_unknown = 0;
4558 TREE_INT_CST_LOW (fileinfo) = interface_only;
4559 TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
4566 #ifdef HANDLE_SYSV_PRAGMA
4568 /* Handle a #pragma directive. INPUT is the current input stream,
4569 and C is a character to reread. Processes the entire input line
4570 and returns a character for the caller to reread: either \n or EOF. */
4572 /* This function has to be in this file, in order to get at
4575 handle_sysv_pragma (finput, token)
4587 handle_pragma_token ("ignored", yylval.ttype);
4590 handle_pragma_token ("(", NULL_TREE);
4593 handle_pragma_token (")", NULL_TREE);
4596 handle_pragma_token (",", NULL_TREE);
4599 handle_pragma_token ("=", NULL_TREE);
4602 handle_pragma_token ("(", NULL_TREE);
4603 handle_pragma_token (")", NULL_TREE);
4607 handle_pragma_token (NULL_PTR, NULL_TREE);
4610 token = real_yylex ();
4613 #endif /* HANDLE_SYSV_PRAGMA */