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 tree stringval = DECL_INITIAL (tmp);
3101 /* Copy the string value so that we won't clobber anything
3102 if we put something in the TREE_CHAIN of this one. */
3103 yylval.ttype = build_string (TREE_STRING_LENGTH (stringval),
3104 TREE_STRING_POINTER (stringval));
3108 if (value == NEW && ! global_bindings_p ())
3118 register int c1 = getch ();
3119 token_buffer[0] = c;
3120 token_buffer[1] = c1;
3124 token_buffer[2] = 0;
3132 token_buffer[2] = c1;
3133 token_buffer[3] = 0;
3137 error ("parse error at `..'");
3142 goto resume_numerical_scan;
3146 token_buffer[1] = 0;
3150 /* Optimize for most frequent case. */
3152 register int c1 = getch ();
3153 if (! isalnum (c1) && c1 != '.')
3155 /* Terminate string. */
3156 token_buffer[0] = c;
3157 token_buffer[1] = 0;
3159 yylval.ttype = integer_zero_node;
3161 yylval.ttype = integer_one_node;
3168 /* fall through... */
3169 case '2': case '3': case '4':
3170 case '5': case '6': case '7': case '8': case '9':
3171 resume_numerical_scan:
3176 int largest_digit = 0;
3178 /* for multi-precision arithmetic,
3179 we actually store only HOST_BITS_PER_CHAR bits in each part.
3180 The number of parts is chosen so as to be sufficient to hold
3181 the enough bits to fit into the two HOST_WIDE_INTs that contain
3182 the integer value (this is always at least as many bits as are
3183 in a target `long long' value, but may be wider). */
3184 #define TOTAL_PARTS ((HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2 + 2)
3185 int parts[TOTAL_PARTS];
3188 enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS} floatflag
3194 for (count = 0; count < TOTAL_PARTS; count++)
3199 *p++ = (c = getch ());
3200 if ((c == 'x') || (c == 'X'))
3203 *p++ = (c = getch ());
3205 /* Leading 0 forces octal unless the 0 is the only digit. */
3206 else if (c >= '0' && c <= '9')
3215 /* Read all the digits-and-decimal-points. */
3218 || (isalnum (c) && (c != 'l') && (c != 'L')
3219 && (c != 'u') && (c != 'U')
3220 && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
3225 error ("floating constant may not be in radix 16");
3226 if (floatflag == AFTER_POINT)
3228 error ("malformed floating constant");
3229 floatflag = TOO_MANY_POINTS;
3232 floatflag = AFTER_POINT;
3235 *p++ = c = getch ();
3236 /* Accept '.' as the start of a floating-point number
3237 only when it is followed by a digit.
3238 Otherwise, unread the following non-digit
3239 and use the '.' as a structural token. */
3240 if (p == token_buffer + 2 && !isdigit (c))
3252 error ("parse error at `..'");
3255 token_buffer[1] = '\0';
3262 /* It is not a decimal point.
3263 It should be a digit (perhaps a hex digit). */
3269 else if (base <= 10)
3271 if (c == 'e' || c == 'E')
3274 floatflag = AFTER_POINT;
3275 break; /* start of exponent */
3277 error ("nondigits in number and not hexadecimal");
3288 if (c >= largest_digit)
3292 for (count = 0; count < TOTAL_PARTS; count++)
3294 parts[count] *= base;
3298 += (parts[count-1] >> HOST_BITS_PER_CHAR);
3300 &= (1 << HOST_BITS_PER_CHAR) - 1;
3306 /* If the extra highest-order part ever gets anything in it,
3307 the number is certainly too big. */
3308 if (parts[TOTAL_PARTS - 1] != 0)
3311 if (p >= token_buffer + maxtoken - 3)
3312 p = extend_token_buffer (p);
3313 *p++ = (c = getch ());
3318 error ("numeric constant with no digits");
3320 if (largest_digit >= base)
3321 error ("numeric constant contains digits beyond the radix");
3323 /* Remove terminating char from the token buffer and delimit the string */
3326 if (floatflag != NOT_FLOAT)
3328 tree type = double_type_node;
3331 int garbage_chars = 0;
3332 REAL_VALUE_TYPE value;
3335 /* Read explicit exponent if any, and put it in tokenbuf. */
3337 if ((c == 'e') || (c == 'E'))
3339 if (p >= token_buffer + maxtoken - 3)
3340 p = extend_token_buffer (p);
3343 if ((c == '+') || (c == '-'))
3349 error ("floating constant exponent has no digits");
3352 if (p >= token_buffer + maxtoken - 3)
3353 p = extend_token_buffer (p);
3362 /* Convert string to a double, checking for overflow. */
3363 if (setjmp (handler))
3365 error ("floating constant out of range");
3370 set_float_handler (handler);
3371 /* The second argument, machine_mode, of REAL_VALUE_ATOF
3372 tells the desired precision of the binary result of
3373 decimal-to-binary conversion. */
3375 /* Read the suffixes to choose a data type. */
3379 type = float_type_node;
3380 value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
3385 type = long_double_type_node;
3386 value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
3391 value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
3393 set_float_handler (NULL_PTR);
3396 && (REAL_VALUE_ISINF (value)
3398 || (TARGET_FLOAT_FORMAT != IEEE_FLOAT_FORMAT
3400 /* ERANGE is also reported for underflow, so test the
3401 value to distinguish overflow from that. */
3402 && (REAL_VALUES_LESS (dconst1, value)
3403 || REAL_VALUES_LESS (value, dconstm1)))
3407 pedwarn ("floating point number exceeds range of `%s'",
3408 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
3410 /* Note: garbage_chars is -1 if first char is *not* garbage. */
3413 if (c == 'f' || c == 'F')
3416 error ("two `f's in floating constant");
3419 if (c == 'l' || c == 'L')
3422 error ("two `l's in floating constant");
3425 if (p >= token_buffer + maxtoken - 3)
3426 p = extend_token_buffer (p);
3432 if (garbage_chars > 0)
3433 error ("garbage at end of number");
3435 /* Create a node with determined type and value. */
3436 yylval.ttype = build_real (type, value);
3444 HOST_WIDE_INT high, low;
3445 int spec_unsigned = 0;
3447 int spec_long_long = 0;
3452 if (c == 'u' || c == 'U')
3455 error ("two `u's in integer constant");
3458 else if (c == 'l' || c == 'L')
3463 error ("three `l's in integer constant");
3465 pedwarn ("ANSI C++ forbids long long integer constants");
3474 error ("garbage at end of number");
3477 if (p >= token_buffer + maxtoken - 3)
3478 p = extend_token_buffer (p);
3485 if (p >= token_buffer + maxtoken - 3)
3486 p = extend_token_buffer (p);
3493 /* If the constant is not long long and it won't fit in an
3494 unsigned long, or if the constant is long long and won't fit
3495 in an unsigned long long, then warn that the constant is out
3498 /* ??? This assumes that long long and long integer types are
3499 a multiple of 8 bits. This better than the original code
3500 though which assumed that long was exactly 32 bits and long
3501 long was exactly 64 bits. */
3504 bytes = TYPE_PRECISION (long_long_integer_type_node) / 8;
3506 bytes = TYPE_PRECISION (long_integer_type_node) / 8;
3509 for (i = bytes; i < TOTAL_PARTS; i++)
3513 pedwarn ("integer constant out of range");
3515 /* This is simplified by the fact that our constant
3516 is always positive. */
3519 for (i = 0; i < HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR; i++)
3521 high |= ((HOST_WIDE_INT) parts[i + (HOST_BITS_PER_WIDE_INT
3522 / HOST_BITS_PER_CHAR)]
3523 << (i * HOST_BITS_PER_CHAR));
3524 low |= (HOST_WIDE_INT) parts[i] << (i * HOST_BITS_PER_CHAR);
3528 yylval.ttype = build_int_2 (low, high);
3529 TREE_TYPE (yylval.ttype) = long_long_unsigned_type_node;
3532 /* Find the first allowable type that the value fits in. */
3534 for (i = 0; i < sizeof (type_sequence) / sizeof (type_sequence[0]);
3536 if (!(spec_long && !type_sequence[i].long_flag)
3537 && !(spec_long_long && !type_sequence[i].long_long_flag)
3538 && !(spec_unsigned && !type_sequence[i].unsigned_flag)
3539 /* A hex or octal constant traditionally is unsigned. */
3540 && !(base != 10 && flag_traditional
3541 && !type_sequence[i].unsigned_flag)
3542 /* A decimal constant can't be unsigned int
3543 unless explicitly specified. */
3544 && !(base == 10 && !spec_unsigned
3545 && *type_sequence[i].node_var == unsigned_type_node))
3546 if (int_fits_type_p (yylval.ttype, *type_sequence[i].node_var))
3548 type = *type_sequence[i].node_var;
3551 if (flag_traditional && type == long_unsigned_type_node
3553 type = long_integer_type_node;
3557 type = long_long_integer_type_node;
3558 warning ("integer constant out of range");
3561 /* Warn about some cases where the type of a given constant
3562 changes from traditional C to ANSI C. */
3563 if (warn_traditional)
3565 tree other_type = 0;
3567 /* This computation is the same as the previous one
3568 except that flag_traditional is used backwards. */
3569 for (i = 0; i < sizeof (type_sequence) / sizeof (type_sequence[0]);
3571 if (!(spec_long && !type_sequence[i].long_flag)
3572 && !(spec_long_long && !type_sequence[i].long_long_flag)
3573 && !(spec_unsigned && !type_sequence[i].unsigned_flag)
3574 /* A hex or octal constant traditionally is unsigned. */
3575 && !(base != 10 && !flag_traditional
3576 && !type_sequence[i].unsigned_flag)
3577 /* A decimal constant can't be unsigned int
3578 unless explicitly specified. */
3579 && !(base == 10 && !spec_unsigned
3580 && *type_sequence[i].node_var == unsigned_type_node))
3581 if (int_fits_type_p (yylval.ttype, *type_sequence[i].node_var))
3583 other_type = *type_sequence[i].node_var;
3586 if (!flag_traditional && type == long_unsigned_type_node
3588 type = long_integer_type_node;
3590 if (other_type != 0 && other_type != type)
3592 if (flag_traditional)
3593 warning ("type of integer constant would be different without -traditional");
3595 warning ("type of integer constant would be different with -traditional");
3600 if (!spec_long && !spec_unsigned
3601 && !(flag_traditional && base != 10)
3602 && int_fits_type_p (yylval.ttype, integer_type_node))
3605 if (warn_traditional && base != 10)
3606 warning ("small nondecimal constant becomes signed in ANSI C++");
3608 type = integer_type_node;
3610 else if (!spec_long && (base != 10 || spec_unsigned)
3611 && int_fits_type_p (yylval.ttype, unsigned_type_node))
3613 /* Nondecimal constants try unsigned even in traditional C. */
3614 type = unsigned_type_node;
3617 else if (!spec_unsigned && !spec_long_long
3618 && int_fits_type_p (yylval.ttype, long_integer_type_node))
3619 type = long_integer_type_node;
3621 else if (! spec_long_long
3622 && int_fits_type_p (yylval.ttype,
3623 long_unsigned_type_node))
3626 if (warn_traditional && !spec_unsigned)
3627 warning ("large integer constant becomes unsigned in ANSI C++");
3629 if (flag_traditional && !spec_unsigned)
3630 type = long_integer_type_node;
3632 type = long_unsigned_type_node;
3635 else if (! spec_unsigned
3636 /* Verify value does not overflow into sign bit. */
3637 && TREE_INT_CST_HIGH (yylval.ttype) >= 0
3638 && int_fits_type_p (yylval.ttype,
3639 long_long_integer_type_node))
3640 type = long_long_integer_type_node;
3642 else if (int_fits_type_p (yylval.ttype,
3643 long_long_unsigned_type_node))
3646 if (warn_traditional && !spec_unsigned)
3647 warning ("large nondecimal constant is unsigned in ANSI C++");
3650 if (flag_traditional && !spec_unsigned)
3651 type = long_long_integer_type_node;
3653 type = long_long_unsigned_type_node;
3658 type = long_long_integer_type_node;
3659 warning ("integer constant out of range");
3661 if (base == 10 && ! spec_unsigned && TREE_UNSIGNED (type))
3662 warning ("decimal integer constant is so large that it is unsigned");
3666 TREE_TYPE (yylval.ttype) = type;
3670 value = CONSTANT; break;
3676 register int result = 0;
3677 register int num_chars = 0;
3678 unsigned width = TYPE_PRECISION (char_type_node);
3683 width = WCHAR_TYPE_SIZE;
3684 #ifdef MULTIBYTE_CHARS
3685 max_chars = MB_CUR_MAX;
3691 max_chars = TYPE_PRECISION (integer_type_node) / width;
3699 if (c == '\'' || c == EOF)
3705 c = readescape (&ignore);
3708 if (width < HOST_BITS_PER_INT
3709 && (unsigned) c >= (1 << width))
3710 warning ("escape sequence out of range for character");
3711 #ifdef MAP_CHARACTER
3713 c = MAP_CHARACTER (c);
3719 pedwarn ("ANSI C++ forbids newline in character constant");
3722 #ifdef MAP_CHARACTER
3724 c = MAP_CHARACTER (c);
3728 if (num_chars > maxtoken - 4)
3729 extend_token_buffer (token_buffer);
3731 token_buffer[num_chars] = c;
3733 /* Merge character into result; ignore excess chars. */
3734 if (num_chars < max_chars + 1)
3736 if (width < HOST_BITS_PER_INT)
3737 result = (result << width) | (c & ((1 << width) - 1));
3743 token_buffer[num_chars + 1] = '\'';
3744 token_buffer[num_chars + 2] = 0;
3747 error ("malformatted character constant");
3748 else if (num_chars == 0)
3749 error ("empty character constant");
3750 else if (num_chars > max_chars)
3752 num_chars = max_chars;
3753 error ("character constant too long");
3755 else if (num_chars != 1 && ! flag_traditional)
3756 warning ("multi-character character constant");
3758 /* If char type is signed, sign-extend the constant. */
3761 int num_bits = num_chars * width;
3763 /* We already got an error; avoid invalid shift. */
3764 yylval.ttype = build_int_2 (0, 0);
3765 else if (TREE_UNSIGNED (char_type_node)
3766 || ((result >> (num_bits - 1)) & 1) == 0)
3768 = build_int_2 (result & ((unsigned HOST_WIDE_INT) ~0
3769 >> (HOST_BITS_PER_WIDE_INT - num_bits)),
3773 = build_int_2 (result | ~((unsigned HOST_WIDE_INT) ~0
3774 >> (HOST_BITS_PER_WIDE_INT - num_bits)),
3777 TREE_TYPE (yylval.ttype) = char_type_node;
3779 TREE_TYPE (yylval.ttype) = integer_type_node;
3783 #ifdef MULTIBYTE_CHARS
3784 /* Set the initial shift state and convert the next sequence. */
3786 /* In all locales L'\0' is zero and mbtowc will return zero,
3789 || (num_chars == 1 && token_buffer[1] != '\0'))
3792 (void) mbtowc (NULL, NULL, 0);
3793 if (mbtowc (& wc, token_buffer + 1, num_chars) == num_chars)
3796 warning ("Ignoring invalid multibyte character");
3799 yylval.ttype = build_int_2 (result, 0);
3800 TREE_TYPE (yylval.ttype) = wchar_type_node;
3813 p = token_buffer + 1;
3815 while (c != '"' && c >= 0)
3817 /* ignore_escape_flag is set for reading the filename in #line. */
3818 if (!ignore_escape_flag && c == '\\')
3821 c = readescape (&ignore);
3825 && TYPE_PRECISION (char_type_node) < HOST_BITS_PER_INT
3826 && c >= ((unsigned) 1 << TYPE_PRECISION (char_type_node)))
3827 warning ("escape sequence out of range for character");
3832 pedwarn ("ANSI C++ forbids newline in string constant");
3836 if (p == token_buffer + maxtoken)
3837 p = extend_token_buffer (p);
3843 error ("Unterminated string");
3849 /* We have read the entire constant.
3850 Construct a STRING_CST for the result. */
3854 /* If this is a L"..." wide-string, convert the multibyte string
3855 to a wide character string. */
3856 char *widep = (char *) alloca ((p - token_buffer) * WCHAR_BYTES);
3859 #ifdef MULTIBYTE_CHARS
3860 len = mbstowcs ((wchar_t *) widep, token_buffer + 1, p - token_buffer);
3861 if (len < 0 || len >= (p - token_buffer))
3863 warning ("Ignoring invalid multibyte string");
3866 bzero (widep + (len * WCHAR_BYTES), WCHAR_BYTES);
3869 union { long l; char c[sizeof (long)]; } u;
3873 /* Determine whether host is little or big endian. */
3875 big_endian = u.c[sizeof (long) - 1];
3876 wp = widep + (big_endian ? WCHAR_BYTES - 1 : 0);
3878 bzero (widep, (p - token_buffer) * WCHAR_BYTES);
3879 for (cp = token_buffer + 1; cp < p; cp++)
3880 *wp = *cp, wp += WCHAR_BYTES;
3881 len = p - token_buffer - 1;
3884 if (current_template_parms)
3885 push_obstacks (&permanent_obstack, &permanent_obstack);
3886 yylval.ttype = build_string ((len + 1) * WCHAR_BYTES, widep);
3887 if (current_template_parms)
3889 TREE_TYPE (yylval.ttype) = wchar_array_type_node;
3893 if (current_template_parms)
3894 push_obstacks (&permanent_obstack, &permanent_obstack);
3895 yylval.ttype = build_string (p - token_buffer, token_buffer + 1);
3896 if (current_template_parms)
3898 TREE_TYPE (yylval.ttype) = char_array_type_node;
3904 value = STRING; break;
3927 yylval.code = PLUS_EXPR; break;
3929 yylval.code = MINUS_EXPR; break;
3931 yylval.code = BIT_AND_EXPR; break;
3933 yylval.code = BIT_IOR_EXPR; break;
3935 yylval.code = MULT_EXPR; break;
3937 yylval.code = TRUNC_DIV_EXPR; break;
3939 yylval.code = TRUNC_MOD_EXPR; break;
3941 yylval.code = BIT_XOR_EXPR; break;
3943 yylval.code = LSHIFT_EXPR; break;
3945 yylval.code = RSHIFT_EXPR; break;
3947 yylval.code = LT_EXPR; break;
3949 yylval.code = GT_EXPR; break;
3952 token_buffer[1] = c1 = getch ();
3953 token_buffer[2] = 0;
3960 value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done;
3962 value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done;
3964 value = EQCOMPARE; yylval.code = NE_EXPR; goto done;
3966 value = EQCOMPARE; yylval.code = EQ_EXPR; goto done;
3968 value = ASSIGN; goto done;
3974 value = PLUSPLUS; goto done;
3976 value = MINUSMINUS; goto done;
3978 value = ANDAND; goto done;
3980 value = OROR; goto done;
3988 else if ((c == '-') && (c1 == '>'))
3990 nextchar = getch ();
3991 if (nextchar == '*')
3994 value = POINTSAT_STAR;
4000 else if (c1 == '?' && (c == '<' || c == '>'))
4002 token_buffer[3] = 0;
4005 yylval.code = (c == '<' ? MIN_EXPR : MAX_EXPR);
4008 /* <?= or >?= expression. */
4009 token_buffer[2] = c1;
4018 pedwarn ("use of `operator %s' is not standard C++",
4023 else if (c == '<' && c1 == '%')
4024 { value = '{'; goto done; }
4025 else if (c == '<' && c1 == ':')
4026 { value = '['; goto done; }
4027 else if (c == '%' && c1 == '>')
4028 { value = '}'; goto done; }
4029 else if (c == '%' && c1 == ':')
4030 { value = '#'; goto done; }
4033 token_buffer[1] = 0;
4043 token_buffer[1] = ':';
4044 token_buffer[2] = '\0';
4061 /* Don't make yyparse think this is eof. */
4066 /* try, weakly, to handle casts to pointers to functions. */
4067 nextchar = skip_white_space (getch ());
4068 if (nextchar == '*')
4070 int next_c = skip_white_space (getch ());
4074 yylval.ttype = build1 (INDIRECT_REF, 0, 0);
4075 value = PAREN_STAR_PAREN;
4083 else if (nextchar == ')')
4086 yylval.ttype = NULL_TREE;
4097 /* yylloc.last_line = lineno; */
4098 #ifdef GATHER_STATISTICS
4099 #ifdef REDUCE_LENGTH
4100 token_count[value] += 1;
4111 return !!is_reserved_word (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t));
4114 #ifdef GATHER_STATISTICS
4115 extern int tree_node_counts[];
4116 extern int tree_node_sizes[];
4119 /* Place to save freed lang_decls which were allocated on the
4120 permanent_obstack. @@ Not currently used. */
4121 tree free_lang_decl_chain;
4124 build_lang_decl (code, name, type)
4125 enum tree_code code;
4129 register tree t = build_decl (code, name, type);
4130 struct obstack *obstack = current_obstack;
4131 register int i = sizeof (struct lang_decl) / sizeof (int);
4134 if (! TREE_PERMANENT (t))
4135 obstack = saveable_obstack;
4137 /* Could be that saveable is permanent and current is not. */
4138 obstack = &permanent_obstack;
4140 if (free_lang_decl_chain && obstack == &permanent_obstack)
4142 pi = (int *)free_lang_decl_chain;
4143 free_lang_decl_chain = TREE_CHAIN (free_lang_decl_chain);
4146 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
4151 DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
4152 LANG_DECL_PERMANENT ((struct lang_decl *) pi)
4153 = obstack == &permanent_obstack;
4154 my_friendly_assert (LANG_DECL_PERMANENT ((struct lang_decl *) pi)
4155 == TREE_PERMANENT (t), 234);
4156 DECL_MAIN_VARIANT (t) = t;
4157 if (current_lang_name == lang_name_cplusplus)
4159 DECL_LANGUAGE (t) = lang_cplusplus;
4161 #ifndef NO_AUTO_OVERLOAD
4162 if (code == FUNCTION_DECL && name != 0
4163 && ! (IDENTIFIER_LENGTH (name) == 4
4164 && IDENTIFIER_POINTER (name)[0] == 'm'
4165 && strcmp (IDENTIFIER_POINTER (name), "main") == 0)
4166 && ! (IDENTIFIER_LENGTH (name) > 10
4167 && IDENTIFIER_POINTER (name)[0] == '_'
4168 && IDENTIFIER_POINTER (name)[1] == '_'
4169 && strncmp (IDENTIFIER_POINTER (name)+2, "builtin_", 8) == 0))
4170 TREE_OVERLOADED (name) = 1;
4174 else if (current_lang_name == lang_name_c)
4175 DECL_LANGUAGE (t) = lang_c;
4176 else my_friendly_abort (64);
4178 #if 0 /* not yet, should get fixed properly later */
4179 if (code == TYPE_DECL)
4182 id = get_identifier (build_overload_name (type, 1, 1));
4183 DECL_ASSEMBLER_NAME (t) = id;
4187 #ifdef GATHER_STATISTICS
4188 tree_node_counts[(int)lang_decl] += 1;
4189 tree_node_sizes[(int)lang_decl] += sizeof (struct lang_decl);
4196 build_lang_field_decl (code, name, type)
4197 enum tree_code code;
4201 extern struct obstack *current_obstack, *saveable_obstack;
4202 register tree t = build_decl (code, name, type);
4203 struct obstack *obstack = current_obstack;
4204 register int i = sizeof (struct lang_decl_flags) / sizeof (int);
4206 #if 0 /* not yet, should get fixed properly later */
4208 if (code == TYPE_DECL)
4211 id = get_identifier (build_overload_name (type, 1, 1));
4212 DECL_ASSEMBLER_NAME (t) = id;
4216 if (! TREE_PERMANENT (t))
4217 obstack = saveable_obstack;
4219 my_friendly_assert (obstack == &permanent_obstack, 235);
4221 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl_flags));
4225 DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
4230 copy_lang_decl (node)
4236 if (! DECL_LANG_SPECIFIC (node))
4239 if (TREE_CODE (node) == FIELD_DECL)
4240 size = sizeof (struct lang_decl_flags);
4242 size = sizeof (struct lang_decl);
4243 pi = (int *)obstack_alloc (&permanent_obstack, size);
4244 bcopy ((char *)DECL_LANG_SPECIFIC (node), (char *)pi, size);
4245 DECL_LANG_SPECIFIC (node) = (struct lang_decl *)pi;
4249 make_lang_type (code)
4250 enum tree_code code;
4252 extern struct obstack *current_obstack, *saveable_obstack;
4253 register tree t = make_node (code);
4254 struct obstack *obstack = current_obstack;
4255 register int i = sizeof (struct lang_type) / sizeof (int);
4258 /* Set up some flags that give proper default behavior. */
4259 IS_AGGR_TYPE (t) = 1;
4261 if (! TREE_PERMANENT (t))
4262 obstack = saveable_obstack;
4264 my_friendly_assert (obstack == &permanent_obstack, 236);
4266 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_type));
4270 TYPE_LANG_SPECIFIC (t) = (struct lang_type *) pi;
4271 CLASSTYPE_AS_LIST (t) = build_tree_list (NULL_TREE, t);
4272 SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, interface_unknown);
4273 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
4274 CLASSTYPE_VBASE_SIZE (t) = integer_zero_node;
4275 TYPE_BINFO (t) = make_binfo (integer_zero_node, t, NULL_TREE, NULL_TREE,
4277 CLASSTYPE_BINFO_AS_LIST (t) = build_tree_list (NULL_TREE, TYPE_BINFO (t));
4279 /* Make sure this is laid out, for ease of use later.
4280 In the presence of parse errors, the normal was of assuring
4281 this might not ever get executed, so we lay it out *immediately*. */
4282 build_pointer_type (t);
4284 #ifdef GATHER_STATISTICS
4285 tree_node_counts[(int)lang_type] += 1;
4286 tree_node_sizes[(int)lang_type] += sizeof (struct lang_type);
4293 copy_decl_lang_specific (decl)
4296 extern struct obstack *current_obstack, *saveable_obstack;
4297 register int *old = (int *)DECL_LANG_SPECIFIC (decl);
4298 struct obstack *obstack = current_obstack;
4299 register int i = sizeof (struct lang_decl) / sizeof (int);
4302 if (! TREE_PERMANENT (decl))
4303 obstack = saveable_obstack;
4305 my_friendly_assert (obstack == &permanent_obstack, 237);
4307 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
4311 DECL_LANG_SPECIFIC (decl) = (struct lang_decl *) pi;
4313 #ifdef GATHER_STATISTICS
4314 tree_node_counts[(int)lang_decl] += 1;
4315 tree_node_sizes[(int)lang_decl] += sizeof (struct lang_decl);
4320 dump_time_statistics ()
4322 register tree prev = 0, decl, next;
4323 int this_time = my_get_run_time ();
4324 TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time))
4325 += this_time - body_time;
4327 fprintf (stderr, "\n******\n");
4328 print_time ("header files (total)", header_time);
4329 print_time ("main file (total)", this_time - body_time);
4330 fprintf (stderr, "ratio = %g : 1\n",
4331 (double)header_time / (double)(this_time - body_time));
4332 fprintf (stderr, "\n******\n");
4334 for (decl = filename_times; decl; decl = next)
4336 next = IDENTIFIER_GLOBAL_VALUE (decl);
4337 IDENTIFIER_GLOBAL_VALUE (decl) = prev;
4341 for (decl = prev; decl; decl = IDENTIFIER_GLOBAL_VALUE (decl))
4342 print_time (IDENTIFIER_POINTER (decl),
4343 TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (decl)));
4347 compiler_error (s, v, v2)
4349 HOST_WIDE_INT v, v2; /* @@also used as pointer */
4352 sprintf (buf, s, v, v2);
4353 error_with_file_and_line (input_filename, lineno, "%s (compiler error)", buf);
4360 extern int end_of_file;
4363 strcpy (buf, string);
4365 /* We can't print string and character constants well
4366 because the token_buffer contains the result of processing escapes. */
4368 strcat (buf, input_redirected ()
4369 ? " at end of saved text"
4370 : " at end of input");
4371 else if (token_buffer[0] == 0)
4372 strcat (buf, " at null character");
4373 else if (token_buffer[0] == '"')
4374 strcat (buf, " before string constant");
4375 else if (token_buffer[0] == '\'')
4376 strcat (buf, " before character constant");
4377 else if (token_buffer[0] < 040 || (unsigned char) token_buffer[0] >= 0177)
4378 sprintf (buf + strlen (buf), " before character 0%o",
4379 (unsigned char) token_buffer[0]);
4381 strcat (buf, " before `%s'");
4383 error (buf, token_buffer);
4387 handle_cp_pragma (pname)
4392 if (! strcmp (pname, "vtable"))
4394 extern tree pending_vtables;
4396 /* More follows: it must be a string constant (class name). */
4397 token = real_yylex ();
4398 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
4400 error ("invalid #pragma vtable");
4404 if (write_virtuals != 2)
4406 warning ("use `+e2' option to enable #pragma vtable");
4410 = perm_tree_cons (NULL_TREE,
4411 get_identifier (TREE_STRING_POINTER (yylval.ttype)),
4413 token = real_yylex ();
4414 if (token != END_OF_LINE)
4415 warning ("trailing characters ignored");
4418 else if (! strcmp (pname, "unit"))
4420 /* More follows: it must be a string constant (unit name). */
4421 token = real_yylex ();
4422 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
4424 error ("invalid #pragma unit");
4427 token = real_yylex ();
4428 if (token != END_OF_LINE)
4429 warning ("trailing characters ignored");
4432 else if (! strcmp (pname, "interface"))
4434 tree fileinfo = IDENTIFIER_CLASS_VALUE (get_time_identifier (input_filename));
4435 int warned_already = 0;
4436 char *main_filename = input_filename;
4438 main_filename = FILE_NAME_NONDIRECTORY (main_filename);
4440 token = real_yylex ();
4442 if (token != END_OF_LINE)
4445 || TREE_CODE (yylval.ttype) != STRING_CST)
4447 error ("invalid `#pragma interface'");
4450 main_filename = TREE_STRING_POINTER (yylval.ttype);
4453 #ifdef SUPPORTS_ONE_ONLY
4454 if (SUPPORTS_ONE_ONLY > 1)
4458 while (token != END_OF_LINE)
4460 if (!warned_already && extra_warnings)
4462 warning ("garbage after `#pragma interface' ignored");
4465 token = real_yylex ();
4470 if (impl_file_chain == 0)
4472 /* If this is zero at this point, then we are
4473 auto-implementing. */
4474 if (main_input_filename == 0)
4475 main_input_filename = input_filename;
4477 #ifdef AUTO_IMPLEMENT
4478 filename = FILE_NAME_NONDIRECTORY (main_input_filename);
4479 fi = get_time_identifier (filename);
4480 fi = IDENTIFIER_CLASS_VALUE (fi);
4481 TREE_INT_CST_LOW (fi) = 0;
4482 TREE_INT_CST_HIGH (fi) = 1;
4484 impl_file_chain = (struct impl_files *)permalloc (sizeof (struct impl_files));
4485 impl_file_chain->filename = filename;
4486 impl_file_chain->next = 0;
4490 interface_only = interface_strcmp (main_filename);
4491 interface_unknown = 0;
4492 TREE_INT_CST_LOW (fileinfo) = interface_only;
4493 TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
4497 else if (! strcmp (pname, "implementation"))
4499 tree fileinfo = IDENTIFIER_CLASS_VALUE (get_time_identifier (input_filename));
4500 int warned_already = 0;
4501 char *main_filename = main_input_filename ? main_input_filename : input_filename;
4503 main_filename = FILE_NAME_NONDIRECTORY (main_filename);
4504 token = real_yylex ();
4505 if (token != END_OF_LINE)
4508 || TREE_CODE (yylval.ttype) != STRING_CST)
4510 error ("invalid `#pragma implementation'");
4513 main_filename = TREE_STRING_POINTER (yylval.ttype);
4516 while (token != END_OF_LINE)
4518 if (!warned_already && extra_warnings)
4520 warning ("garbage after `#pragma implementation' ignored");
4523 token = real_yylex ();
4526 #ifdef SUPPORTS_ONE_ONLY
4527 if (SUPPORTS_ONE_ONLY > 1)
4531 if (write_virtuals == 3)
4533 struct impl_files *ifiles = impl_file_chain;
4536 if (! strcmp (ifiles->filename, main_filename))
4538 ifiles = ifiles->next;
4542 ifiles = (struct impl_files*) permalloc (sizeof (struct impl_files));
4543 ifiles->filename = main_filename;
4544 ifiles->next = impl_file_chain;
4545 impl_file_chain = ifiles;
4548 else if ((main_input_filename != 0
4549 && ! strcmp (main_input_filename, input_filename))
4550 || ! strcmp (input_filename, main_filename))
4553 if (impl_file_chain == 0)
4555 impl_file_chain = (struct impl_files*) permalloc (sizeof (struct impl_files));
4556 impl_file_chain->filename = main_filename;
4557 impl_file_chain->next = 0;
4561 error ("`#pragma implementation' can only appear at top-level");
4564 /* We make this non-zero so that we infer decl linkage
4565 in the impl file only for variables first declared
4566 in the interface file. */
4567 interface_unknown = 1;
4569 /* We make this zero so that templates in the impl
4570 file will be emitted properly. */
4571 interface_unknown = 0;
4573 TREE_INT_CST_LOW (fileinfo) = interface_only;
4574 TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
4581 #ifdef HANDLE_SYSV_PRAGMA
4583 /* Handle a #pragma directive. INPUT is the current input stream,
4584 and C is a character to reread. Processes the entire input line
4585 and returns a character for the caller to reread: either \n or EOF. */
4587 /* This function has to be in this file, in order to get at
4590 handle_sysv_pragma (finput, token)
4602 handle_pragma_token ("ignored", yylval.ttype);
4605 handle_pragma_token ("(", NULL_TREE);
4608 handle_pragma_token (")", NULL_TREE);
4611 handle_pragma_token (",", NULL_TREE);
4614 handle_pragma_token ("=", NULL_TREE);
4617 handle_pragma_token ("(", NULL_TREE);
4618 handle_pragma_token (")", NULL_TREE);
4622 handle_pragma_token (NULL_PTR, NULL_TREE);
4625 token = real_yylex ();
4628 #endif /* HANDLE_SYSV_PRAGMA */