1 /* Separate lexical analyzer for GNU C++.
2 Copyright (C) 1987, 89, 92-96, 1997 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. */
40 /* MULTIBYTE_CHARS support only works for native compilers.
41 ??? Ideally what we want is to model widechar support after
42 the current floating point support. */
44 #undef MULTIBYTE_CHARS
47 #ifdef MULTIBYTE_CHARS
53 #ifndef MULTIBYTE_CHARS
57 extern double atof ();
60 #define obstack_chunk_alloc xmalloc
61 #define obstack_chunk_free free
64 #define DIR_SEPARATOR '/'
67 extern struct obstack permanent_obstack;
68 extern struct obstack *current_obstack, *saveable_obstack;
70 extern void yyprint PROTO((FILE *, int, YYSTYPE));
71 extern void set_float_handler PROTO((jmp_buf));
72 extern void compiler_error PROTO((char *, HOST_WIDE_INT,
75 static tree get_time_identifier PROTO((char *));
76 static int check_newline PROTO((void));
77 static int skip_white_space PROTO((int));
78 static void finish_defarg PROTO((void));
79 static int my_get_run_time PROTO((void));
80 static int get_last_nonwhite_on_line PROTO((void));
81 static int interface_strcmp PROTO((char *));
82 static int readescape PROTO((int *));
83 static char *extend_token_buffer PROTO((char *));
84 static void consume_string PROTO((struct obstack *, int));
85 static void set_typedecl_interface_info PROTO((tree, tree));
86 static void feed_defarg PROTO((tree, tree));
87 static int set_vardecl_interface_info PROTO((tree, tree));
88 static void store_pending_inline PROTO((tree, struct pending_inline *));
89 static void reinit_parse_for_expr PROTO((struct obstack *));
90 static int *init_cpp_parse PROTO((void));
91 static int handle_cp_pragma PROTO((char *));
92 #ifdef HANDLE_SYSV_PRAGMA
93 static int handle_sysv_pragma PROTO((FILE *, int));
95 #ifdef GATHER_STATISTICS
97 static int reduce_cmp PROTO((int *, int *));
98 static int token_cmp PROTO((int *, int *));
102 /* Given a file name X, return the nondirectory portion.
103 Keep in mind that X can be computed more than once. */
105 file_name_nondirectory (x)
108 char *tmp = (char *) rindex (x, '/');
109 if (DIR_SEPARATOR != '/' && ! tmp)
110 tmp = (char *) rindex (x, DIR_SEPARATOR);
112 return (char *) (tmp + 1);
117 /* This obstack is needed to hold text. It is not safe to use
118 TOKEN_BUFFER because `check_newline' calls `yylex'. */
119 struct obstack inline_text_obstack;
120 char *inline_text_firstobj;
127 /* Pending language change.
128 Positive is push count, negative is pop count. */
129 int pending_lang_change = 0;
131 /* Wrap the current header file in extern "C". */
132 static int c_header_level = 0;
134 extern int first_token;
135 extern struct obstack token_obstack;
137 /* ??? Don't really know where this goes yet. */
141 extern void put_back (/* int */);
142 extern int input_redirected ();
143 extern void feed_input (/* char *, int */);
146 /* Holds translations from TREE_CODEs to operator name strings,
147 i.e., opname_tab[PLUS_EXPR] == "+". */
151 extern int yychar; /* the lookahead symbol */
152 extern YYSTYPE yylval; /* the semantic value of the */
153 /* lookahead symbol */
156 YYLTYPE yylloc; /* location data for the lookahead */
161 /* the declaration found for the last IDENTIFIER token read in.
162 yylex must look this up to detect typedefs, which get token type TYPENAME,
163 so it is left around in case the identifier is not a typedef but is
164 used in a context which makes it a reference to a variable. */
167 /* The elements of `ridpointers' are identifier nodes
168 for the reserved type names and storage classes.
169 It is indexed by a RID_... value. */
170 tree ridpointers[(int) RID_MAX];
172 /* We may keep statistics about how long which files took to compile. */
173 static int header_time, body_time;
174 static tree filename_times;
175 static tree this_filename_time;
177 /* Array for holding counts of the numbers of tokens seen. */
178 extern int *token_count;
180 /* Return something to represent absolute declarators containing a *.
181 TARGET is the absolute declarator that the * contains.
182 CV_QUALIFIERS is a list of modifiers such as const or volatile
183 to apply to the pointer type, represented as identifiers.
185 We return an INDIRECT_REF whose "contents" are TARGET
186 and whose type is the modifier list. */
189 make_pointer_declarator (cv_qualifiers, target)
190 tree cv_qualifiers, target;
192 if (target && TREE_CODE (target) == IDENTIFIER_NODE
193 && ANON_AGGRNAME_P (target))
194 error ("type name expected before `*'");
195 target = build_parse_node (INDIRECT_REF, target);
196 TREE_TYPE (target) = cv_qualifiers;
200 /* Return something to represent absolute declarators containing a &.
201 TARGET is the absolute declarator that the & contains.
202 CV_QUALIFIERS is a list of modifiers such as const or volatile
203 to apply to the reference type, represented as identifiers.
205 We return an ADDR_EXPR whose "contents" are TARGET
206 and whose type is the modifier list. */
209 make_reference_declarator (cv_qualifiers, target)
210 tree cv_qualifiers, target;
214 if (TREE_CODE (target) == ADDR_EXPR)
216 error ("cannot declare references to references");
219 if (TREE_CODE (target) == INDIRECT_REF)
221 error ("cannot declare pointers to references");
224 if (TREE_CODE (target) == IDENTIFIER_NODE && ANON_AGGRNAME_P (target))
225 error ("type name expected before `&'");
227 target = build_parse_node (ADDR_EXPR, target);
228 TREE_TYPE (target) = cv_qualifiers;
233 make_call_declarator (target, parms, cv_qualifiers, exception_specification)
234 tree target, parms, cv_qualifiers, exception_specification;
236 target = build_parse_node (CALL_EXPR, target, parms, cv_qualifiers);
237 TREE_TYPE (target) = exception_specification;
242 set_quals_and_spec (call_declarator, cv_qualifiers, exception_specification)
243 tree call_declarator, cv_qualifiers, exception_specification;
245 TREE_OPERAND (call_declarator, 2) = cv_qualifiers;
246 TREE_TYPE (call_declarator) = exception_specification;
249 /* Build names and nodes for overloaded operators. */
251 tree ansi_opname[LAST_CPLUS_TREE_CODE];
252 tree ansi_assopname[LAST_CPLUS_TREE_CODE];
255 operator_name_string (name)
258 char *opname = IDENTIFIER_POINTER (name) + 2;
262 /* Works for builtin and user defined types. */
263 if (IDENTIFIER_GLOBAL_VALUE (name)
264 && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (name)) == TYPE_DECL)
265 return IDENTIFIER_POINTER (name);
267 if (opname[0] == 'a' && opname[2] != '\0' && opname[2] != '_')
271 opname_table = ansi_assopname;
276 opname_table = ansi_opname;
279 for (i = 0; i < (int) LAST_CPLUS_TREE_CODE; i++)
281 if (opname[0] == IDENTIFIER_POINTER (opname_table[i])[2+assign]
282 && opname[1] == IDENTIFIER_POINTER (opname_table[i])[3+assign])
286 if (i == LAST_CPLUS_TREE_CODE)
287 return "<invalid operator>";
290 return assignop_tab[i];
292 return opname_tab[i];
295 int interface_only; /* whether or not current file is only for
296 interface definitions. */
297 int interface_unknown; /* whether or not we know this class
298 to behave according to #pragma interface. */
300 /* lexical analyzer */
302 /* File used for outputting assembler code. */
303 extern FILE *asm_out_file;
305 #ifndef WCHAR_TYPE_SIZE
307 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
309 #define WCHAR_TYPE_SIZE BITS_PER_WORD
313 /* Number of bytes in a wide character. */
314 #define WCHAR_BYTES (WCHAR_TYPE_SIZE / BITS_PER_UNIT)
316 static int maxtoken; /* Current nominal length of token buffer. */
317 char *token_buffer; /* Pointer to token buffer.
318 Actual allocated length is maxtoken + 2. */
323 /* Nonzero tells yylex to ignore \ in string constants. */
324 static int ignore_escape_flag = 0;
327 get_time_identifier (name)
330 tree time_identifier;
331 int len = strlen (name);
332 char *buf = (char *) alloca (len + 6);
333 strcpy (buf, "file ");
334 bcopy (name, buf+5, len);
336 time_identifier = get_identifier (buf);
337 if (IDENTIFIER_LOCAL_VALUE (time_identifier) == NULL_TREE)
339 push_obstacks_nochange ();
340 end_temporary_allocation ();
341 IDENTIFIER_LOCAL_VALUE (time_identifier) = build_int_2 (0, 0);
342 IDENTIFIER_CLASS_VALUE (time_identifier) = build_int_2 (0, 1);
343 IDENTIFIER_GLOBAL_VALUE (time_identifier) = filename_times;
344 filename_times = time_identifier;
347 return time_identifier;
356 int old_quiet_flag = quiet_flag;
359 this_time = get_run_time ();
360 quiet_flag = old_quiet_flag;
364 /* Table indexed by tree code giving a string containing a character
365 classifying the tree code. Possibilities are
366 t, d, s, c, r, <, 1 and 2. See cp/cp-tree.def for details. */
368 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
370 char cplus_tree_code_type[] = {
372 #include "cp-tree.def"
376 /* Table indexed by tree code giving number of expression
377 operands beyond the fixed part of the node structure.
378 Not used for types or decls. */
380 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
382 int cplus_tree_code_length[] = {
384 #include "cp-tree.def"
388 /* Names of tree components.
389 Used for printing out the tree and error messages. */
390 #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
392 char *cplus_tree_code_name[] = {
394 #include "cp-tree.def"
398 /* toplev.c needs to call these. */
403 /* the beginning of the file is a new line; check for # */
404 /* With luck, we discover the real source file's name from that
405 and put it in input_filename. */
406 put_back (check_newline ());
407 if (flag_gnu_xref) GNU_xref_begin (input_filename);
408 init_repo (input_filename);
410 /* See comments in toplev.c before the call to lang_init. */
411 if (flag_exceptions == 2)
418 extern int errorcount, sorrycount;
419 if (flag_gnu_xref) GNU_xref_end (errorcount+sorrycount);
429 init_filename_times ()
431 this_filename_time = get_time_identifier ("<top level>");
432 if (flag_detailed_statistics)
435 body_time = my_get_run_time ();
436 TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time)) = body_time;
440 /* Change by Bryan Boreham, Kewill, Thu Jul 27 09:46:05 1989.
441 Stuck this hack in to get the files open correctly; this is called
442 in place of init_parse if we are an unexec'd binary. */
446 reinit_lang_specific ()
448 init_filename_times ();
449 reinit_search_statistics ();
456 #ifdef GATHER_STATISTICS
458 reduce_count = (int *)malloc (sizeof (int) * (REDUCE_LENGTH + 1));
459 bzero (reduce_count, sizeof (int) * (REDUCE_LENGTH + 1));
461 token_count = (int *)malloc (sizeof (int) * (TOKEN_LENGTH + 1));
462 bzero (token_count, sizeof (int) * (TOKEN_LENGTH + 1));
470 init_parse (filename)
473 extern int flag_no_gnu_keywords;
474 extern int flag_operator_names;
479 /* Open input file. */
480 if (filename == 0 || !strcmp (filename, "-"))
486 finput = fopen (filename, "r");
488 pfatal_with_name (filename);
490 #ifdef IO_BUFFER_SIZE
491 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
493 #endif /* !USE_CPPLIB */
495 /* Initialize the lookahead machinery. */
498 /* Make identifier nodes long enough for the language-specific slots. */
499 set_identifier_size (sizeof (struct lang_identifier));
500 decl_printable_name = lang_printable_name;
502 init_cplus_expand ();
504 bcopy (cplus_tree_code_type,
505 tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
506 (int)LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE);
507 bcopy ((char *)cplus_tree_code_length,
508 (char *)(tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE),
509 (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
510 bcopy ((char *)cplus_tree_code_name,
511 (char *)(tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
512 (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
514 opname_tab = (char **)oballoc ((int)LAST_CPLUS_TREE_CODE * sizeof (char *));
515 bzero ((char *)opname_tab, (int)LAST_CPLUS_TREE_CODE * sizeof (char *));
516 assignop_tab = (char **)oballoc ((int)LAST_CPLUS_TREE_CODE * sizeof (char *));
517 bzero ((char *)assignop_tab, (int)LAST_CPLUS_TREE_CODE * sizeof (char *));
519 ansi_opname[0] = get_identifier ("<invalid operator>");
520 for (i = 0; i < (int) LAST_CPLUS_TREE_CODE; i++)
522 ansi_opname[i] = ansi_opname[0];
523 ansi_assopname[i] = ansi_opname[0];
526 ansi_opname[(int) MULT_EXPR] = get_identifier ("__ml");
527 IDENTIFIER_OPNAME_P (ansi_opname[(int) MULT_EXPR]) = 1;
528 ansi_opname[(int) INDIRECT_REF] = ansi_opname[(int) MULT_EXPR];
529 ansi_assopname[(int) MULT_EXPR] = get_identifier ("__aml");
530 IDENTIFIER_OPNAME_P (ansi_assopname[(int) MULT_EXPR]) = 1;
531 ansi_assopname[(int) INDIRECT_REF] = ansi_assopname[(int) MULT_EXPR];
532 ansi_opname[(int) TRUNC_MOD_EXPR] = get_identifier ("__md");
533 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUNC_MOD_EXPR]) = 1;
534 ansi_assopname[(int) TRUNC_MOD_EXPR] = get_identifier ("__amd");
535 IDENTIFIER_OPNAME_P (ansi_assopname[(int) TRUNC_MOD_EXPR]) = 1;
536 ansi_opname[(int) CEIL_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
537 ansi_opname[(int) FLOOR_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
538 ansi_opname[(int) ROUND_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
539 ansi_opname[(int) MINUS_EXPR] = get_identifier ("__mi");
540 IDENTIFIER_OPNAME_P (ansi_opname[(int) MINUS_EXPR]) = 1;
541 ansi_opname[(int) NEGATE_EXPR] = ansi_opname[(int) MINUS_EXPR];
542 ansi_assopname[(int) MINUS_EXPR] = get_identifier ("__ami");
543 IDENTIFIER_OPNAME_P (ansi_assopname[(int) MINUS_EXPR]) = 1;
544 ansi_assopname[(int) NEGATE_EXPR] = ansi_assopname[(int) MINUS_EXPR];
545 ansi_opname[(int) RSHIFT_EXPR] = get_identifier ("__rs");
546 IDENTIFIER_OPNAME_P (ansi_opname[(int) RSHIFT_EXPR]) = 1;
547 ansi_assopname[(int) RSHIFT_EXPR] = get_identifier ("__ars");
548 IDENTIFIER_OPNAME_P (ansi_assopname[(int) RSHIFT_EXPR]) = 1;
549 ansi_opname[(int) NE_EXPR] = get_identifier ("__ne");
550 IDENTIFIER_OPNAME_P (ansi_opname[(int) NE_EXPR]) = 1;
551 ansi_opname[(int) GT_EXPR] = get_identifier ("__gt");
552 IDENTIFIER_OPNAME_P (ansi_opname[(int) GT_EXPR]) = 1;
553 ansi_opname[(int) GE_EXPR] = get_identifier ("__ge");
554 IDENTIFIER_OPNAME_P (ansi_opname[(int) GE_EXPR]) = 1;
555 ansi_opname[(int) BIT_IOR_EXPR] = get_identifier ("__or");
556 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_IOR_EXPR]) = 1;
557 ansi_assopname[(int) BIT_IOR_EXPR] = get_identifier ("__aor");
558 IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_IOR_EXPR]) = 1;
559 ansi_opname[(int) TRUTH_ANDIF_EXPR] = get_identifier ("__aa");
560 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_ANDIF_EXPR]) = 1;
561 ansi_opname[(int) TRUTH_NOT_EXPR] = get_identifier ("__nt");
562 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_NOT_EXPR]) = 1;
563 ansi_opname[(int) PREINCREMENT_EXPR] = get_identifier ("__pp");
564 IDENTIFIER_OPNAME_P (ansi_opname[(int) PREINCREMENT_EXPR]) = 1;
565 ansi_opname[(int) POSTINCREMENT_EXPR] = ansi_opname[(int) PREINCREMENT_EXPR];
566 ansi_opname[(int) MODIFY_EXPR] = get_identifier ("__as");
567 IDENTIFIER_OPNAME_P (ansi_opname[(int) MODIFY_EXPR]) = 1;
568 ansi_assopname[(int) NOP_EXPR] = ansi_opname[(int) MODIFY_EXPR];
569 ansi_opname[(int) COMPOUND_EXPR] = get_identifier ("__cm");
570 IDENTIFIER_OPNAME_P (ansi_opname[(int) COMPOUND_EXPR]) = 1;
571 ansi_opname[(int) EXACT_DIV_EXPR] = get_identifier ("__dv");
572 IDENTIFIER_OPNAME_P (ansi_opname[(int) EXACT_DIV_EXPR]) = 1;
573 ansi_assopname[(int) EXACT_DIV_EXPR] = get_identifier ("__adv");
574 IDENTIFIER_OPNAME_P (ansi_assopname[(int) EXACT_DIV_EXPR]) = 1;
575 ansi_opname[(int) TRUNC_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
576 ansi_opname[(int) CEIL_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
577 ansi_opname[(int) FLOOR_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
578 ansi_opname[(int) ROUND_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
579 ansi_opname[(int) PLUS_EXPR] = get_identifier ("__pl");
580 ansi_assopname[(int) TRUNC_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
581 ansi_assopname[(int) CEIL_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
582 ansi_assopname[(int) FLOOR_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
583 ansi_assopname[(int) ROUND_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
584 IDENTIFIER_OPNAME_P (ansi_opname[(int) PLUS_EXPR]) = 1;
585 ansi_assopname[(int) PLUS_EXPR] = get_identifier ("__apl");
586 IDENTIFIER_OPNAME_P (ansi_assopname[(int) PLUS_EXPR]) = 1;
587 ansi_opname[(int) CONVERT_EXPR] = ansi_opname[(int) PLUS_EXPR];
588 ansi_assopname[(int) CONVERT_EXPR] = ansi_assopname[(int) PLUS_EXPR];
589 ansi_opname[(int) LSHIFT_EXPR] = get_identifier ("__ls");
590 IDENTIFIER_OPNAME_P (ansi_opname[(int) LSHIFT_EXPR]) = 1;
591 ansi_assopname[(int) LSHIFT_EXPR] = get_identifier ("__als");
592 IDENTIFIER_OPNAME_P (ansi_assopname[(int) LSHIFT_EXPR]) = 1;
593 ansi_opname[(int) EQ_EXPR] = get_identifier ("__eq");
594 IDENTIFIER_OPNAME_P (ansi_opname[(int) EQ_EXPR]) = 1;
595 ansi_opname[(int) LT_EXPR] = get_identifier ("__lt");
596 IDENTIFIER_OPNAME_P (ansi_opname[(int) LT_EXPR]) = 1;
597 ansi_opname[(int) LE_EXPR] = get_identifier ("__le");
598 IDENTIFIER_OPNAME_P (ansi_opname[(int) LE_EXPR]) = 1;
599 ansi_opname[(int) BIT_AND_EXPR] = get_identifier ("__ad");
600 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_AND_EXPR]) = 1;
601 ansi_assopname[(int) BIT_AND_EXPR] = get_identifier ("__aad");
602 IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_AND_EXPR]) = 1;
603 ansi_opname[(int) ADDR_EXPR] = ansi_opname[(int) BIT_AND_EXPR];
604 ansi_assopname[(int) ADDR_EXPR] = ansi_assopname[(int) BIT_AND_EXPR];
605 ansi_opname[(int) BIT_XOR_EXPR] = get_identifier ("__er");
606 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_XOR_EXPR]) = 1;
607 ansi_assopname[(int) BIT_XOR_EXPR] = get_identifier ("__aer");
608 IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_XOR_EXPR]) = 1;
609 ansi_opname[(int) TRUTH_ORIF_EXPR] = get_identifier ("__oo");
610 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_ORIF_EXPR]) = 1;
611 ansi_opname[(int) BIT_NOT_EXPR] = get_identifier ("__co");
612 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_NOT_EXPR]) = 1;
613 ansi_opname[(int) PREDECREMENT_EXPR] = get_identifier ("__mm");
614 IDENTIFIER_OPNAME_P (ansi_opname[(int) PREDECREMENT_EXPR]) = 1;
615 ansi_opname[(int) POSTDECREMENT_EXPR] = ansi_opname[(int) PREDECREMENT_EXPR];
616 ansi_opname[(int) COMPONENT_REF] = get_identifier ("__rf");
617 IDENTIFIER_OPNAME_P (ansi_opname[(int) COMPONENT_REF]) = 1;
618 ansi_opname[(int) MEMBER_REF] = get_identifier ("__rm");
619 IDENTIFIER_OPNAME_P (ansi_opname[(int) MEMBER_REF]) = 1;
620 ansi_opname[(int) CALL_EXPR] = get_identifier ("__cl");
621 IDENTIFIER_OPNAME_P (ansi_opname[(int) CALL_EXPR]) = 1;
622 ansi_opname[(int) ARRAY_REF] = get_identifier ("__vc");
623 IDENTIFIER_OPNAME_P (ansi_opname[(int) ARRAY_REF]) = 1;
624 ansi_opname[(int) NEW_EXPR] = get_identifier ("__nw");
625 IDENTIFIER_OPNAME_P (ansi_opname[(int) NEW_EXPR]) = 1;
626 ansi_opname[(int) DELETE_EXPR] = get_identifier ("__dl");
627 IDENTIFIER_OPNAME_P (ansi_opname[(int) DELETE_EXPR]) = 1;
628 ansi_opname[(int) VEC_NEW_EXPR] = get_identifier ("__vn");
629 IDENTIFIER_OPNAME_P (ansi_opname[(int) VEC_NEW_EXPR]) = 1;
630 ansi_opname[(int) VEC_DELETE_EXPR] = get_identifier ("__vd");
631 IDENTIFIER_OPNAME_P (ansi_opname[(int) VEC_DELETE_EXPR]) = 1;
632 ansi_opname[(int) TYPE_EXPR] = get_identifier ("__op");
633 IDENTIFIER_OPNAME_P (ansi_opname[(int) TYPE_EXPR]) = 1;
635 /* This is not true: these operators are not defined in ANSI,
636 but we need them anyway. */
637 ansi_opname[(int) MIN_EXPR] = get_identifier ("__mn");
638 IDENTIFIER_OPNAME_P (ansi_opname[(int) MIN_EXPR]) = 1;
639 ansi_opname[(int) MAX_EXPR] = get_identifier ("__mx");
640 IDENTIFIER_OPNAME_P (ansi_opname[(int) MAX_EXPR]) = 1;
641 ansi_opname[(int) COND_EXPR] = get_identifier ("__cn");
642 IDENTIFIER_OPNAME_P (ansi_opname[(int) COND_EXPR]) = 1;
643 ansi_opname[(int) SIZEOF_EXPR] = get_identifier ("__sz");
644 IDENTIFIER_OPNAME_P (ansi_opname[(int) SIZEOF_EXPR]) = 1;
648 gcc_obstack_init (&inline_text_obstack);
649 inline_text_firstobj = (char *) obstack_alloc (&inline_text_obstack, 0);
651 /* Start it at 0, because check_newline is called at the very beginning
652 and will increment it to 1. */
654 input_filename = "<internal>";
655 current_function_decl = NULL;
658 token_buffer = (char *) xmalloc (maxtoken + 2);
660 ridpointers[(int) RID_INT] = get_identifier ("int");
661 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INT],
662 build_tree_list (NULL_TREE, ridpointers[(int) RID_INT]));
663 ridpointers[(int) RID_BOOL] = get_identifier ("bool");
664 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_BOOL],
665 build_tree_list (NULL_TREE, ridpointers[(int) RID_BOOL]));
666 ridpointers[(int) RID_CHAR] = get_identifier ("char");
667 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CHAR],
668 build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]));
669 ridpointers[(int) RID_VOID] = get_identifier ("void");
670 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOID],
671 build_tree_list (NULL_TREE, ridpointers[(int) RID_VOID]));
672 ridpointers[(int) RID_FLOAT] = get_identifier ("float");
673 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FLOAT],
674 build_tree_list (NULL_TREE, ridpointers[(int) RID_FLOAT]));
675 ridpointers[(int) RID_DOUBLE] = get_identifier ("double");
676 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_DOUBLE],
677 build_tree_list (NULL_TREE, ridpointers[(int) RID_DOUBLE]));
678 ridpointers[(int) RID_SHORT] = get_identifier ("short");
679 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SHORT],
680 build_tree_list (NULL_TREE, ridpointers[(int) RID_SHORT]));
681 ridpointers[(int) RID_LONG] = get_identifier ("long");
682 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_LONG],
683 build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]));
684 ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned");
685 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_UNSIGNED],
686 build_tree_list (NULL_TREE, ridpointers[(int) RID_UNSIGNED]));
687 ridpointers[(int) RID_SIGNED] = get_identifier ("signed");
688 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SIGNED],
689 build_tree_list (NULL_TREE, ridpointers[(int) RID_SIGNED]));
690 ridpointers[(int) RID_INLINE] = get_identifier ("inline");
691 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INLINE],
692 build_tree_list (NULL_TREE, ridpointers[(int) RID_INLINE]));
693 ridpointers[(int) RID_CONST] = get_identifier ("const");
694 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CONST],
695 build_tree_list (NULL_TREE, ridpointers[(int) RID_CONST]));
696 ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
697 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOLATILE],
698 build_tree_list (NULL_TREE, ridpointers[(int) RID_VOLATILE]));
699 ridpointers[(int) RID_AUTO] = get_identifier ("auto");
700 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_AUTO],
701 build_tree_list (NULL_TREE, ridpointers[(int) RID_AUTO]));
702 ridpointers[(int) RID_STATIC] = get_identifier ("static");
703 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_STATIC],
704 build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC]));
705 ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
706 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_EXTERN],
707 build_tree_list (NULL_TREE, ridpointers[(int) RID_EXTERN]));
708 ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
709 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_TYPEDEF],
710 build_tree_list (NULL_TREE, ridpointers[(int) RID_TYPEDEF]));
711 ridpointers[(int) RID_REGISTER] = get_identifier ("register");
712 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_REGISTER],
713 build_tree_list (NULL_TREE, ridpointers[(int) RID_REGISTER]));
714 ridpointers[(int) RID_COMPLEX] = get_identifier ("__complex");
715 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_COMPLEX],
716 build_tree_list (NULL_TREE, ridpointers[(int) RID_COMPLEX]));
718 /* C++ extensions. These are probably not correctly named. */
719 ridpointers[(int) RID_WCHAR] = get_identifier ("__wchar_t");
720 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_WCHAR],
721 build_tree_list (NULL_TREE, ridpointers[(int) RID_WCHAR]));
722 class_type_node = build_int_2 (class_type, 0);
723 TREE_TYPE (class_type_node) = class_type_node;
724 ridpointers[(int) RID_CLASS] = class_type_node;
726 record_type_node = build_int_2 (record_type, 0);
727 TREE_TYPE (record_type_node) = record_type_node;
728 ridpointers[(int) RID_RECORD] = record_type_node;
730 union_type_node = build_int_2 (union_type, 0);
731 TREE_TYPE (union_type_node) = union_type_node;
732 ridpointers[(int) RID_UNION] = union_type_node;
734 enum_type_node = build_int_2 (enum_type, 0);
735 TREE_TYPE (enum_type_node) = enum_type_node;
736 ridpointers[(int) RID_ENUM] = enum_type_node;
738 ridpointers[(int) RID_VIRTUAL] = get_identifier ("virtual");
739 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VIRTUAL],
740 build_tree_list (NULL_TREE, ridpointers[(int) RID_VIRTUAL]));
741 ridpointers[(int) RID_EXPLICIT] = get_identifier ("explicit");
742 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_EXPLICIT],
743 build_tree_list (NULL_TREE, ridpointers[(int) RID_EXPLICIT]));
744 ridpointers[(int) RID_FRIEND] = get_identifier ("friend");
745 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FRIEND],
746 build_tree_list (NULL_TREE, ridpointers[(int) RID_FRIEND]));
748 ridpointers[(int) RID_PUBLIC] = get_identifier ("public");
749 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_PUBLIC],
750 build_tree_list (NULL_TREE, ridpointers[(int) RID_PUBLIC]));
751 ridpointers[(int) RID_PRIVATE] = get_identifier ("private");
752 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_PRIVATE],
753 build_tree_list (NULL_TREE, ridpointers[(int) RID_PRIVATE]));
754 ridpointers[(int) RID_PROTECTED] = get_identifier ("protected");
755 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_PROTECTED],
756 build_tree_list (NULL_TREE, ridpointers[(int) RID_PROTECTED]));
757 ridpointers[(int) RID_TEMPLATE] = get_identifier ("template");
758 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_TEMPLATE],
759 build_tree_list (NULL_TREE, ridpointers[(int) RID_TEMPLATE]));
760 /* This is for ANSI C++. */
761 ridpointers[(int) RID_MUTABLE] = get_identifier ("mutable");
762 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_MUTABLE],
763 build_tree_list (NULL_TREE, ridpointers[(int) RID_MUTABLE]));
765 /* Signature handling extensions. */
766 signature_type_node = build_int_2 (signature_type, 0);
767 TREE_TYPE (signature_type_node) = signature_type_node;
768 ridpointers[(int) RID_SIGNATURE] = signature_type_node;
770 null_node = build_int_2 (0, 0);
771 ridpointers[RID_NULL] = null_node;
773 opname_tab[(int) COMPONENT_REF] = "->";
774 opname_tab[(int) MEMBER_REF] = "->*";
775 opname_tab[(int) INDIRECT_REF] = "*";
776 opname_tab[(int) ARRAY_REF] = "[]";
777 opname_tab[(int) MODIFY_EXPR] = "=";
778 opname_tab[(int) NEW_EXPR] = "new";
779 opname_tab[(int) DELETE_EXPR] = "delete";
780 opname_tab[(int) VEC_NEW_EXPR] = "new []";
781 opname_tab[(int) VEC_DELETE_EXPR] = "delete []";
782 opname_tab[(int) COND_EXPR] = "?:";
783 opname_tab[(int) CALL_EXPR] = "()";
784 opname_tab[(int) PLUS_EXPR] = "+";
785 opname_tab[(int) MINUS_EXPR] = "-";
786 opname_tab[(int) MULT_EXPR] = "*";
787 opname_tab[(int) TRUNC_DIV_EXPR] = "/";
788 opname_tab[(int) CEIL_DIV_EXPR] = "(ceiling /)";
789 opname_tab[(int) FLOOR_DIV_EXPR] = "(floor /)";
790 opname_tab[(int) ROUND_DIV_EXPR] = "(round /)";
791 opname_tab[(int) TRUNC_MOD_EXPR] = "%";
792 opname_tab[(int) CEIL_MOD_EXPR] = "(ceiling %)";
793 opname_tab[(int) FLOOR_MOD_EXPR] = "(floor %)";
794 opname_tab[(int) ROUND_MOD_EXPR] = "(round %)";
795 opname_tab[(int) NEGATE_EXPR] = "-";
796 opname_tab[(int) MIN_EXPR] = "<?";
797 opname_tab[(int) MAX_EXPR] = ">?";
798 opname_tab[(int) ABS_EXPR] = "abs";
799 opname_tab[(int) FFS_EXPR] = "ffs";
800 opname_tab[(int) LSHIFT_EXPR] = "<<";
801 opname_tab[(int) RSHIFT_EXPR] = ">>";
802 opname_tab[(int) BIT_IOR_EXPR] = "|";
803 opname_tab[(int) BIT_XOR_EXPR] = "^";
804 opname_tab[(int) BIT_AND_EXPR] = "&";
805 opname_tab[(int) BIT_ANDTC_EXPR] = "&~";
806 opname_tab[(int) BIT_NOT_EXPR] = "~";
807 opname_tab[(int) TRUTH_ANDIF_EXPR] = "&&";
808 opname_tab[(int) TRUTH_ORIF_EXPR] = "||";
809 opname_tab[(int) TRUTH_AND_EXPR] = "strict &&";
810 opname_tab[(int) TRUTH_OR_EXPR] = "strict ||";
811 opname_tab[(int) TRUTH_NOT_EXPR] = "!";
812 opname_tab[(int) LT_EXPR] = "<";
813 opname_tab[(int) LE_EXPR] = "<=";
814 opname_tab[(int) GT_EXPR] = ">";
815 opname_tab[(int) GE_EXPR] = ">=";
816 opname_tab[(int) EQ_EXPR] = "==";
817 opname_tab[(int) NE_EXPR] = "!=";
818 opname_tab[(int) IN_EXPR] = "in";
819 opname_tab[(int) RANGE_EXPR] = "...";
820 opname_tab[(int) CONVERT_EXPR] = "+";
821 opname_tab[(int) ADDR_EXPR] = "&";
822 opname_tab[(int) PREDECREMENT_EXPR] = "--";
823 opname_tab[(int) PREINCREMENT_EXPR] = "++";
824 opname_tab[(int) POSTDECREMENT_EXPR] = "--";
825 opname_tab[(int) POSTINCREMENT_EXPR] = "++";
826 opname_tab[(int) COMPOUND_EXPR] = ",";
828 assignop_tab[(int) NOP_EXPR] = "=";
829 assignop_tab[(int) PLUS_EXPR] = "+=";
830 assignop_tab[(int) CONVERT_EXPR] = "+=";
831 assignop_tab[(int) MINUS_EXPR] = "-=";
832 assignop_tab[(int) NEGATE_EXPR] = "-=";
833 assignop_tab[(int) MULT_EXPR] = "*=";
834 assignop_tab[(int) INDIRECT_REF] = "*=";
835 assignop_tab[(int) TRUNC_DIV_EXPR] = "/=";
836 assignop_tab[(int) EXACT_DIV_EXPR] = "(exact /=)";
837 assignop_tab[(int) CEIL_DIV_EXPR] = "(ceiling /=)";
838 assignop_tab[(int) FLOOR_DIV_EXPR] = "(floor /=)";
839 assignop_tab[(int) ROUND_DIV_EXPR] = "(round /=)";
840 assignop_tab[(int) TRUNC_MOD_EXPR] = "%=";
841 assignop_tab[(int) CEIL_MOD_EXPR] = "(ceiling %=)";
842 assignop_tab[(int) FLOOR_MOD_EXPR] = "(floor %=)";
843 assignop_tab[(int) ROUND_MOD_EXPR] = "(round %=)";
844 assignop_tab[(int) MIN_EXPR] = "<?=";
845 assignop_tab[(int) MAX_EXPR] = ">?=";
846 assignop_tab[(int) LSHIFT_EXPR] = "<<=";
847 assignop_tab[(int) RSHIFT_EXPR] = ">>=";
848 assignop_tab[(int) BIT_IOR_EXPR] = "|=";
849 assignop_tab[(int) BIT_XOR_EXPR] = "^=";
850 assignop_tab[(int) BIT_AND_EXPR] = "&=";
851 assignop_tab[(int) ADDR_EXPR] = "&=";
853 init_filename_times ();
855 /* Some options inhibit certain reserved words.
856 Clear those words out of the hash table so they won't be recognized. */
857 #define UNSET_RESERVED_WORD(STRING) \
858 do { struct resword *s = is_reserved_word (STRING, sizeof (STRING) - 1); \
859 if (s) s->name = ""; } while (0)
862 /* let's parse things, and if they use it, then give them an error. */
863 if (!flag_exceptions)
865 UNSET_RESERVED_WORD ("throw");
866 UNSET_RESERVED_WORD ("try");
867 UNSET_RESERVED_WORD ("catch");
871 if (!flag_rtti || flag_no_gnu_keywords)
873 UNSET_RESERVED_WORD ("classof");
874 UNSET_RESERVED_WORD ("headof");
877 if (! flag_handle_signatures || flag_no_gnu_keywords)
879 /* Easiest way to not recognize signature
880 handling extensions... */
881 UNSET_RESERVED_WORD ("signature");
882 UNSET_RESERVED_WORD ("sigof");
884 if (flag_no_asm || flag_no_gnu_keywords)
885 UNSET_RESERVED_WORD ("typeof");
886 if (! flag_operator_names)
888 /* These are new ANSI keywords that may break code. */
889 UNSET_RESERVED_WORD ("and");
890 UNSET_RESERVED_WORD ("and_eq");
891 UNSET_RESERVED_WORD ("bitand");
892 UNSET_RESERVED_WORD ("bitor");
893 UNSET_RESERVED_WORD ("compl");
894 UNSET_RESERVED_WORD ("not");
895 UNSET_RESERVED_WORD ("not_eq");
896 UNSET_RESERVED_WORD ("or");
897 UNSET_RESERVED_WORD ("or_eq");
898 UNSET_RESERVED_WORD ("xor");
899 UNSET_RESERVED_WORD ("xor_eq");
902 token_count = init_cpp_parse ();
903 interface_unknown = 1;
912 cpp_finish (&parse_in);
919 reinit_parse_for_function ()
921 current_base_init_list = NULL_TREE;
922 current_member_init_list = NULL_TREE;
929 yyprint (file, yychar, yylval)
941 case IDENTIFIER_DEFN:
944 case TYPENAME_ELLIPSIS:
946 case PRE_PARSED_CLASS_DECL:
948 if (TREE_CODE (t) == TYPE_DECL || TREE_CODE (t) == TEMPLATE_DECL)
950 fprintf (file, " `%s'", IDENTIFIER_POINTER (DECL_NAME (t)));
953 my_friendly_assert (TREE_CODE (t) == IDENTIFIER_NODE, 224);
954 if (IDENTIFIER_POINTER (t))
955 fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
958 if (yylval.ttype == class_type_node)
959 fprintf (file, " `class'");
960 else if (yylval.ttype == record_type_node)
961 fprintf (file, " `struct'");
962 else if (yylval.ttype == union_type_node)
963 fprintf (file, " `union'");
964 else if (yylval.ttype == enum_type_node)
965 fprintf (file, " `enum'");
966 else if (yylval.ttype == signature_type_node)
967 fprintf (file, " `signature'");
969 my_friendly_abort (80);
974 #if defined(GATHER_STATISTICS) && defined(REDUCE_LENGTH)
975 static int *reduce_count;
981 #define REDUCE_LENGTH (sizeof (yyr2) / sizeof (yyr2[0]))
982 #define TOKEN_LENGTH (256 + sizeof (yytname) / sizeof (yytname[0]))
985 #ifdef GATHER_STATISTICS
991 reduce_count[yyn] += 1;
998 return reduce_count[*q] - reduce_count[*p];
1005 return token_count[*q] - token_count[*p];
1011 print_parse_statistics ()
1013 #ifdef GATHER_STATISTICS
1014 #ifdef REDUCE_LENGTH
1017 int maxlen = REDUCE_LENGTH;
1020 if (reduce_count[-1] == 0)
1023 if (TOKEN_LENGTH > REDUCE_LENGTH)
1024 maxlen = TOKEN_LENGTH;
1025 sorted = (unsigned *) alloca (sizeof (int) * maxlen);
1027 for (i = 0; i < TOKEN_LENGTH; i++)
1029 qsort (sorted, TOKEN_LENGTH, sizeof (int), token_cmp);
1030 for (i = 0; i < TOKEN_LENGTH; i++)
1032 int idx = sorted[i];
1033 if (token_count[idx] == 0)
1035 if (token_count[idx] < token_count[-1])
1037 fprintf (stderr, "token %d, `%s', count = %d\n",
1038 idx, yytname[YYTRANSLATE (idx)], token_count[idx]);
1040 fprintf (stderr, "\n");
1041 for (i = 0; i < REDUCE_LENGTH; i++)
1043 qsort (sorted, REDUCE_LENGTH, sizeof (int), reduce_cmp);
1044 for (i = 0; i < REDUCE_LENGTH; i++)
1046 int idx = sorted[i];
1047 if (reduce_count[idx] == 0)
1049 if (reduce_count[idx] < reduce_count[-1])
1051 fprintf (stderr, "rule %d, line %d, count = %d\n",
1052 idx, yyrline[idx], reduce_count[idx]);
1054 fprintf (stderr, "\n");
1060 /* Sets the value of the 'yydebug' variable to VALUE.
1061 This is a function so we don't have to have YYDEBUG defined
1062 in order to build the compiler. */
1072 warning ("YYDEBUG not defined.");
1077 /* Functions and data structures for #pragma interface.
1079 `#pragma implementation' means that the main file being compiled
1080 is considered to implement (provide) the classes that appear in
1081 its main body. I.e., if this is file "foo.cc", and class `bar'
1082 is defined in "foo.cc", then we say that "foo.cc implements bar".
1084 All main input files "implement" themselves automagically.
1086 `#pragma interface' means that unless this file (of the form "foo.h"
1087 is not presently being included by file "foo.cc", the
1088 CLASSTYPE_INTERFACE_ONLY bit gets set. The effect is that none
1089 of the vtables nor any of the inline functions defined in foo.h
1090 will ever be output.
1092 There are cases when we want to link files such as "defs.h" and
1093 "main.cc". In this case, we give "defs.h" a `#pragma interface',
1094 and "main.cc" has `#pragma implementation "defs.h"'. */
1099 struct impl_files *next;
1102 static struct impl_files *impl_file_chain;
1104 /* Helper function to load global variables with interface
1108 extract_interface_info ()
1112 if (flag_alt_external_templates)
1114 struct tinst_level *til = tinst_for_decl ();
1117 fileinfo = get_time_identifier (til->file);
1120 fileinfo = get_time_identifier (input_filename);
1121 fileinfo = IDENTIFIER_CLASS_VALUE (fileinfo);
1122 interface_only = TREE_INT_CST_LOW (fileinfo);
1123 interface_unknown = TREE_INT_CST_HIGH (fileinfo);
1126 /* Return nonzero if S is not considered part of an
1127 INTERFACE/IMPLEMENTATION pair. Otherwise, return 0. */
1130 interface_strcmp (s)
1133 /* Set the interface/implementation bits for this scope. */
1134 struct impl_files *ifiles;
1137 for (ifiles = impl_file_chain; ifiles; ifiles = ifiles->next)
1139 char *t1 = ifiles->filename;
1142 if (*s1 != *t1 || *s1 == 0)
1145 while (*s1 == *t1 && *s1 != 0)
1152 /* Don't get faked out by xxx.yyy.cc vs xxx.zzz.cc. */
1153 if (index (s1, '.') || index (t1, '.'))
1156 if (*s1 == '\0' || s1[-1] != '.' || t1[-1] != '.')
1168 set_typedecl_interface_info (prev, vars)
1171 tree id = get_time_identifier (DECL_SOURCE_FILE (vars));
1172 tree fileinfo = IDENTIFIER_CLASS_VALUE (id);
1173 tree type = TREE_TYPE (vars);
1175 CLASSTYPE_INTERFACE_ONLY (type) = TREE_INT_CST_LOW (fileinfo)
1176 = interface_strcmp (file_name_nondirectory (DECL_SOURCE_FILE (vars)));
1180 set_vardecl_interface_info (prev, vars)
1183 tree type = DECL_CONTEXT (vars);
1185 if (CLASSTYPE_INTERFACE_KNOWN (type))
1187 if (CLASSTYPE_INTERFACE_ONLY (type))
1188 set_typedecl_interface_info (prev, TYPE_MAIN_DECL (type));
1190 CLASSTYPE_VTABLE_NEEDS_WRITING (type) = 1;
1191 DECL_EXTERNAL (vars) = CLASSTYPE_INTERFACE_ONLY (type);
1192 TREE_PUBLIC (vars) = 1;
1198 /* Called from the top level: if there are any pending inlines to
1199 do, set up to process them now. This function sets up the first function
1200 to be parsed; after it has been, the rule for fndef in parse.y will
1201 call process_next_inline to start working on the next one. */
1204 do_pending_inlines ()
1206 struct pending_inline *t;
1209 /* Oops, we're still dealing with the last batch. */
1210 if (yychar == PRE_PARSED_FUNCTION_DECL)
1213 /* Reverse the pending inline functions, since
1214 they were cons'd instead of appended. */
1216 struct pending_inline *prev = 0, *tail;
1217 t = pending_inlines;
1218 pending_inlines = 0;
1233 /* Now start processing the first inline function. */
1234 context = hack_decl_function_context (t->fndecl);
1236 push_cp_function_context (context);
1237 maybe_begin_member_template_processing (t->fndecl);
1240 feed_input (t->buf, t->len);
1243 if (input_filename != t->filename)
1245 input_filename = t->filename;
1246 /* Get interface/implementation back in sync. */
1247 extract_interface_info ();
1250 input_filename = t->filename;
1251 interface_unknown = t->interface == 1;
1252 interface_only = t->interface == 0;
1254 yychar = PRE_PARSED_FUNCTION_DECL;
1256 /* Pass back a handle on the rest of the inline functions, so that they
1257 can be processed later. */
1258 yylval.ttype = build_tree_list ((tree) t, t->fndecl);
1259 DECL_PENDING_INLINE_INFO (t->fndecl) = 0;
1262 static int nextchar = -1;
1264 /* Called from the fndecl rule in the parser when the function just parsed
1265 was declared using a PRE_PARSED_FUNCTION_DECL (i.e. came from
1266 do_pending_inlines). */
1269 process_next_inline (t)
1273 struct pending_inline *i = (struct pending_inline *) TREE_PURPOSE (t);
1274 context = hack_decl_function_context (i->fndecl);
1275 maybe_end_member_template_processing (i->fndecl);
1277 pop_cp_function_context (context);
1279 if (yychar == YYEMPTY)
1281 if (yychar != END_OF_SAVED_INPUT)
1283 error ("parse error at end of saved function text");
1285 /* restore_pending_input will abort unless yychar is either
1286 END_OF_SAVED_INPUT or YYEMPTY; since we already know we're
1287 hosed, feed back YYEMPTY. We also need to discard nextchar,
1288 since that may have gotten set as well. */
1293 if (i && i->fndecl != NULL_TREE)
1295 context = hack_decl_function_context (i->fndecl);
1297 push_cp_function_context (context);
1298 maybe_begin_member_template_processing (i->fndecl);
1299 feed_input (i->buf, i->len);
1301 input_filename = i->filename;
1302 yychar = PRE_PARSED_FUNCTION_DECL;
1303 yylval.ttype = build_tree_list ((tree) i, i->fndecl);
1304 DECL_PENDING_INLINE_INFO (i->fndecl) = 0;
1308 interface_unknown = i->interface == 1;
1309 interface_only = i->interface == 0;
1312 extract_interface_info ();
1315 /* Since inline methods can refer to text which has not yet been seen,
1316 we store the text of the method in a structure which is placed in the
1317 DECL_PENDING_INLINE_INFO field of the FUNCTION_DECL.
1318 After parsing the body of the class definition, the FUNCTION_DECL's are
1319 scanned to see which ones have this field set. Those are then digested
1322 This function's FUNCTION_DECL will have a bit set in its common so
1323 that we know to watch out for it. */
1326 consume_string (this_obstack, matching_char)
1327 register struct obstack *this_obstack;
1331 int starting_lineno = lineno;
1337 int save_lineno = lineno;
1338 lineno = starting_lineno;
1339 if (matching_char == '"')
1340 error ("end of file encountered inside string constant");
1342 error ("end of file encountered inside character constant");
1343 lineno = save_lineno;
1348 obstack_1grow (this_obstack, c);
1350 obstack_1grow (this_obstack, c);
1352 /* Make sure we continue the loop */
1359 pedwarn ("ANSI C++ forbids newline in string constant");
1362 obstack_1grow (this_obstack, c);
1364 while (c != matching_char);
1367 static int nextyychar = YYEMPTY;
1368 static YYSTYPE nextyylval;
1370 struct pending_input {
1371 int nextchar, yychar, nextyychar, eof;
1372 YYSTYPE yylval, nextyylval;
1373 struct obstack token_obstack;
1377 struct pending_input *
1378 save_pending_input ()
1380 struct pending_input *p;
1381 p = (struct pending_input *) xmalloc (sizeof (struct pending_input));
1382 p->nextchar = nextchar;
1384 p->nextyychar = nextyychar;
1386 p->nextyylval = nextyylval;
1387 p->eof = end_of_file;
1388 yychar = nextyychar = YYEMPTY;
1390 p->first_token = first_token;
1391 p->token_obstack = token_obstack;
1394 gcc_obstack_init (&token_obstack);
1400 restore_pending_input (p)
1401 struct pending_input *p;
1403 my_friendly_assert (nextchar == -1, 229);
1404 nextchar = p->nextchar;
1405 my_friendly_assert (yychar == YYEMPTY || yychar == END_OF_SAVED_INPUT, 230);
1407 my_friendly_assert (nextyychar == YYEMPTY, 231);
1408 nextyychar = p->nextyychar;
1410 nextyylval = p->nextyylval;
1411 first_token = p->first_token;
1412 obstack_free (&token_obstack, (char *) 0);
1413 token_obstack = p->token_obstack;
1414 end_of_file = p->eof;
1418 /* Unget character CH from the input stream.
1419 If RESCAN is non-zero, then we want to `see' this
1420 character as the next input token. */
1423 yyungetc (ch, rescan)
1427 /* Unget a character from the input stream. */
1428 if (yychar == YYEMPTY || rescan == 0)
1431 put_back (nextchar);
1436 my_friendly_assert (nextyychar == YYEMPTY, 232);
1437 nextyychar = yychar;
1438 nextyylval = yylval;
1444 clear_inline_text_obstack ()
1446 obstack_free (&inline_text_obstack, inline_text_firstobj);
1449 /* This function stores away the text for an inline function that should
1450 be processed later. It decides how much later, and may need to move
1451 the info between obstacks; therefore, the caller should not refer to
1452 the T parameter after calling this function. */
1455 store_pending_inline (decl, t)
1457 struct pending_inline *t;
1460 DECL_PENDING_INLINE_INFO (decl) = t;
1462 /* Because we use obstacks, we must process these in precise order. */
1463 t->next = pending_inlines;
1464 pending_inlines = t;
1468 reinit_parse_for_method (yychar, decl)
1473 int starting_lineno = lineno;
1474 char *starting_filename = input_filename;
1476 reinit_parse_for_block (yychar, &inline_text_obstack);
1478 len = obstack_object_size (&inline_text_obstack);
1479 current_base_init_list = NULL_TREE;
1480 current_member_init_list = NULL_TREE;
1481 if (decl == void_type_node
1482 || (current_class_type && TYPE_REDEFINED (current_class_type)))
1484 /* Happens when we get two declarations of the same
1485 function in the same scope. */
1486 char *buf = obstack_finish (&inline_text_obstack);
1487 obstack_free (&inline_text_obstack, buf);
1492 struct pending_inline *t;
1493 char *buf = obstack_finish (&inline_text_obstack);
1495 t = (struct pending_inline *) obstack_alloc (&inline_text_obstack,
1496 sizeof (struct pending_inline));
1497 t->lineno = starting_lineno;
1498 t->filename = starting_filename;
1505 if (interface_unknown && processing_template_defn && flag_external_templates && ! DECL_IN_SYSTEM_HEADER (decl))
1506 warn_if_unknown_interface (decl);
1508 t->interface = (interface_unknown ? 1 : (interface_only ? 0 : 2));
1509 store_pending_inline (decl, t);
1513 /* Consume a block -- actually, a method beginning
1514 with `:' or `{' -- and save it away on the specified obstack. */
1517 reinit_parse_for_block (pyychar, obstackp)
1519 struct obstack *obstackp;
1523 int starting_lineno = lineno;
1524 char *starting_filename = input_filename;
1526 int look_for_semicolon = 0;
1527 int look_for_lbrac = 0;
1530 obstack_1grow (obstackp, '{');
1531 else if (pyychar == '=')
1532 look_for_semicolon = 1;
1533 else if (pyychar == ':')
1535 obstack_1grow (obstackp, pyychar);
1539 else if (pyychar == RETURN)
1541 obstack_grow (obstackp, "return", 6);
1545 else if (pyychar == TRY)
1547 obstack_grow (obstackp, "try", 3);
1553 yyerror ("parse error in method specification");
1554 obstack_1grow (obstackp, '{');
1557 if (nextchar != EOF)
1567 int this_lineno = lineno;
1569 c = skip_white_space (c);
1571 /* Don't lose our cool if there are lots of comments. */
1572 if (lineno == this_lineno + 1)
1573 obstack_1grow (obstackp, '\n');
1574 else if (lineno == this_lineno)
1576 else if (lineno - this_lineno < 10)
1579 for (i = lineno - this_lineno; i > 0; i--)
1580 obstack_1grow (obstackp, '\n');
1585 sprintf (buf, "\n# %d \"", lineno);
1587 obstack_grow (obstackp, buf, len);
1589 len = strlen (input_filename);
1590 obstack_grow (obstackp, input_filename, len);
1591 obstack_1grow (obstackp, '\"');
1592 obstack_1grow (obstackp, '\n');
1595 while (c > ' ') /* ASCII dependent... */
1597 obstack_1grow (obstackp, c);
1606 if (blev == 0 && !look_for_semicolon)
1610 if (peekyylex () == CATCH)
1613 obstack_grow (obstackp, " catch ", 7);
1630 /* Don't act on the next character...e.g, doing an escaped
1635 error_with_file_and_line (starting_filename,
1637 "end of file read inside definition");
1640 obstack_1grow (obstackp, c);
1643 consume_string (obstackp, c);
1645 consume_string (obstackp, c);
1650 error ("function body for constructor missing");
1651 obstack_1grow (obstackp, '{');
1652 obstack_1grow (obstackp, '}');
1656 else if (look_for_semicolon && blev == 0)
1664 error_with_file_and_line (starting_filename,
1666 "end of file read inside definition");
1671 obstack_1grow (obstackp, c);
1676 obstack_1grow (obstackp, '\0');
1679 /* Consume a no-commas expression -- actually, a default argument -- and
1680 save it away on the specified obstack. */
1683 reinit_parse_for_expr (obstackp)
1684 struct obstack *obstackp;
1687 int starting_lineno = lineno;
1688 char *starting_filename = input_filename;
1692 if (nextchar != EOF)
1702 int this_lineno = lineno;
1704 c = skip_white_space (c);
1706 /* Don't lose our cool if there are lots of comments. */
1707 if (lineno == this_lineno + 1)
1708 obstack_1grow (obstackp, '\n');
1709 else if (lineno == this_lineno)
1711 else if (lineno - this_lineno < 10)
1714 for (i = lineno - this_lineno; i > 0; --i)
1715 obstack_1grow (obstackp, '\n');
1720 sprintf (buf, "\n# %d \"", lineno);
1722 obstack_grow (obstackp, buf, len);
1724 len = strlen (input_filename);
1725 obstack_grow (obstackp, input_filename, len);
1726 obstack_1grow (obstackp, '\"');
1727 obstack_1grow (obstackp, '\n');
1730 while (c > ' ') /* ASCII dependent... */
1732 if (plev <= 0 && (c == ')' || c == ','))
1737 obstack_1grow (obstackp, c);
1738 if (c == '(' || c == '[')
1740 else if (c == ']' || c == ')')
1744 /* Don't act on the next character...e.g, doing an escaped
1749 error_with_file_and_line (starting_filename,
1751 "end of file read inside definition");
1754 obstack_1grow (obstackp, c);
1757 consume_string (obstackp, c);
1759 consume_string (obstackp, c);
1765 error_with_file_and_line (starting_filename,
1767 "end of file read inside definition");
1772 obstack_1grow (obstackp, c);
1777 obstack_1grow (obstackp, '\0');
1780 int do_snarf_defarg;
1782 /* Decide whether the default argument we are about to see should be
1783 gobbled up as text for later parsing. */
1786 maybe_snarf_defarg ()
1788 if (current_class_type && TYPE_BEING_DEFINED (current_class_type))
1789 do_snarf_defarg = 1;
1792 /* When we see a default argument in a method declaration, we snarf it as
1793 text using snarf_defarg. When we get up to namespace scope, we then go
1794 through and parse all of them using do_pending_defargs. Since yacc
1795 parsers are not reentrant, we retain defargs state in these two
1796 variables so that subsequent calls to do_pending_defargs can resume
1797 where the previous call left off. */
1809 reinit_parse_for_expr (&inline_text_obstack);
1810 len = obstack_object_size (&inline_text_obstack);
1811 buf = obstack_finish (&inline_text_obstack);
1813 push_obstacks (&inline_text_obstack, &inline_text_obstack);
1814 arg = make_node (DEFAULT_ARG);
1815 DEFARG_LENGTH (arg) = len - 1;
1816 DEFARG_POINTER (arg) = buf;
1822 /* Called from grokfndecl to note a function decl with unparsed default
1823 arguments for later processing. Also called from grokdeclarator
1824 for function types with unparsed defargs; the call from grokfndecl
1825 will always come second, so we can overwrite the entry from the type. */
1828 add_defarg_fn (decl)
1831 if (TREE_CODE (decl) == FUNCTION_DECL)
1832 TREE_VALUE (defarg_fns) = decl;
1835 push_obstacks (&inline_text_obstack, &inline_text_obstack);
1836 defarg_fns = tree_cons (current_class_type, decl, defarg_fns);
1841 /* Helper for do_pending_defargs. Starts the parsing of a default arg. */
1847 tree d = TREE_PURPOSE (p);
1848 feed_input (DEFARG_POINTER (d), DEFARG_LENGTH (d));
1849 if (TREE_CODE (f) == FUNCTION_DECL)
1851 lineno = DECL_SOURCE_LINE (f);
1852 input_filename = DECL_SOURCE_FILE (f);
1854 yychar = DEFARG_MARKER;
1858 /* Helper for do_pending_defargs. Ends the parsing of a default arg. */
1863 if (yychar == YYEMPTY)
1865 if (yychar != END_OF_SAVED_INPUT)
1867 error ("parse error at end of saved function text");
1869 /* restore_pending_input will abort unless yychar is either
1870 END_OF_SAVED_INPUT or YYEMPTY; since we already know we're
1871 hosed, feed back YYEMPTY. We also need to discard nextchar,
1872 since that may have gotten set as well. */
1879 /* Main function for deferred parsing of default arguments. Called from
1883 do_pending_defargs ()
1888 for (; defarg_fns; defarg_fns = TREE_CHAIN (defarg_fns))
1890 tree defarg_fn = TREE_VALUE (defarg_fns);
1891 if (defarg_parm == NULL_TREE)
1893 push_nested_class (TREE_PURPOSE (defarg_fns), 1);
1895 if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
1896 maybe_begin_member_template_processing (defarg_fn);
1898 if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
1902 for (p = DECL_ARGUMENTS (defarg_fn); p; p = TREE_CHAIN (p))
1903 pushdecl (copy_node (p));
1905 defarg_parm = TYPE_ARG_TYPES (TREE_TYPE (defarg_fn));
1908 defarg_parm = TYPE_ARG_TYPES (defarg_fn);
1911 defarg_parm = TREE_CHAIN (defarg_parm);
1913 for (; defarg_parm; defarg_parm = TREE_CHAIN (defarg_parm))
1914 if (TREE_PURPOSE (defarg_parm)
1915 && TREE_CODE (TREE_PURPOSE (defarg_parm)) == DEFAULT_ARG)
1917 feed_defarg (defarg_fn, defarg_parm);
1919 /* Return to the parser, which will process this defarg
1920 and call us again. */
1924 if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
1925 maybe_end_member_template_processing (defarg_fn);
1927 pop_nested_class (1);
1931 /* Build a default function named NAME for type TYPE.
1932 KIND says what to build.
1934 When KIND == 0, build default destructor.
1935 When KIND == 1, build virtual destructor.
1936 When KIND == 2, build default constructor.
1937 When KIND == 3, build default X(const X&) constructor.
1938 When KIND == 4, build default X(X&) constructor.
1939 When KIND == 5, build default operator = (const X&).
1940 When KIND == 6, build default operator = (X&). */
1943 cons_up_default_function (type, full_name, kind)
1944 tree type, full_name;
1947 extern tree void_list_node;
1948 tree declspecs = NULL_TREE;
1949 tree fn, args = NULL_TREE;
1952 tree name = constructor_name (full_name);
1958 declspecs = build_decl_list (NULL_TREE, ridpointers [(int) RID_VIRTUAL]);
1959 /* Fall through... */
1961 name = build_parse_node (BIT_NOT_EXPR, name);
1962 args = void_list_node;
1966 /* Default constructor. */
1967 args = void_list_node;
1971 type = build_type_variant (type, 1, 0);
1972 /* Fall through... */
1974 /* According to ARM $12.8, the default copy ctor will be declared, but
1975 not defined, unless it's needed. */
1976 argtype = build_reference_type (type);
1977 args = tree_cons (NULL_TREE,
1978 build_tree_list (hash_tree_chain (argtype, NULL_TREE),
1979 get_identifier ("_ctor_arg")),
1986 declspecs = build_decl_list (NULL_TREE, type);
1989 type = build_type_variant (type, 1, 0);
1991 name = ansi_opname [(int) MODIFY_EXPR];
1993 argtype = build_reference_type (type);
1994 args = tree_cons (NULL_TREE,
1995 build_tree_list (hash_tree_chain (argtype, NULL_TREE),
1996 get_identifier ("_ctor_arg")),
2001 my_friendly_abort (59);
2004 declspecs = decl_tree_cons (NULL_TREE, ridpointers [(int) RID_INLINE],
2007 TREE_PARMLIST (args) = 1;
2010 tree declarator = make_call_declarator (name, args, NULL_TREE, NULL_TREE);
2012 declarator = build_parse_node (ADDR_EXPR, declarator);
2014 fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE, NULL_TREE);
2017 if (fn == void_type_node)
2021 SET_DECL_ARTIFICIAL (TREE_CHAIN (DECL_ARGUMENTS (fn)));
2024 if (processing_template_defn)
2026 SET_DECL_IMPLICIT_INSTANTIATION (fn);
2027 repo_template_used (fn);
2032 if (CLASSTYPE_INTERFACE_KNOWN (type))
2034 DECL_INTERFACE_KNOWN (fn) = 1;
2035 DECL_NOT_REALLY_EXTERN (fn) = (!CLASSTYPE_INTERFACE_ONLY (type)
2036 && flag_implement_inlines);
2040 DECL_NOT_REALLY_EXTERN (fn) = 1;
2042 mark_inline_for_output (fn);
2044 #ifdef DEBUG_DEFAULT_FUNCTIONS
2045 { char *fn_type = NULL;
2049 case 0: fn_type = "default destructor"; break;
2050 case 1: fn_type = "virtual destructor"; break;
2051 case 2: fn_type = "default constructor"; break;
2052 case 3: fn_type = "default X(const X&)"; break;
2053 case 4: fn_type = "default X(X&)"; break;
2057 if (TREE_CODE (name) == BIT_NOT_EXPR)
2058 t = TREE_OPERAND (name, 0);
2059 fprintf (stderr, "[[[[ %s for %s:\n%s]]]]\n", fn_type,
2060 IDENTIFIER_POINTER (t), func_buf);
2063 #endif /* DEBUG_DEFAULT_FUNCTIONS */
2065 /* Show that this function was generated by the compiler. */
2066 SET_DECL_ARTIFICIAL (fn);
2071 /* Heuristic to tell whether the user is missing a semicolon
2072 after a struct or enum declaration. Emit an error message
2073 if we know the user has blown it. */
2076 check_for_missing_semicolon (type)
2084 && yychar != IDENTIFIER
2085 && yychar != TYPENAME
2086 && yychar != CV_QUALIFIER
2087 && yychar != SELFNAME)
2090 if (ANON_AGGRNAME_P (TYPE_IDENTIFIER (type)))
2091 error ("semicolon missing after %s declaration",
2092 TREE_CODE (type) == ENUMERAL_TYPE ? "enum" : "struct");
2094 cp_error ("semicolon missing after declaration of `%T'", type);
2095 shadow_tag (build_tree_list (0, type));
2097 /* Could probably also hack cases where class { ... } f (); appears. */
2102 note_got_semicolon (type)
2105 if (TREE_CODE_CLASS (TREE_CODE (type)) != 't')
2106 my_friendly_abort (60);
2107 if (IS_AGGR_TYPE (type))
2108 CLASSTYPE_GOT_SEMICOLON (type) = 1;
2112 note_list_got_semicolon (declspecs)
2117 for (link = declspecs; link; link = TREE_CHAIN (link))
2119 tree type = TREE_VALUE (link);
2120 if (TREE_CODE_CLASS (TREE_CODE (type)) == 't')
2121 note_got_semicolon (type);
2126 /* If C is not whitespace, return C.
2127 Otherwise skip whitespace and return first nonwhite char read. */
2130 skip_white_space (c)
2138 c = check_newline ();
2149 while (c == ' ' || c == '\t');
2157 error ("stray '\\' in program");
2169 /* Make the token buffer longer, preserving the data in it.
2170 P should point to just beyond the last valid character in the old buffer.
2171 The value we return is a pointer to the new buffer
2172 at a place corresponding to P. */
2175 extend_token_buffer (p)
2178 int offset = p - token_buffer;
2180 maxtoken = maxtoken * 2 + 10;
2181 token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2);
2183 return token_buffer + offset;
2187 get_last_nonwhite_on_line ()
2191 /* Is this the last nonwhite stuff on the line? */
2193 c = nextchar, nextchar = -1;
2197 while (c == ' ' || c == '\t')
2202 /* At the beginning of a line, increment the line number
2203 and process any #-directive on this line.
2204 If the line is a #-directive, read the entire line and return a newline.
2205 Otherwise, return the line's first non-whitespace character. */
2209 #ifdef HANDLE_SYSV_PRAGMA
2210 static int handle_sysv_pragma PROTO((FILE *, int));
2212 static int handle_cp_pragma PROTO((char *));
2220 /* Read first nonwhite char on the line. Do this before incrementing the
2221 line number, in case we're at the end of saved text. */
2225 while (c == ' ' || c == '\t');
2231 /* If not #, return it so caller will use it. */
2235 /* Don't read beyond this line. */
2238 /* Read first nonwhite char after the `#'. */
2242 while (c == ' ' || c == '\t');
2244 /* If a letter follows, then if the word here is `line', skip
2245 it and ignore it; otherwise, ignore the line, with an error
2246 if the word isn't `pragma'. */
2248 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
2258 token = real_yylex ();
2259 if (token == IDENTIFIER
2260 && TREE_CODE (yylval.ttype) == IDENTIFIER_NODE)
2262 /* If this is 1, we handled it; if it's -1, it was one we
2263 wanted but had something wrong with it. Only if it's
2264 0 was it not handled. */
2265 if (handle_cp_pragma (IDENTIFIER_POINTER (yylval.ttype)))
2268 else if (token == END_OF_LINE)
2271 #ifdef HANDLE_SYSV_PRAGMA
2272 if (handle_sysv_pragma (finput, token))
2275 #ifdef HANDLE_PRAGMA
2276 if (HANDLE_PRAGMA (finput, yylval.ttype))
2290 && ((c = getch ()) == ' ' || c == '\t'))
2292 debug_define (lineno, get_directive_line (finput));
2302 && ((c = getch ()) == ' ' || c == '\t'))
2304 debug_undef (lineno, get_directive_line (finput));
2313 && ((c = getch ()) == ' ' || c == '\t'))
2322 && ((c = getch ()) == ' ' || c == '\t'))
2324 #ifdef ASM_OUTPUT_IDENT
2325 extern FILE *asm_out_file;
2327 /* #ident. The pedantic warning is now in cccp.c. */
2329 /* Here we have just seen `#ident '.
2330 A string constant should follow. */
2332 token = real_yylex ();
2333 if (token == END_OF_LINE)
2336 || TREE_CODE (yylval.ttype) != STRING_CST)
2338 error ("invalid #ident");
2342 if (! flag_no_ident)
2344 #ifdef ASM_OUTPUT_IDENT
2345 ASM_OUTPUT_IDENT (asm_out_file,
2346 TREE_STRING_POINTER (yylval.ttype));
2350 /* Skip the rest of this line. */
2363 && ((c = getch ()) == ' ' || c == '\t'))
2365 /* Used to test incremental compilation. */
2366 sorry ("#pragma newworld");
2370 error ("undefined or invalid # directive");
2375 /* Here we have either `#line' or `# <nonletter>'.
2376 In either case, it should be a line number; a digit should follow. */
2378 while (c == ' ' || c == '\t')
2381 /* If the # is the only nonwhite char on the line,
2382 just ignore it. Check the new newline. */
2386 /* Something follows the #; read a token. */
2389 token = real_yylex ();
2391 if (token == CONSTANT
2392 && TREE_CODE (yylval.ttype) == INTEGER_CST)
2394 int old_lineno = lineno;
2395 enum { act_none, act_push, act_pop } action = act_none;
2396 int entering_system_header = 0;
2397 int entering_c_header = 0;
2399 /* subtract one, because it is the following line that
2400 gets the specified number */
2402 int l = TREE_INT_CST_LOW (yylval.ttype) - 1;
2403 c = get_last_nonwhite_on_line ();
2406 /* No more: store the line number and check following line. */
2412 /* More follows: it must be a string constant (filename). */
2414 /* Read the string constant, but don't treat \ as special. */
2415 ignore_escape_flag = 1;
2416 token = real_yylex ();
2417 ignore_escape_flag = 0;
2419 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
2421 error ("invalid #line");
2425 /* Changing files again. This means currently collected time
2426 is charged against header time, and body time starts back
2428 if (flag_detailed_statistics)
2430 int this_time = my_get_run_time ();
2431 tree time_identifier = get_time_identifier (TREE_STRING_POINTER (yylval.ttype));
2432 header_time += this_time - body_time;
2433 TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time))
2434 += this_time - body_time;
2435 this_filename_time = time_identifier;
2436 body_time = this_time;
2440 = (char *) permalloc (TREE_STRING_LENGTH (yylval.ttype) + 1);
2441 strcpy (input_filename, TREE_STRING_POINTER (yylval.ttype));
2443 GNU_xref_file (input_filename);
2445 if (main_input_filename == 0)
2447 struct impl_files *ifiles = impl_file_chain;
2451 while (ifiles->next)
2452 ifiles = ifiles->next;
2453 ifiles->filename = file_name_nondirectory (input_filename);
2456 main_input_filename = input_filename;
2457 if (write_virtuals == 3)
2458 walk_vtables (set_typedecl_interface_info, set_vardecl_interface_info);
2461 extract_interface_info ();
2463 c = get_last_nonwhite_on_line ();
2466 /* Update the name in the top element of input_file_stack. */
2467 if (input_file_stack)
2468 input_file_stack->name = input_filename;
2474 token = real_yylex ();
2476 /* `1' after file name means entering new file.
2477 `2' after file name means just left a file. */
2479 if (token == CONSTANT
2480 && TREE_CODE (yylval.ttype) == INTEGER_CST)
2482 if (TREE_INT_CST_LOW (yylval.ttype) == 1)
2484 else if (TREE_INT_CST_LOW (yylval.ttype) == 2)
2489 c = get_last_nonwhite_on_line ();
2493 token = real_yylex ();
2498 /* `3' after file name means this is a system header file. */
2500 if (token == CONSTANT
2501 && TREE_CODE (yylval.ttype) == INTEGER_CST
2502 && TREE_INT_CST_LOW (yylval.ttype) == 3)
2504 entering_system_header = 1;
2506 c = get_last_nonwhite_on_line ();
2510 token = real_yylex ();
2514 /* `4' after file name means this is a C header file. */
2516 if (token == CONSTANT
2517 && TREE_CODE (yylval.ttype) == INTEGER_CST
2518 && TREE_INT_CST_LOW (yylval.ttype) == 4)
2520 entering_c_header = 1;
2522 c = get_last_nonwhite_on_line ();
2526 token = real_yylex ();
2530 /* Do the actions implied by the preceding numbers. */
2532 if (action == act_push)
2534 /* Pushing to a new file. */
2535 struct file_stack *p;
2537 p = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2538 input_file_stack->line = old_lineno;
2539 p->next = input_file_stack;
2540 p->name = input_filename;
2541 input_file_stack = p;
2542 input_file_stack_tick++;
2543 debug_start_source_file (input_filename);
2544 in_system_header = entering_system_header;
2547 else if (entering_c_header)
2550 ++pending_lang_change;
2553 else if (action == act_pop)
2555 /* Popping out of a file. */
2556 if (input_file_stack->next)
2558 struct file_stack *p;
2560 if (c_header_level && --c_header_level == 0)
2562 if (entering_c_header)
2563 warning ("badly nested C headers from preprocessor");
2564 --pending_lang_change;
2566 in_system_header = entering_system_header;
2568 p = input_file_stack;
2569 input_file_stack = p->next;
2571 input_file_stack_tick++;
2572 debug_end_source_file (input_file_stack->line);
2575 error ("#-lines for entering and leaving files don't match");
2578 in_system_header = entering_system_header;
2581 /* If NEXTCHAR is not end of line, we don't care what it is. */
2582 if (nextchar == EOF)
2586 error ("invalid #-line");
2588 /* skip the rest of this line. */
2593 while ((c = getch ()) != EOF && c != '\n');
2598 do_pending_lang_change ()
2600 for (; pending_lang_change > 0; --pending_lang_change)
2601 push_lang_context (lang_name_c);
2602 for (; pending_lang_change < 0; ++pending_lang_change)
2603 pop_lang_context ();
2607 #define isalnum(char) (char >= 'a' ? char <= 'z' : char >= '0' ? char <= '9' || (char >= 'A' && char <= 'Z') : 0)
2608 #define isdigit(char) (char >= '0' && char <= '9')
2613 #define ENDFILE -1 /* token that represents end-of-file */
2615 /* Read an escape sequence, returning its equivalent as a character,
2616 or store 1 in *ignore_ptr if it is backslash-newline. */
2619 readescape (ignore_ptr)
2622 register int c = getch ();
2624 register unsigned count;
2625 unsigned firstdig = 0;
2643 if (c >= 'a' && c <= 'f')
2644 code += c - 'a' + 10;
2645 if (c >= 'A' && c <= 'F')
2646 code += c - 'A' + 10;
2647 if (c >= '0' && c <= '9')
2649 if (code != 0 || count != 0)
2658 error ("\\x used with no following hex digits");
2659 else if (count == 0)
2660 /* Digits are all 0's. Ok. */
2662 else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node)
2664 && ((1 << (TYPE_PRECISION (integer_type_node) - (count - 1) * 4))
2666 pedwarn ("hex escape out of range");
2669 case '0': case '1': case '2': case '3': case '4':
2670 case '5': case '6': case '7':
2673 while ((c <= '7') && (c >= '0') && (count++ < 3))
2675 code = (code * 8) + (c - '0');
2681 case '\\': case '\'': case '"':
2690 return TARGET_NEWLINE;
2713 pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c);
2719 /* `\(', etc, are used at beginning of line to avoid confusing Emacs. */
2723 /* `\%' is used to prevent SCCS from getting confused. */
2726 pedwarn ("unknown escape sequence `\\%c'", c);
2729 if (c >= 040 && c < 0177)
2730 pedwarn ("unknown escape sequence `\\%c'", c);
2732 pedwarn ("unknown escape sequence: `\\' followed by char code 0x%x", c);
2736 /* Value is 1 (or 2) if we should try to make the next identifier look like
2737 a typename (when it may be a local variable or a class variable).
2738 Value is 0 if we treat this name in a default fashion. */
2739 int looking_for_typename = 0;
2745 identifier_type (decl)
2748 if (TREE_CODE (decl) == TEMPLATE_DECL)
2750 if (TREE_CODE (DECL_RESULT (decl)) == TYPE_DECL)
2752 else if (looking_for_template)
2755 if (looking_for_template && really_overloaded_fn (decl))
2758 for (t = TREE_VALUE (decl); t != NULL_TREE; t = DECL_CHAIN (t))
2759 if (DECL_FUNCTION_TEMPLATE_P (t))
2762 if (TREE_CODE (decl) == NAMESPACE_DECL)
2764 if (TREE_CODE (decl) != TYPE_DECL)
2766 if (((got_scope && TREE_TYPE (decl) == got_scope)
2767 || TREE_TYPE (decl) == current_class_type)
2768 && DECL_ARTIFICIAL (decl))
2776 looking_for_typename = 1;
2778 if ((yychar = yylex ()) < 0) yychar = 0;
2779 looking_for_typename = 0;
2780 if (yychar == IDENTIFIER)
2782 lastiddecl = lookup_name (yylval.ttype, -2);
2783 if (lastiddecl == 0)
2786 lastiddecl = IDENTIFIER_LABEL_VALUE (yylval.ttype);
2789 yychar = identifier_type (lastiddecl);
2794 do_identifier (token, parsing)
2795 register tree token;
2800 if (! parsing || IDENTIFIER_OPNAME_P (token))
2801 id = lookup_name (token, 0);
2805 if (parsing && yychar == YYEMPTY)
2807 /* Scope class declarations before global
2809 if (id == IDENTIFIER_NAMESPACE_VALUE (token)
2810 && current_class_type != 0
2811 && TYPE_SIZE (current_class_type) == 0)
2813 /* Could be from one of the base classes. */
2814 tree field = lookup_field (current_class_type, token, 1, 0);
2817 else if (field == error_mark_node)
2818 /* We have already generated the error message.
2819 But we still want to return this value. */
2820 id = lookup_field (current_class_type, token, 0, 0);
2821 else if (TREE_CODE (field) == VAR_DECL
2822 || TREE_CODE (field) == CONST_DECL
2823 || TREE_CODE (field) == TEMPLATE_DECL)
2825 else if (TREE_CODE (field) != FIELD_DECL)
2826 my_friendly_abort (61);
2829 cp_error ("invalid use of member `%D' from base class `%T'", field,
2830 DECL_FIELD_CONTEXT (field));
2831 id = error_mark_node;
2836 /* Remember that this name has been used in the class definition, as per
2838 if (id && current_class_type && parsing
2839 && TYPE_BEING_DEFINED (current_class_type)
2840 && ! IDENTIFIER_CLASS_VALUE (token)
2841 /* Avoid breaking if we get called for a default argument that
2842 refers to an overloaded method. Eventually this will not be
2843 necessary, since default arguments shouldn't be parsed until
2844 after the class is complete. (jason 3/12/97) */
2845 && TREE_CODE (id) != TREE_LIST)
2846 pushdecl_class_level (id);
2848 if (!id || id == error_mark_node)
2850 if (id == error_mark_node && current_class_type != NULL_TREE)
2852 id = lookup_nested_field (token, 1);
2853 /* In lookup_nested_field(), we marked this so we can gracefully
2854 leave this whole mess. */
2855 if (id && id != error_mark_node && TREE_TYPE (id) == error_mark_node)
2859 if (current_template_parms)
2860 return build_min_nt (LOOKUP_EXPR, token, NULL_TREE);
2861 else if (IDENTIFIER_OPNAME_P (token))
2863 if (token != ansi_opname[ERROR_MARK])
2864 cp_error ("`%D' not defined", token);
2865 id = error_mark_node;
2867 else if (parsing && (yychar == '(' || yychar == LEFT_RIGHT))
2869 id = implicitly_declare (token);
2871 else if (current_function_decl == 0)
2873 cp_error ("`%D' was not declared in this scope", token);
2874 id = error_mark_node;
2878 if (IDENTIFIER_NAMESPACE_VALUE (token) != error_mark_node
2879 || IDENTIFIER_ERROR_LOCUS (token) != current_function_decl)
2881 static int undeclared_variable_notice;
2883 cp_error ("`%D' undeclared (first use this function)", token);
2885 if (! undeclared_variable_notice)
2887 error ("(Each undeclared identifier is reported only once");
2888 error ("for each function it appears in.)");
2889 undeclared_variable_notice = 1;
2892 id = error_mark_node;
2893 /* Prevent repeated error messages. */
2894 IDENTIFIER_NAMESPACE_VALUE (token) = error_mark_node;
2895 SET_IDENTIFIER_ERROR_LOCUS (token, current_function_decl);
2899 if (TREE_CODE (id) == VAR_DECL && DECL_DEAD_FOR_LOCAL (id))
2901 tree shadowed = DECL_SHADOWED_FOR_VAR (id);
2902 while (shadowed != NULL_TREE && TREE_CODE (shadowed) == VAR_DECL
2903 && DECL_DEAD_FOR_LOCAL (shadowed))
2904 shadowed = DECL_SHADOWED_FOR_VAR (shadowed);
2906 shadowed = IDENTIFIER_NAMESPACE_VALUE (DECL_NAME (id));
2909 if (!DECL_ERROR_REPORTED (id))
2911 warning ("name lookup of `%s' changed",
2912 IDENTIFIER_POINTER (token));
2913 cp_warning_at (" matches this `%D' under current ANSI rules",
2915 cp_warning_at (" matches this `%D' under old rules", id);
2916 DECL_ERROR_REPORTED (id) = 1;
2920 else if (!DECL_ERROR_REPORTED (id))
2923 = "name lookup of `%s' changed for new ANSI `for' scoping";
2924 DECL_ERROR_REPORTED (id) = 1;
2925 if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (id)))
2927 error (msg, IDENTIFIER_POINTER (token));
2928 cp_error_at (" cannot use obsolete binding at `%D' because it has a destructor", id);
2929 id = error_mark_node;
2933 pedwarn (msg, IDENTIFIER_POINTER (token));
2934 cp_pedwarn_at (" using obsolete binding at `%D'", id);
2938 /* TREE_USED is set in `hack_identifier'. */
2939 if (TREE_CODE (id) == CONST_DECL)
2941 if (IDENTIFIER_CLASS_VALUE (token) == id)
2944 tree access = compute_access (TYPE_BINFO (current_class_type), id);
2945 if (access == access_private_node)
2946 cp_error ("enum `%D' is private", id);
2947 /* protected is OK, since it's an enum of `this'. */
2949 if (! processing_template_decl
2950 || (DECL_INITIAL (id)
2951 && TREE_CODE (DECL_INITIAL (id)) == TEMPLATE_PARM_INDEX))
2952 id = DECL_INITIAL (id);
2955 id = hack_identifier (id, token);
2957 if (current_template_parms)
2959 if (is_overloaded_fn (id))
2961 tree t = build_min (LOOKUP_EXPR, unknown_type_node,
2962 token, get_first_fn (id));
2963 if (id != IDENTIFIER_NAMESPACE_VALUE (token))
2964 TREE_OPERAND (t, 1) = error_mark_node;
2967 else if (! TREE_PERMANENT (id) || TREE_CODE (id) == PARM_DECL
2968 || TREE_CODE (id) == USING_DECL)
2969 id = build_min (LOOKUP_EXPR, TREE_TYPE (id), token, error_mark_node);
2970 /* else just use the decl */
2977 do_scoped_id (token, parsing)
2982 /* during parsing, this is ::name. Otherwise, it is black magic. */
2984 id = qualified_lookup_using_namespace (token, global_namespace);
2986 id = IDENTIFIER_GLOBAL_VALUE (token);
2987 if (parsing && yychar == YYEMPTY)
2991 if (processing_template_decl)
2993 id = build_min_nt (LOOKUP_EXPR, token, NULL_TREE);
2994 LOOKUP_EXPR_GLOBAL (id) = 1;
2997 if (parsing && (yychar == '(' || yychar == LEFT_RIGHT))
2998 id = implicitly_declare (token);
3001 if (IDENTIFIER_NAMESPACE_VALUE (token) != error_mark_node)
3002 error ("undeclared variable `%s' (first use here)",
3003 IDENTIFIER_POINTER (token));
3004 id = error_mark_node;
3005 /* Prevent repeated error messages. */
3006 IDENTIFIER_NAMESPACE_VALUE (token) = error_mark_node;
3011 if (TREE_CODE (id) == ADDR_EXPR)
3012 mark_used (TREE_OPERAND (id, 0));
3013 else if (TREE_CODE (id) != TREE_LIST)
3016 if (TREE_CODE (id) == CONST_DECL && ! processing_template_decl)
3018 /* XXX CHS - should we set TREE_USED of the constant? */
3019 id = DECL_INITIAL (id);
3020 /* This is to prevent an enum whose value is 0
3021 from being considered a null pointer constant. */
3022 id = build1 (NOP_EXPR, TREE_TYPE (id), id);
3023 TREE_CONSTANT (id) = 1;
3026 if (processing_template_decl)
3028 if (is_overloaded_fn (id))
3030 id = build_min (LOOKUP_EXPR, unknown_type_node,
3031 token, get_first_fn (id));
3032 LOOKUP_EXPR_GLOBAL (id) = 1;
3034 /* else just use the decl */
3036 return convert_from_reference (id);
3040 identifier_typedecl_value (node)
3044 type = IDENTIFIER_TYPE_VALUE (node);
3045 if (type == NULL_TREE)
3050 if (t && TREE_CODE (t) == TYPE_DECL && TREE_TYPE (t) == type) \
3053 do (IDENTIFIER_LOCAL_VALUE (node));
3054 do (IDENTIFIER_CLASS_VALUE (node));
3055 do (IDENTIFIER_NAMESPACE_VALUE (node));
3057 /* Will this one ever happen? */
3058 if (TYPE_MAIN_DECL (type))
3059 return TYPE_MAIN_DECL (type);
3061 /* We used to do an internal error of 62 here, but instead we will
3062 handle the return of a null appropriately in the callers. */
3072 int dollar_seen = 0;
3076 c = nextchar, nextchar = -1;
3080 /* Effectively do c = skip_white_space (c)
3081 but do it faster in the usual cases. */
3094 /* Call skip_white_space so we can warn if appropriate. */
3099 c = skip_white_space (c);
3101 goto found_nonwhite;
3105 token_buffer[0] = c;
3106 token_buffer[1] = 0;
3108 /* yylloc.first_line = lineno; */
3113 token_buffer[0] = '\0';
3115 if (input_redirected ())
3116 value = END_OF_SAVED_INPUT;
3118 value = END_OF_LINE;
3124 if (! dollars_in_ident)
3125 error ("`$' in identifier");
3127 pedwarn ("`$' in identifier");
3132 /* Capital L may start a wide-string or wide-character constant. */
3134 register int c = getch ();
3143 goto string_constant;
3148 case 'A': case 'B': case 'C': case 'D': case 'E':
3149 case 'F': case 'G': case 'H': case 'I': case 'J':
3150 case 'K': case 'M': case 'N': case 'O':
3151 case 'P': case 'Q': case 'R': case 'S': case 'T':
3152 case 'U': case 'V': case 'W': case 'X': case 'Y':
3154 case 'a': case 'b': case 'c': case 'd': case 'e':
3155 case 'f': case 'g': case 'h': case 'i': case 'j':
3156 case 'k': case 'l': case 'm': case 'n': case 'o':
3157 case 'p': case 'q': case 'r': case 's': case 't':
3158 case 'u': case 'v': case 'w': case 'x': case 'y':
3168 /* We know that `token_buffer' can hold at least on char,
3169 so we install C immediately.
3170 We may have to read the value in `putback_char', so call
3175 /* Make this run fast. We know that we are reading straight
3176 from FINPUT in this case (since identifiers cannot straddle
3178 while (isalnum (c) || (c == '_') || c == '$')
3182 if (! dollars_in_ident)
3183 error ("`$' in identifier");
3185 pedwarn ("`$' in identifier");
3188 if (p >= token_buffer + maxtoken)
3189 p = extend_token_buffer (p);
3195 if (linemode && c == '\n')
3203 /* We know that `token_buffer' can hold at least on char,
3204 so we install C immediately. */
3208 while (isalnum (c) || (c == '_') || c == '$')
3212 if (! dollars_in_ident)
3213 error ("`$' in identifier");
3215 pedwarn ("`$' in identifier");
3218 if (p >= token_buffer + maxtoken)
3219 p = extend_token_buffer (p);
3232 /* Try to recognize a keyword. Uses minimum-perfect hash function */
3235 register struct resword *ptr;
3237 if ((ptr = is_reserved_word (token_buffer, p - token_buffer)))
3241 tree old_ttype = ridpointers[(int) ptr->rid];
3243 /* If this provides a type for us, then revert lexical
3244 state to standard state. */
3245 if (TREE_CODE (old_ttype) == IDENTIFIER_NODE
3246 && IDENTIFIER_GLOBAL_VALUE (old_ttype) != 0
3247 && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (old_ttype)) == TYPE_DECL)
3248 looking_for_typename = 0;
3249 else if (ptr->token == AGGR || ptr->token == ENUM)
3250 looking_for_typename = 1;
3252 /* Check if this is a language-type declaration.
3253 Just glimpse the next non-white character. */
3254 nextchar = skip_white_space (nextchar);
3255 if (nextchar == '"')
3257 /* We are looking at a string. Complain
3258 if the token before the string is no `extern'.
3260 Could cheat some memory by placing this string
3261 on the temporary_, instead of the saveable_
3264 if (ptr->rid != RID_EXTERN)
3265 error ("invalid modifier `%s' for language string",
3268 value = EXTERN_LANG_STRING;
3269 yylval.ttype = get_identifier (TREE_STRING_POINTER (yylval.ttype));
3272 if (ptr->token == VISSPEC)
3277 yylval.ttype = access_public_node;
3280 yylval.ttype = access_private_node;
3283 yylval.ttype = access_protected_node;
3286 my_friendly_abort (63);
3290 yylval.ttype = old_ttype;
3292 else if (ptr->token == EQCOMPARE)
3294 yylval.code = NE_EXPR;
3295 token_buffer[0] = '!';
3296 token_buffer[1] = '=';
3297 token_buffer[2] = 0;
3299 else if (ptr->token == ASSIGN)
3301 if (strcmp ("and_eq", token_buffer) == 0)
3303 yylval.code = BIT_AND_EXPR;
3304 token_buffer[0] = '&';
3306 else if (strcmp ("or_eq", token_buffer) == 0)
3308 yylval.code = BIT_IOR_EXPR;
3309 token_buffer[0] = '|';
3311 else if (strcmp ("xor_eq", token_buffer) == 0)
3313 yylval.code = BIT_XOR_EXPR;
3314 token_buffer[0] = '^';
3316 token_buffer[1] = '=';
3317 token_buffer[2] = 0;
3319 else if (ptr->token == '&')
3321 yylval.code = BIT_AND_EXPR;
3322 token_buffer[0] = '&';
3323 token_buffer[1] = 0;
3325 else if (ptr->token == '|')
3327 yylval.code = BIT_IOR_EXPR;
3328 token_buffer[0] = '|';
3329 token_buffer[1] = 0;
3331 else if (ptr->token == '^')
3333 yylval.code = BIT_XOR_EXPR;
3334 token_buffer[0] = '^';
3335 token_buffer[1] = 0;
3338 value = (int) ptr->token;
3342 /* If we did not find a keyword, look for an identifier
3345 if (value == IDENTIFIER || value == TYPESPEC)
3346 GNU_xref_ref (current_function_decl, token_buffer);
3348 if (value == IDENTIFIER)
3350 register tree tmp = get_identifier (token_buffer);
3352 #if !defined(VMS) && defined(JOINER)
3353 /* Make sure that user does not collide with our internal
3357 && (THIS_NAME_P (tmp)
3358 || VPTR_NAME_P (tmp)
3359 || DESTRUCTOR_NAME_P (tmp)
3360 || VTABLE_NAME_P (tmp)
3361 || TEMP_NAME_P (tmp)
3362 || ANON_AGGRNAME_P (tmp)
3363 || ANON_PARMNAME_P (tmp)))
3364 warning ("identifier name `%s' conflicts with GNU C++ internal naming strategy",
3370 if (value == NEW && ! global_bindings_p ())
3380 register int c1 = getch ();
3381 token_buffer[0] = c;
3382 token_buffer[1] = c1;
3386 token_buffer[2] = 0;
3394 token_buffer[2] = c1;
3395 token_buffer[3] = 0;
3399 error ("parse error at `..'");
3404 goto resume_numerical_scan;
3408 token_buffer[1] = 0;
3412 /* Optimize for most frequent case. */
3414 register int c1 = getch ();
3415 if (! isalnum (c1) && c1 != '.')
3417 /* Terminate string. */
3418 token_buffer[0] = c;
3419 token_buffer[1] = 0;
3421 yylval.ttype = integer_zero_node;
3423 yylval.ttype = integer_one_node;
3430 /* fall through... */
3431 case '2': case '3': case '4':
3432 case '5': case '6': case '7': case '8': case '9':
3433 resume_numerical_scan:
3438 int largest_digit = 0;
3440 /* for multi-precision arithmetic,
3441 we actually store only HOST_BITS_PER_CHAR bits in each part.
3442 The number of parts is chosen so as to be sufficient to hold
3443 the enough bits to fit into the two HOST_WIDE_INTs that contain
3444 the integer value (this is always at least as many bits as are
3445 in a target `long long' value, but may be wider). */
3446 #define TOTAL_PARTS ((HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2 + 2)
3447 int parts[TOTAL_PARTS];
3450 enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS} floatflag
3453 for (count = 0; count < TOTAL_PARTS; count++)
3461 *p++ = (c = getch ());
3462 if ((c == 'x') || (c == 'X'))
3465 *p++ = (c = getch ());
3467 /* Leading 0 forces octal unless the 0 is the only digit. */
3468 else if (c >= '0' && c <= '9')
3477 /* Read all the digits-and-decimal-points. */
3480 || (isalnum (c) && (c != 'l') && (c != 'L')
3481 && (c != 'u') && (c != 'U')
3482 && c != 'i' && c != 'I' && c != 'j' && c != 'J'
3483 && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
3488 error ("floating constant may not be in radix 16");
3489 if (floatflag == TOO_MANY_POINTS)
3490 /* We have already emitted an error. Don't need another. */
3492 else if (floatflag == AFTER_POINT)
3494 error ("malformed floating constant");
3495 floatflag = TOO_MANY_POINTS;
3496 /* Avoid another error from atof by forcing all characters
3497 from here on to be ignored. */
3501 floatflag = AFTER_POINT;
3504 *p++ = c = getch ();
3505 /* Accept '.' as the start of a floating-point number
3506 only when it is followed by a digit.
3507 Otherwise, unread the following non-digit
3508 and use the '.' as a structural token. */
3509 if (p == token_buffer + 2 && !isdigit (c))
3521 error ("parse error at `..'");
3524 token_buffer[1] = '\0';
3531 /* It is not a decimal point.
3532 It should be a digit (perhaps a hex digit). */
3538 else if (base <= 10)
3540 if (c == 'e' || c == 'E')
3543 floatflag = AFTER_POINT;
3544 break; /* start of exponent */
3546 error ("nondigits in number and not hexadecimal");
3557 if (c >= largest_digit)
3561 for (count = 0; count < TOTAL_PARTS; count++)
3563 parts[count] *= base;
3567 += (parts[count-1] >> HOST_BITS_PER_CHAR);
3569 &= (1 << HOST_BITS_PER_CHAR) - 1;
3575 /* If the extra highest-order part ever gets anything in it,
3576 the number is certainly too big. */
3577 if (parts[TOTAL_PARTS - 1] != 0)
3580 if (p >= token_buffer + maxtoken - 3)
3581 p = extend_token_buffer (p);
3582 *p++ = (c = getch ());
3587 error ("numeric constant with no digits");
3589 if (largest_digit >= base)
3590 error ("numeric constant contains digits beyond the radix");
3592 /* Remove terminating char from the token buffer and delimit the string */
3595 if (floatflag != NOT_FLOAT)
3597 tree type = double_type_node;
3598 int exceeds_double = 0;
3600 REAL_VALUE_TYPE value;
3603 /* Read explicit exponent if any, and put it in tokenbuf. */
3605 if ((c == 'e') || (c == 'E'))
3607 if (p >= token_buffer + maxtoken - 3)
3608 p = extend_token_buffer (p);
3611 if ((c == '+') || (c == '-'))
3617 error ("floating constant exponent has no digits");
3620 if (p >= token_buffer + maxtoken - 3)
3621 p = extend_token_buffer (p);
3630 /* Convert string to a double, checking for overflow. */
3631 if (setjmp (handler))
3633 error ("floating constant out of range");
3638 int fflag = 0, lflag = 0;
3639 /* Copy token_buffer now, while it has just the number
3640 and not the suffixes; once we add `f' or `i',
3641 REAL_VALUE_ATOF may not work any more. */
3642 char *copy = (char *) alloca (p - token_buffer + 1);
3643 bcopy (token_buffer, copy, p - token_buffer + 1);
3645 set_float_handler (handler);
3651 /* Read the suffixes to choose a data type. */
3656 error ("more than one `f' in numeric constant");
3662 error ("more than one `l' in numeric constant");
3668 error ("more than one `i' or `j' in numeric constant");
3670 pedwarn ("ANSI C++ forbids imaginary numeric constants");
3681 if (p >= token_buffer + maxtoken - 3)
3682 p = extend_token_buffer (p);
3688 /* The second argument, machine_mode, of REAL_VALUE_ATOF
3689 tells the desired precision of the binary result
3690 of decimal-to-binary conversion. */
3695 error ("both `f' and `l' in floating constant");
3697 type = float_type_node;
3698 value = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
3699 /* A diagnostic is required here by some ANSI C testsuites.
3700 This is not pedwarn, become some people don't want
3701 an error for this. */
3702 if (REAL_VALUE_ISINF (value) && pedantic)
3703 warning ("floating point number exceeds range of `float'");
3707 type = long_double_type_node;
3708 value = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
3709 if (REAL_VALUE_ISINF (value) && pedantic)
3710 warning ("floating point number exceeds range of `long double'");
3714 value = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
3715 if (REAL_VALUE_ISINF (value) && pedantic)
3716 warning ("floating point number exceeds range of `double'");
3719 set_float_handler (NULL_PTR);
3722 if (errno == ERANGE && pedantic)
3724 /* ERANGE is also reported for underflow,
3725 so test the value to distinguish overflow from that. */
3726 if (REAL_VALUES_LESS (dconst1, value)
3727 || REAL_VALUES_LESS (value, dconstm1))
3729 pedwarn ("floating point number exceeds range of `%s'",
3730 IDENTIFIER_POINTER (TYPE_IDENTIFIER (type)));
3736 /* If the result is not a number, assume it must have been
3737 due to some error message above, so silently convert
3739 if (REAL_VALUE_ISNAN (value))
3742 /* Create a node with determined type and value. */
3744 yylval.ttype = build_complex (NULL_TREE,
3745 cp_convert (type, integer_zero_node),
3746 build_real (type, value));
3748 yylval.ttype = build_real (type, value);
3753 HOST_WIDE_INT high, low;
3754 int spec_unsigned = 0;
3756 int spec_long_long = 0;
3762 if (c == 'u' || c == 'U')
3765 error ("two `u's in integer constant");
3768 else if (c == 'l' || c == 'L')
3773 error ("three `l's in integer constant");
3775 pedwarn ("ANSI C++ forbids long long integer constants");
3780 else if (c == 'i' || c == 'j' || c == 'I' || c == 'J')
3783 error ("more than one `i' or `j' in numeric constant");
3785 pedwarn ("ANSI C++ forbids imaginary numeric constants");
3790 if (p >= token_buffer + maxtoken - 3)
3791 p = extend_token_buffer (p);
3796 /* If the constant is not long long and it won't fit in an
3797 unsigned long, or if the constant is long long and won't fit
3798 in an unsigned long long, then warn that the constant is out
3801 /* ??? This assumes that long long and long integer types are
3802 a multiple of 8 bits. This better than the original code
3803 though which assumed that long was exactly 32 bits and long
3804 long was exactly 64 bits. */
3807 bytes = TYPE_PRECISION (long_long_integer_type_node) / 8;
3809 bytes = TYPE_PRECISION (long_integer_type_node) / 8;
3812 for (i = bytes; i < TOTAL_PARTS; i++)
3816 pedwarn ("integer constant out of range");
3818 /* This is simplified by the fact that our constant
3819 is always positive. */
3822 for (i = 0; i < HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR; i++)
3824 high |= ((HOST_WIDE_INT) parts[i + (HOST_BITS_PER_WIDE_INT
3825 / HOST_BITS_PER_CHAR)]
3826 << (i * HOST_BITS_PER_CHAR));
3827 low |= (HOST_WIDE_INT) parts[i] << (i * HOST_BITS_PER_CHAR);
3831 yylval.ttype = build_int_2 (low, high);
3832 TREE_TYPE (yylval.ttype) = long_long_unsigned_type_node;
3834 /* Calculate the ANSI type. */
3835 if (!spec_long && !spec_unsigned
3836 && int_fits_type_p (yylval.ttype, integer_type_node))
3837 type = integer_type_node;
3838 else if (!spec_long && (base != 10 || spec_unsigned)
3839 && int_fits_type_p (yylval.ttype, unsigned_type_node))
3840 /* Nondecimal constants try unsigned even in traditional C. */
3841 type = unsigned_type_node;
3842 else if (!spec_unsigned && !spec_long_long
3843 && int_fits_type_p (yylval.ttype, long_integer_type_node))
3844 type = long_integer_type_node;
3845 else if (! spec_long_long)
3846 type = long_unsigned_type_node;
3847 else if (! spec_unsigned
3848 /* Verify value does not overflow into sign bit. */
3849 && TREE_INT_CST_HIGH (yylval.ttype) >= 0
3850 && int_fits_type_p (yylval.ttype,
3851 long_long_integer_type_node))
3852 type = long_long_integer_type_node;
3854 type = long_long_unsigned_type_node;
3856 if (!int_fits_type_p (yylval.ttype, type) && !warn)
3857 pedwarn ("integer constant out of range");
3859 if (base == 10 && ! spec_unsigned && TREE_UNSIGNED (type))
3860 warning ("decimal integer constant is so large that it is unsigned");
3864 if (TYPE_PRECISION (type)
3865 <= TYPE_PRECISION (integer_type_node))
3867 = build_complex (NULL_TREE, integer_zero_node,
3868 cp_convert (integer_type_node,
3871 error ("complex integer constant is too wide for `__complex int'");
3874 TREE_TYPE (yylval.ttype) = type;
3880 value = CONSTANT; break;
3886 register int result = 0;
3887 register int num_chars = 0;
3888 unsigned width = TYPE_PRECISION (char_type_node);
3893 width = WCHAR_TYPE_SIZE;
3894 #ifdef MULTIBYTE_CHARS
3895 max_chars = MB_CUR_MAX;
3901 max_chars = TYPE_PRECISION (integer_type_node) / width;
3909 if (c == '\'' || c == EOF)
3915 c = readescape (&ignore);
3918 if (width < HOST_BITS_PER_INT
3919 && (unsigned) c >= (1 << width))
3920 warning ("escape sequence out of range for character");
3921 #ifdef MAP_CHARACTER
3923 c = MAP_CHARACTER (c);
3929 pedwarn ("ANSI C++ forbids newline in character constant");
3932 #ifdef MAP_CHARACTER
3934 c = MAP_CHARACTER (c);
3938 if (num_chars > maxtoken - 4)
3939 extend_token_buffer (token_buffer);
3941 token_buffer[num_chars] = c;
3943 /* Merge character into result; ignore excess chars. */
3944 if (num_chars < max_chars + 1)
3946 if (width < HOST_BITS_PER_INT)
3947 result = (result << width) | (c & ((1 << width) - 1));
3953 token_buffer[num_chars + 1] = '\'';
3954 token_buffer[num_chars + 2] = 0;
3957 error ("malformatted character constant");
3958 else if (num_chars == 0)
3959 error ("empty character constant");
3960 else if (num_chars > max_chars)
3962 num_chars = max_chars;
3963 error ("character constant too long");
3965 else if (num_chars != 1)
3966 warning ("multi-character character constant");
3968 /* If char type is signed, sign-extend the constant. */
3971 int num_bits = num_chars * width;
3973 /* We already got an error; avoid invalid shift. */
3974 yylval.ttype = build_int_2 (0, 0);
3975 else if (TREE_UNSIGNED (char_type_node)
3976 || ((result >> (num_bits - 1)) & 1) == 0)
3978 = build_int_2 (result & ((unsigned HOST_WIDE_INT) ~0
3979 >> (HOST_BITS_PER_WIDE_INT - num_bits)),
3983 = build_int_2 (result | ~((unsigned HOST_WIDE_INT) ~0
3984 >> (HOST_BITS_PER_WIDE_INT - num_bits)),
3987 TREE_TYPE (yylval.ttype) = char_type_node;
3989 TREE_TYPE (yylval.ttype) = integer_type_node;
3993 #ifdef MULTIBYTE_CHARS
3994 /* Set the initial shift state and convert the next sequence. */
3996 /* In all locales L'\0' is zero and mbtowc will return zero,
3999 || (num_chars == 1 && token_buffer[1] != '\0'))
4002 (void) mbtowc (NULL, NULL, 0);
4003 if (mbtowc (& wc, token_buffer + 1, num_chars) == num_chars)
4006 warning ("Ignoring invalid multibyte character");
4009 yylval.ttype = build_int_2 (result, 0);
4010 TREE_TYPE (yylval.ttype) = wchar_type_node;
4023 p = token_buffer + 1;
4025 while (c != '"' && c >= 0)
4027 /* ignore_escape_flag is set for reading the filename in #line. */
4028 if (!ignore_escape_flag && c == '\\')
4031 c = readescape (&ignore);
4035 && TYPE_PRECISION (char_type_node) < HOST_BITS_PER_INT
4036 && c >= ((unsigned) 1 << TYPE_PRECISION (char_type_node)))
4037 warning ("escape sequence out of range for character");
4042 pedwarn ("ANSI C++ forbids newline in string constant");
4046 if (p == token_buffer + maxtoken)
4047 p = extend_token_buffer (p);
4053 error ("Unterminated string");
4059 /* We have read the entire constant.
4060 Construct a STRING_CST for the result. */
4064 /* If this is a L"..." wide-string, convert the multibyte string
4065 to a wide character string. */
4066 char *widep = (char *) alloca ((p - token_buffer) * WCHAR_BYTES);
4069 #ifdef MULTIBYTE_CHARS
4070 len = mbstowcs ((wchar_t *) widep, token_buffer + 1, p - token_buffer);
4071 if (len < 0 || len >= (p - token_buffer))
4073 warning ("Ignoring invalid multibyte string");
4076 bzero (widep + (len * WCHAR_BYTES), WCHAR_BYTES);
4081 wp = widep + (BYTES_BIG_ENDIAN ? WCHAR_BYTES - 1 : 0);
4082 bzero (widep, (p - token_buffer) * WCHAR_BYTES);
4083 for (cp = token_buffer + 1; cp < p; cp++)
4084 *wp = *cp, wp += WCHAR_BYTES;
4085 len = p - token_buffer - 1;
4088 if (processing_template_decl)
4089 push_obstacks (&permanent_obstack, &permanent_obstack);
4090 yylval.ttype = build_string ((len + 1) * WCHAR_BYTES, widep);
4091 if (processing_template_decl)
4093 TREE_TYPE (yylval.ttype) = wchar_array_type_node;
4097 if (processing_template_decl)
4098 push_obstacks (&permanent_obstack, &permanent_obstack);
4099 yylval.ttype = build_string (p - token_buffer, token_buffer + 1);
4100 if (processing_template_decl)
4102 TREE_TYPE (yylval.ttype) = char_array_type_node;
4108 value = STRING; break;
4131 yylval.code = PLUS_EXPR; break;
4133 yylval.code = MINUS_EXPR; break;
4135 yylval.code = BIT_AND_EXPR; break;
4137 yylval.code = BIT_IOR_EXPR; break;
4139 yylval.code = MULT_EXPR; break;
4141 yylval.code = TRUNC_DIV_EXPR; break;
4143 yylval.code = TRUNC_MOD_EXPR; break;
4145 yylval.code = BIT_XOR_EXPR; break;
4147 yylval.code = LSHIFT_EXPR; break;
4149 yylval.code = RSHIFT_EXPR; break;
4151 yylval.code = LT_EXPR; break;
4153 yylval.code = GT_EXPR; break;
4156 token_buffer[1] = c1 = getch ();
4157 token_buffer[2] = 0;
4164 value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done;
4166 value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done;
4168 value = EQCOMPARE; yylval.code = NE_EXPR; goto done;
4170 value = EQCOMPARE; yylval.code = EQ_EXPR; goto done;
4172 value = ASSIGN; goto done;
4178 value = PLUSPLUS; goto done;
4180 value = MINUSMINUS; goto done;
4182 value = ANDAND; goto done;
4184 value = OROR; goto done;
4192 else if ((c == '-') && (c1 == '>'))
4194 nextchar = getch ();
4195 if (nextchar == '*')
4198 value = POINTSAT_STAR;
4204 else if (c1 == '?' && (c == '<' || c == '>'))
4206 token_buffer[3] = 0;
4209 yylval.code = (c == '<' ? MIN_EXPR : MAX_EXPR);
4212 /* <?= or >?= expression. */
4213 token_buffer[2] = c1;
4222 pedwarn ("use of `operator %s' is not standard C++",
4227 else if (c == '<' && c1 == '%')
4228 { value = '{'; goto done; }
4229 else if (c == '<' && c1 == ':')
4230 { value = '['; goto done; }
4231 else if (c == '%' && c1 == '>')
4232 { value = '}'; goto done; }
4233 else if (c == '%' && c1 == ':')
4234 { value = '#'; goto done; }
4237 token_buffer[1] = 0;
4247 token_buffer[1] = ':';
4248 token_buffer[2] = '\0';
4265 /* Don't make yyparse think this is eof. */
4270 /* try, weakly, to handle casts to pointers to functions. */
4271 nextchar = skip_white_space (getch ());
4272 if (nextchar == '*')
4274 int next_c = skip_white_space (getch ());
4278 yylval.ttype = build1 (INDIRECT_REF, 0, 0);
4279 value = PAREN_STAR_PAREN;
4287 else if (nextchar == ')')
4290 yylval.ttype = NULL_TREE;
4301 /* yylloc.last_line = lineno; */
4302 #ifdef GATHER_STATISTICS
4303 #ifdef REDUCE_LENGTH
4304 token_count[value] += 1;
4315 return !!is_reserved_word (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t));
4318 #ifdef GATHER_STATISTICS
4319 /* The original for tree_node_kind is in the toplevel tree.c; changes there
4320 need to be brought into here, unless this were actually put into a header
4322 /* Statistics-gathering stuff. */
4343 extern int tree_node_counts[];
4344 extern int tree_node_sizes[];
4347 /* Place to save freed lang_decls which were allocated on the
4348 permanent_obstack. @@ Not currently used. */
4349 tree free_lang_decl_chain;
4352 build_lang_decl (code, name, type)
4353 enum tree_code code;
4357 register tree t = build_decl (code, name, type);
4358 struct obstack *obstack = current_obstack;
4359 register int i = sizeof (struct lang_decl) / sizeof (int);
4362 if (! TREE_PERMANENT (t))
4363 obstack = saveable_obstack;
4365 /* Could be that saveable is permanent and current is not. */
4366 obstack = &permanent_obstack;
4368 if (free_lang_decl_chain && obstack == &permanent_obstack)
4370 pi = (int *)free_lang_decl_chain;
4371 free_lang_decl_chain = TREE_CHAIN (free_lang_decl_chain);
4374 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
4379 DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
4380 LANG_DECL_PERMANENT ((struct lang_decl *) pi)
4381 = obstack == &permanent_obstack;
4382 my_friendly_assert (LANG_DECL_PERMANENT ((struct lang_decl *) pi)
4383 == TREE_PERMANENT (t), 234);
4384 DECL_MAIN_VARIANT (t) = t;
4385 if (current_lang_name == lang_name_cplusplus)
4386 DECL_LANGUAGE (t) = lang_cplusplus;
4387 else if (current_lang_name == lang_name_c)
4388 DECL_LANGUAGE (t) = lang_c;
4389 else if (current_lang_name == lang_name_java)
4390 DECL_LANGUAGE (t) = lang_java;
4391 else my_friendly_abort (64);
4393 SET_DECL_NAMESPACE (t, current_namespace);
4395 #if 0 /* not yet, should get fixed properly later */
4396 if (code == TYPE_DECL)
4399 id = get_identifier (build_overload_name (type, 1, 1));
4400 DECL_ASSEMBLER_NAME (t) = id;
4404 #ifdef GATHER_STATISTICS
4405 tree_node_counts[(int)lang_decl] += 1;
4406 tree_node_sizes[(int)lang_decl] += sizeof (struct lang_decl);
4413 build_lang_field_decl (code, name, type)
4414 enum tree_code code;
4418 extern struct obstack *current_obstack, *saveable_obstack;
4419 register tree t = build_decl (code, name, type);
4420 struct obstack *obstack = current_obstack;
4421 register int i = sizeof (struct lang_decl_flags) / sizeof (int);
4423 #if 0 /* not yet, should get fixed properly later */
4425 if (code == TYPE_DECL)
4428 id = get_identifier (build_overload_name (type, 1, 1));
4429 DECL_ASSEMBLER_NAME (t) = id;
4433 if (! TREE_PERMANENT (t))
4434 obstack = saveable_obstack;
4436 my_friendly_assert (obstack == &permanent_obstack, 235);
4438 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl_flags));
4442 DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
4447 copy_lang_decl (node)
4453 if (! DECL_LANG_SPECIFIC (node))
4456 if (TREE_CODE (node) == FIELD_DECL)
4457 size = sizeof (struct lang_decl_flags);
4459 size = sizeof (struct lang_decl);
4460 pi = (int *)obstack_alloc (&permanent_obstack, size);
4461 bcopy ((char *)DECL_LANG_SPECIFIC (node), (char *)pi, size);
4462 DECL_LANG_SPECIFIC (node) = (struct lang_decl *)pi;
4466 make_lang_type (code)
4467 enum tree_code code;
4469 extern struct obstack *current_obstack, *saveable_obstack;
4470 register tree t = make_node (code);
4471 struct obstack *obstack = current_obstack;
4472 register int i = sizeof (struct lang_type) / sizeof (int);
4475 /* Set up some flags that give proper default behavior. */
4476 IS_AGGR_TYPE (t) = 1;
4478 if (! TREE_PERMANENT (t))
4479 obstack = saveable_obstack;
4481 my_friendly_assert (obstack == &permanent_obstack, 236);
4483 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_type));
4487 TYPE_LANG_SPECIFIC (t) = (struct lang_type *) pi;
4488 CLASSTYPE_AS_LIST (t) = build_expr_list (NULL_TREE, t);
4489 SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, interface_unknown);
4490 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
4491 TYPE_BINFO (t) = make_binfo (integer_zero_node, t, NULL_TREE, NULL_TREE,
4493 CLASSTYPE_BINFO_AS_LIST (t) = build_tree_list (NULL_TREE, TYPE_BINFO (t));
4495 /* Make sure this is laid out, for ease of use later.
4496 In the presence of parse errors, the normal was of assuring
4497 this might not ever get executed, so we lay it out *immediately*. */
4498 build_pointer_type (t);
4500 #ifdef GATHER_STATISTICS
4501 tree_node_counts[(int)lang_type] += 1;
4502 tree_node_sizes[(int)lang_type] += sizeof (struct lang_type);
4509 dump_time_statistics ()
4511 register tree prev = 0, decl, next;
4512 int this_time = my_get_run_time ();
4513 TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time))
4514 += this_time - body_time;
4516 fprintf (stderr, "\n******\n");
4517 print_time ("header files (total)", header_time);
4518 print_time ("main file (total)", this_time - body_time);
4519 fprintf (stderr, "ratio = %g : 1\n",
4520 (double)header_time / (double)(this_time - body_time));
4521 fprintf (stderr, "\n******\n");
4523 for (decl = filename_times; decl; decl = next)
4525 next = IDENTIFIER_GLOBAL_VALUE (decl);
4526 IDENTIFIER_GLOBAL_VALUE (decl) = prev;
4530 for (decl = prev; decl; decl = IDENTIFIER_GLOBAL_VALUE (decl))
4531 print_time (IDENTIFIER_POINTER (decl),
4532 TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (decl)));
4536 compiler_error (s, v, v2)
4538 HOST_WIDE_INT v, v2; /* @@also used as pointer */
4541 sprintf (buf, s, v, v2);
4542 error_with_file_and_line (input_filename, lineno, "%s (compiler error)", buf);
4549 extern int end_of_file;
4552 strcpy (buf, string);
4554 /* We can't print string and character constants well
4555 because the token_buffer contains the result of processing escapes. */
4557 strcat (buf, input_redirected ()
4558 ? " at end of saved text"
4559 : " at end of input");
4560 else if (token_buffer[0] == 0)
4561 strcat (buf, " at null character");
4562 else if (token_buffer[0] == '"')
4563 strcat (buf, " before string constant");
4564 else if (token_buffer[0] == '\'')
4565 strcat (buf, " before character constant");
4566 else if (token_buffer[0] < 040 || (unsigned char) token_buffer[0] >= 0177)
4567 sprintf (buf + strlen (buf), " before character 0%o",
4568 (unsigned char) token_buffer[0]);
4570 strcat (buf, " before `%s'");
4572 error (buf, token_buffer);
4576 handle_cp_pragma (pname)
4581 if (! strcmp (pname, "vtable"))
4583 extern tree pending_vtables;
4585 /* More follows: it must be a string constant (class name). */
4586 token = real_yylex ();
4587 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
4589 error ("invalid #pragma vtable");
4593 if (write_virtuals != 2)
4595 warning ("use `+e2' option to enable #pragma vtable");
4599 = perm_tree_cons (NULL_TREE,
4600 get_identifier (TREE_STRING_POINTER (yylval.ttype)),
4602 token = real_yylex ();
4603 if (token != END_OF_LINE)
4604 warning ("trailing characters ignored");
4607 else if (! strcmp (pname, "unit"))
4609 /* More follows: it must be a string constant (unit name). */
4610 token = real_yylex ();
4611 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
4613 error ("invalid #pragma unit");
4616 token = real_yylex ();
4617 if (token != END_OF_LINE)
4618 warning ("trailing characters ignored");
4621 else if (! strcmp (pname, "interface"))
4623 tree fileinfo = IDENTIFIER_CLASS_VALUE (get_time_identifier (input_filename));
4624 char *main_filename = input_filename;
4626 main_filename = file_name_nondirectory (main_filename);
4628 token = real_yylex ();
4630 if (token != END_OF_LINE)
4633 || TREE_CODE (yylval.ttype) != STRING_CST)
4635 error ("invalid `#pragma interface'");
4638 main_filename = TREE_STRING_POINTER (yylval.ttype);
4639 token = real_yylex ();
4642 if (token != END_OF_LINE)
4643 warning ("garbage after `#pragma interface' ignored");
4645 #ifndef NO_LINKAGE_HEURISTICS
4648 if (impl_file_chain == 0)
4650 /* If this is zero at this point, then we are
4651 auto-implementing. */
4652 if (main_input_filename == 0)
4653 main_input_filename = input_filename;
4655 #ifdef AUTO_IMPLEMENT
4656 filename = file_name_nondirectory (main_input_filename);
4657 fi = get_time_identifier (filename);
4658 fi = IDENTIFIER_CLASS_VALUE (fi);
4659 TREE_INT_CST_LOW (fi) = 0;
4660 TREE_INT_CST_HIGH (fi) = 1;
4662 impl_file_chain = (struct impl_files *)permalloc (sizeof (struct impl_files));
4663 impl_file_chain->filename = filename;
4664 impl_file_chain->next = 0;
4668 interface_only = interface_strcmp (main_filename);
4669 interface_unknown = 0;
4670 TREE_INT_CST_LOW (fileinfo) = interface_only;
4671 TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
4672 #endif /* NO_LINKAGE_HEURISTICS */
4676 else if (! strcmp (pname, "implementation"))
4678 tree fileinfo = IDENTIFIER_CLASS_VALUE (get_time_identifier (input_filename));
4679 char *main_filename = main_input_filename ? main_input_filename : input_filename;
4681 main_filename = file_name_nondirectory (main_filename);
4682 token = real_yylex ();
4683 if (token != END_OF_LINE)
4686 || TREE_CODE (yylval.ttype) != STRING_CST)
4688 error ("invalid `#pragma implementation'");
4691 main_filename = TREE_STRING_POINTER (yylval.ttype);
4692 token = real_yylex ();
4695 if (token != END_OF_LINE)
4696 warning ("garbage after `#pragma implementation' ignored");
4698 #ifndef NO_LINKAGE_HEURISTICS
4699 if (write_virtuals == 3)
4701 struct impl_files *ifiles = impl_file_chain;
4704 if (! strcmp (ifiles->filename, main_filename))
4706 ifiles = ifiles->next;
4710 ifiles = (struct impl_files*) permalloc (sizeof (struct impl_files));
4711 ifiles->filename = main_filename;
4712 ifiles->next = impl_file_chain;
4713 impl_file_chain = ifiles;
4716 else if ((main_input_filename != 0
4717 && ! strcmp (main_input_filename, input_filename))
4718 || ! strcmp (input_filename, main_filename))
4721 if (impl_file_chain == 0)
4723 impl_file_chain = (struct impl_files*) permalloc (sizeof (struct impl_files));
4724 impl_file_chain->filename = main_filename;
4725 impl_file_chain->next = 0;
4729 error ("`#pragma implementation' can only appear at top-level");
4732 /* We make this non-zero so that we infer decl linkage
4733 in the impl file only for variables first declared
4734 in the interface file. */
4735 interface_unknown = 1;
4737 /* We make this zero so that templates in the impl
4738 file will be emitted properly. */
4739 interface_unknown = 0;
4741 TREE_INT_CST_LOW (fileinfo) = interface_only;
4742 TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
4743 #endif /* NO_LINKAGE_HEURISTICS */
4751 #ifdef HANDLE_SYSV_PRAGMA
4753 /* Handle a #pragma directive. INPUT is the current input stream,
4754 and C is a character to reread. Processes the entire input line
4755 and returns a character for the caller to reread: either \n or EOF. */
4757 /* This function has to be in this file, in order to get at
4761 handle_sysv_pragma (finput, token)
4773 handle_pragma_token ("ignored", yylval.ttype);
4776 handle_pragma_token ("(", NULL_TREE);
4779 handle_pragma_token (")", NULL_TREE);
4782 handle_pragma_token (",", NULL_TREE);
4785 handle_pragma_token ("=", NULL_TREE);
4788 handle_pragma_token ("(", NULL_TREE);
4789 handle_pragma_token (")", NULL_TREE);
4793 handle_pragma_token (NULL_PTR, NULL_TREE);
4796 token = real_yylex ();
4799 #endif /* HANDLE_SYSV_PRAGMA */