1 /* Separate lexical analyzer for GNU C++.
2 Copyright (C) 1987, 89, 92-97, 1998 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. */
42 #ifdef MULTIBYTE_CHARS
46 #ifndef GET_ENVIRONMENT
47 #define GET_ENVIRONMENT(ENV_VALUE,ENV_NAME) ((ENV_VALUE) = getenv (ENV_NAME))
51 #define obstack_chunk_alloc xmalloc
52 #define obstack_chunk_free free
55 #define DIR_SEPARATOR '/'
58 extern struct obstack permanent_obstack;
59 extern struct obstack *current_obstack, *saveable_obstack;
61 extern void yyprint PROTO((FILE *, int, YYSTYPE));
62 extern void compiler_error PROTO((char *, HOST_WIDE_INT,
65 static tree get_time_identifier PROTO((char *));
66 static int check_newline PROTO((void));
67 static int skip_white_space PROTO((int));
68 static void finish_defarg PROTO((void));
69 static int my_get_run_time PROTO((void));
70 static int get_last_nonwhite_on_line PROTO((void));
71 static int interface_strcmp PROTO((char *));
72 static int readescape PROTO((int *));
73 static char *extend_token_buffer PROTO((char *));
74 static void consume_string PROTO((struct obstack *, int));
75 static void set_typedecl_interface_info PROTO((tree, tree));
76 static void feed_defarg PROTO((tree, tree));
77 static int set_vardecl_interface_info PROTO((tree, tree));
78 static void store_pending_inline PROTO((tree, struct pending_inline *));
79 static void reinit_parse_for_expr PROTO((struct obstack *));
80 static int *init_cpp_parse PROTO((void));
81 static int handle_cp_pragma PROTO((char *));
82 #ifdef HANDLE_SYSV_PRAGMA
83 static int handle_sysv_pragma PROTO((int));
85 #ifdef GATHER_STATISTICS
87 static int reduce_cmp PROTO((int *, int *));
88 static int token_cmp PROTO((int *, int *));
92 /* Given a file name X, return the nondirectory portion.
93 Keep in mind that X can be computed more than once. */
95 file_name_nondirectory (x)
98 char *tmp = (char *) rindex (x, '/');
99 if (DIR_SEPARATOR != '/' && ! tmp)
100 tmp = (char *) rindex (x, DIR_SEPARATOR);
102 return (char *) (tmp + 1);
107 /* This obstack is needed to hold text. It is not safe to use
108 TOKEN_BUFFER because `check_newline' calls `yylex'. */
109 struct obstack inline_text_obstack;
110 char *inline_text_firstobj;
114 extern cpp_reader parse_in;
115 extern cpp_options parse_options;
116 extern unsigned char *yy_cur, *yy_lim;
122 /* Pending language change.
123 Positive is push count, negative is pop count. */
124 int pending_lang_change = 0;
126 /* Wrap the current header file in extern "C". */
127 static int c_header_level = 0;
129 extern int first_token;
130 extern struct obstack token_obstack;
132 /* ??? Don't really know where this goes yet. */
136 extern void put_back (/* int */);
137 extern int input_redirected ();
138 extern void feed_input (/* char *, int */);
141 /* Holds translations from TREE_CODEs to operator name strings,
142 i.e., opname_tab[PLUS_EXPR] == "+". */
146 extern int yychar; /* the lookahead symbol */
147 extern YYSTYPE yylval; /* the semantic value of the */
148 /* lookahead symbol */
151 YYLTYPE yylloc; /* location data for the lookahead */
156 /* the declaration found for the last IDENTIFIER token read in.
157 yylex must look this up to detect typedefs, which get token type TYPENAME,
158 so it is left around in case the identifier is not a typedef but is
159 used in a context which makes it a reference to a variable. */
162 /* The elements of `ridpointers' are identifier nodes
163 for the reserved type names and storage classes.
164 It is indexed by a RID_... value. */
165 tree ridpointers[(int) RID_MAX];
167 /* We may keep statistics about how long which files took to compile. */
168 static int header_time, body_time;
169 static tree filename_times;
170 static tree this_filename_time;
172 /* Array for holding counts of the numbers of tokens seen. */
173 extern int *token_count;
175 /* Return something to represent absolute declarators containing a *.
176 TARGET is the absolute declarator that the * contains.
177 CV_QUALIFIERS is a list of modifiers such as const or volatile
178 to apply to the pointer type, represented as identifiers.
180 We return an INDIRECT_REF whose "contents" are TARGET
181 and whose type is the modifier list. */
184 make_pointer_declarator (cv_qualifiers, target)
185 tree cv_qualifiers, target;
187 if (target && TREE_CODE (target) == IDENTIFIER_NODE
188 && ANON_AGGRNAME_P (target))
189 error ("type name expected before `*'");
190 target = build_parse_node (INDIRECT_REF, target);
191 TREE_TYPE (target) = cv_qualifiers;
195 /* Return something to represent absolute declarators containing a &.
196 TARGET is the absolute declarator that the & contains.
197 CV_QUALIFIERS is a list of modifiers such as const or volatile
198 to apply to the reference type, represented as identifiers.
200 We return an ADDR_EXPR whose "contents" are TARGET
201 and whose type is the modifier list. */
204 make_reference_declarator (cv_qualifiers, target)
205 tree cv_qualifiers, target;
209 if (TREE_CODE (target) == ADDR_EXPR)
211 error ("cannot declare references to references");
214 if (TREE_CODE (target) == INDIRECT_REF)
216 error ("cannot declare pointers to references");
219 if (TREE_CODE (target) == IDENTIFIER_NODE && ANON_AGGRNAME_P (target))
220 error ("type name expected before `&'");
222 target = build_parse_node (ADDR_EXPR, target);
223 TREE_TYPE (target) = cv_qualifiers;
228 make_call_declarator (target, parms, cv_qualifiers, exception_specification)
229 tree target, parms, cv_qualifiers, exception_specification;
231 target = build_parse_node (CALL_EXPR, target, parms, cv_qualifiers);
232 TREE_TYPE (target) = exception_specification;
237 set_quals_and_spec (call_declarator, cv_qualifiers, exception_specification)
238 tree call_declarator, cv_qualifiers, exception_specification;
240 TREE_OPERAND (call_declarator, 2) = cv_qualifiers;
241 TREE_TYPE (call_declarator) = exception_specification;
244 /* Build names and nodes for overloaded operators. */
246 tree ansi_opname[LAST_CPLUS_TREE_CODE];
247 tree ansi_assopname[LAST_CPLUS_TREE_CODE];
250 operator_name_string (name)
253 char *opname = IDENTIFIER_POINTER (name) + 2;
257 /* Works for builtin and user defined types. */
258 if (IDENTIFIER_GLOBAL_VALUE (name)
259 && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (name)) == TYPE_DECL)
260 return IDENTIFIER_POINTER (name);
262 if (opname[0] == 'a' && opname[2] != '\0' && opname[2] != '_')
266 opname_table = ansi_assopname;
271 opname_table = ansi_opname;
274 for (i = 0; i < (int) LAST_CPLUS_TREE_CODE; i++)
276 if (opname[0] == IDENTIFIER_POINTER (opname_table[i])[2+assign]
277 && opname[1] == IDENTIFIER_POINTER (opname_table[i])[3+assign])
281 if (i == LAST_CPLUS_TREE_CODE)
282 return "<invalid operator>";
285 return assignop_tab[i];
287 return opname_tab[i];
290 int interface_only; /* whether or not current file is only for
291 interface definitions. */
292 int interface_unknown; /* whether or not we know this class
293 to behave according to #pragma interface. */
295 /* lexical analyzer */
297 #ifndef WCHAR_TYPE_SIZE
299 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
301 #define WCHAR_TYPE_SIZE BITS_PER_WORD
305 /* Number of bytes in a wide character. */
306 #define WCHAR_BYTES (WCHAR_TYPE_SIZE / BITS_PER_UNIT)
308 static int maxtoken; /* Current nominal length of token buffer. */
309 char *token_buffer; /* Pointer to token buffer.
310 Actual allocated length is maxtoken + 2. */
315 /* Nonzero tells yylex to ignore \ in string constants. */
316 static int ignore_escape_flag = 0;
319 get_time_identifier (name)
322 tree time_identifier;
323 int len = strlen (name);
324 char *buf = (char *) alloca (len + 6);
325 strcpy (buf, "file ");
326 bcopy (name, buf+5, len);
328 time_identifier = get_identifier (buf);
329 if (IDENTIFIER_LOCAL_VALUE (time_identifier) == NULL_TREE)
331 push_obstacks_nochange ();
332 end_temporary_allocation ();
333 IDENTIFIER_LOCAL_VALUE (time_identifier) = build_int_2 (0, 0);
334 IDENTIFIER_CLASS_VALUE (time_identifier) = build_int_2 (0, 1);
335 SET_IDENTIFIER_GLOBAL_VALUE (time_identifier, filename_times);
336 filename_times = time_identifier;
339 return time_identifier;
348 int old_quiet_flag = quiet_flag;
351 this_time = get_run_time ();
352 quiet_flag = old_quiet_flag;
356 /* Table indexed by tree code giving a string containing a character
357 classifying the tree code. Possibilities are
358 t, d, s, c, r, <, 1 and 2. See cp/cp-tree.def for details. */
360 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
362 char cplus_tree_code_type[] = {
364 #include "cp-tree.def"
368 /* Table indexed by tree code giving number of expression
369 operands beyond the fixed part of the node structure.
370 Not used for types or decls. */
372 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
374 int cplus_tree_code_length[] = {
376 #include "cp-tree.def"
380 /* Names of tree components.
381 Used for printing out the tree and error messages. */
382 #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
384 char *cplus_tree_code_name[] = {
386 #include "cp-tree.def"
390 /* toplev.c needs to call these. */
395 /* Default exceptions on. */
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 ());
408 if (flag_gnu_xref) GNU_xref_begin (input_filename);
409 init_repo (input_filename);
415 extern int errorcount, sorrycount;
416 if (flag_gnu_xref) GNU_xref_end (errorcount+sorrycount);
426 init_filename_times ()
428 this_filename_time = get_time_identifier ("<top level>");
429 if (flag_detailed_statistics)
432 body_time = my_get_run_time ();
433 TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time)) = body_time;
437 /* Change by Bryan Boreham, Kewill, Thu Jul 27 09:46:05 1989.
438 Stuck this hack in to get the files open correctly; this is called
439 in place of init_parse if we are an unexec'd binary. */
443 reinit_lang_specific ()
445 init_filename_times ();
446 reinit_search_statistics ();
453 #ifdef GATHER_STATISTICS
455 reduce_count = (int *)malloc (sizeof (int) * (REDUCE_LENGTH + 1));
456 bzero (reduce_count, sizeof (int) * (REDUCE_LENGTH + 1));
458 token_count = (int *)malloc (sizeof (int) * (TOKEN_LENGTH + 1));
459 bzero (token_count, sizeof (int) * (TOKEN_LENGTH + 1));
467 init_parse (filename)
470 extern int flag_no_gnu_keywords;
471 extern int flag_operator_names;
475 #ifdef MULTIBYTE_CHARS
476 /* Change to the native locale for multibyte conversions. */
477 setlocale (LC_CTYPE, "");
478 GET_ENVIRONMENT (literal_codeset, "LANG");
485 parse_in.show_column = 1;
486 if (! cpp_start_read (&parse_in, filename))
489 /* Open input file. */
490 if (filename == 0 || !strcmp (filename, "-"))
496 finput = fopen (filename, "r");
498 pfatal_with_name (filename);
500 #ifdef IO_BUFFER_SIZE
501 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
503 #endif /* !USE_CPPLIB */
505 /* Initialize the lookahead machinery. */
508 /* Make identifier nodes long enough for the language-specific slots. */
509 set_identifier_size (sizeof (struct lang_identifier));
510 decl_printable_name = lang_printable_name;
512 init_cplus_expand ();
514 bcopy (cplus_tree_code_type,
515 tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
516 (int)LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE);
517 bcopy ((char *)cplus_tree_code_length,
518 (char *)(tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE),
519 (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
520 bcopy ((char *)cplus_tree_code_name,
521 (char *)(tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
522 (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
524 opname_tab = (char **)oballoc ((int)LAST_CPLUS_TREE_CODE * sizeof (char *));
525 bzero ((char *)opname_tab, (int)LAST_CPLUS_TREE_CODE * sizeof (char *));
526 assignop_tab = (char **)oballoc ((int)LAST_CPLUS_TREE_CODE * sizeof (char *));
527 bzero ((char *)assignop_tab, (int)LAST_CPLUS_TREE_CODE * sizeof (char *));
529 ansi_opname[0] = get_identifier ("<invalid operator>");
530 for (i = 0; i < (int) LAST_CPLUS_TREE_CODE; i++)
532 ansi_opname[i] = ansi_opname[0];
533 ansi_assopname[i] = ansi_opname[0];
536 ansi_opname[(int) MULT_EXPR] = get_identifier ("__ml");
537 IDENTIFIER_OPNAME_P (ansi_opname[(int) MULT_EXPR]) = 1;
538 ansi_opname[(int) INDIRECT_REF] = ansi_opname[(int) MULT_EXPR];
539 ansi_assopname[(int) MULT_EXPR] = get_identifier ("__aml");
540 IDENTIFIER_OPNAME_P (ansi_assopname[(int) MULT_EXPR]) = 1;
541 ansi_assopname[(int) INDIRECT_REF] = ansi_assopname[(int) MULT_EXPR];
542 ansi_opname[(int) TRUNC_MOD_EXPR] = get_identifier ("__md");
543 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUNC_MOD_EXPR]) = 1;
544 ansi_assopname[(int) TRUNC_MOD_EXPR] = get_identifier ("__amd");
545 IDENTIFIER_OPNAME_P (ansi_assopname[(int) TRUNC_MOD_EXPR]) = 1;
546 ansi_opname[(int) CEIL_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
547 ansi_opname[(int) FLOOR_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
548 ansi_opname[(int) ROUND_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
549 ansi_opname[(int) MINUS_EXPR] = get_identifier ("__mi");
550 IDENTIFIER_OPNAME_P (ansi_opname[(int) MINUS_EXPR]) = 1;
551 ansi_opname[(int) NEGATE_EXPR] = ansi_opname[(int) MINUS_EXPR];
552 ansi_assopname[(int) MINUS_EXPR] = get_identifier ("__ami");
553 IDENTIFIER_OPNAME_P (ansi_assopname[(int) MINUS_EXPR]) = 1;
554 ansi_assopname[(int) NEGATE_EXPR] = ansi_assopname[(int) MINUS_EXPR];
555 ansi_opname[(int) RSHIFT_EXPR] = get_identifier ("__rs");
556 IDENTIFIER_OPNAME_P (ansi_opname[(int) RSHIFT_EXPR]) = 1;
557 ansi_assopname[(int) RSHIFT_EXPR] = get_identifier ("__ars");
558 IDENTIFIER_OPNAME_P (ansi_assopname[(int) RSHIFT_EXPR]) = 1;
559 ansi_opname[(int) NE_EXPR] = get_identifier ("__ne");
560 IDENTIFIER_OPNAME_P (ansi_opname[(int) NE_EXPR]) = 1;
561 ansi_opname[(int) GT_EXPR] = get_identifier ("__gt");
562 IDENTIFIER_OPNAME_P (ansi_opname[(int) GT_EXPR]) = 1;
563 ansi_opname[(int) GE_EXPR] = get_identifier ("__ge");
564 IDENTIFIER_OPNAME_P (ansi_opname[(int) GE_EXPR]) = 1;
565 ansi_opname[(int) BIT_IOR_EXPR] = get_identifier ("__or");
566 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_IOR_EXPR]) = 1;
567 ansi_assopname[(int) BIT_IOR_EXPR] = get_identifier ("__aor");
568 IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_IOR_EXPR]) = 1;
569 ansi_opname[(int) TRUTH_ANDIF_EXPR] = get_identifier ("__aa");
570 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_ANDIF_EXPR]) = 1;
571 ansi_opname[(int) TRUTH_NOT_EXPR] = get_identifier ("__nt");
572 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_NOT_EXPR]) = 1;
573 ansi_opname[(int) PREINCREMENT_EXPR] = get_identifier ("__pp");
574 IDENTIFIER_OPNAME_P (ansi_opname[(int) PREINCREMENT_EXPR]) = 1;
575 ansi_opname[(int) POSTINCREMENT_EXPR] = ansi_opname[(int) PREINCREMENT_EXPR];
576 ansi_opname[(int) MODIFY_EXPR] = get_identifier ("__as");
577 IDENTIFIER_OPNAME_P (ansi_opname[(int) MODIFY_EXPR]) = 1;
578 ansi_assopname[(int) NOP_EXPR] = ansi_opname[(int) MODIFY_EXPR];
579 ansi_opname[(int) COMPOUND_EXPR] = get_identifier ("__cm");
580 IDENTIFIER_OPNAME_P (ansi_opname[(int) COMPOUND_EXPR]) = 1;
581 ansi_opname[(int) EXACT_DIV_EXPR] = get_identifier ("__dv");
582 IDENTIFIER_OPNAME_P (ansi_opname[(int) EXACT_DIV_EXPR]) = 1;
583 ansi_assopname[(int) EXACT_DIV_EXPR] = get_identifier ("__adv");
584 IDENTIFIER_OPNAME_P (ansi_assopname[(int) EXACT_DIV_EXPR]) = 1;
585 ansi_opname[(int) TRUNC_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
586 ansi_opname[(int) CEIL_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
587 ansi_opname[(int) FLOOR_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
588 ansi_opname[(int) ROUND_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
589 ansi_opname[(int) PLUS_EXPR] = get_identifier ("__pl");
590 ansi_assopname[(int) TRUNC_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
591 ansi_assopname[(int) CEIL_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
592 ansi_assopname[(int) FLOOR_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
593 ansi_assopname[(int) ROUND_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
594 IDENTIFIER_OPNAME_P (ansi_opname[(int) PLUS_EXPR]) = 1;
595 ansi_assopname[(int) PLUS_EXPR] = get_identifier ("__apl");
596 IDENTIFIER_OPNAME_P (ansi_assopname[(int) PLUS_EXPR]) = 1;
597 ansi_opname[(int) CONVERT_EXPR] = ansi_opname[(int) PLUS_EXPR];
598 ansi_assopname[(int) CONVERT_EXPR] = ansi_assopname[(int) PLUS_EXPR];
599 ansi_opname[(int) LSHIFT_EXPR] = get_identifier ("__ls");
600 IDENTIFIER_OPNAME_P (ansi_opname[(int) LSHIFT_EXPR]) = 1;
601 ansi_assopname[(int) LSHIFT_EXPR] = get_identifier ("__als");
602 IDENTIFIER_OPNAME_P (ansi_assopname[(int) LSHIFT_EXPR]) = 1;
603 ansi_opname[(int) EQ_EXPR] = get_identifier ("__eq");
604 IDENTIFIER_OPNAME_P (ansi_opname[(int) EQ_EXPR]) = 1;
605 ansi_opname[(int) LT_EXPR] = get_identifier ("__lt");
606 IDENTIFIER_OPNAME_P (ansi_opname[(int) LT_EXPR]) = 1;
607 ansi_opname[(int) LE_EXPR] = get_identifier ("__le");
608 IDENTIFIER_OPNAME_P (ansi_opname[(int) LE_EXPR]) = 1;
609 ansi_opname[(int) BIT_AND_EXPR] = get_identifier ("__ad");
610 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_AND_EXPR]) = 1;
611 ansi_assopname[(int) BIT_AND_EXPR] = get_identifier ("__aad");
612 IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_AND_EXPR]) = 1;
613 ansi_opname[(int) ADDR_EXPR] = ansi_opname[(int) BIT_AND_EXPR];
614 ansi_assopname[(int) ADDR_EXPR] = ansi_assopname[(int) BIT_AND_EXPR];
615 ansi_opname[(int) BIT_XOR_EXPR] = get_identifier ("__er");
616 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_XOR_EXPR]) = 1;
617 ansi_assopname[(int) BIT_XOR_EXPR] = get_identifier ("__aer");
618 IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_XOR_EXPR]) = 1;
619 ansi_opname[(int) TRUTH_ORIF_EXPR] = get_identifier ("__oo");
620 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_ORIF_EXPR]) = 1;
621 ansi_opname[(int) BIT_NOT_EXPR] = get_identifier ("__co");
622 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_NOT_EXPR]) = 1;
623 ansi_opname[(int) PREDECREMENT_EXPR] = get_identifier ("__mm");
624 IDENTIFIER_OPNAME_P (ansi_opname[(int) PREDECREMENT_EXPR]) = 1;
625 ansi_opname[(int) POSTDECREMENT_EXPR] = ansi_opname[(int) PREDECREMENT_EXPR];
626 ansi_opname[(int) COMPONENT_REF] = get_identifier ("__rf");
627 IDENTIFIER_OPNAME_P (ansi_opname[(int) COMPONENT_REF]) = 1;
628 ansi_opname[(int) MEMBER_REF] = get_identifier ("__rm");
629 IDENTIFIER_OPNAME_P (ansi_opname[(int) MEMBER_REF]) = 1;
630 ansi_opname[(int) CALL_EXPR] = get_identifier ("__cl");
631 IDENTIFIER_OPNAME_P (ansi_opname[(int) CALL_EXPR]) = 1;
632 ansi_opname[(int) ARRAY_REF] = get_identifier ("__vc");
633 IDENTIFIER_OPNAME_P (ansi_opname[(int) ARRAY_REF]) = 1;
634 ansi_opname[(int) NEW_EXPR] = get_identifier ("__nw");
635 IDENTIFIER_OPNAME_P (ansi_opname[(int) NEW_EXPR]) = 1;
636 ansi_opname[(int) DELETE_EXPR] = get_identifier ("__dl");
637 IDENTIFIER_OPNAME_P (ansi_opname[(int) DELETE_EXPR]) = 1;
638 ansi_opname[(int) VEC_NEW_EXPR] = get_identifier ("__vn");
639 IDENTIFIER_OPNAME_P (ansi_opname[(int) VEC_NEW_EXPR]) = 1;
640 ansi_opname[(int) VEC_DELETE_EXPR] = get_identifier ("__vd");
641 IDENTIFIER_OPNAME_P (ansi_opname[(int) VEC_DELETE_EXPR]) = 1;
642 ansi_opname[(int) TYPE_EXPR] = get_identifier ("__op");
643 IDENTIFIER_OPNAME_P (ansi_opname[(int) TYPE_EXPR]) = 1;
645 /* This is not true: these operators are not defined in ANSI,
646 but we need them anyway. */
647 ansi_opname[(int) MIN_EXPR] = get_identifier ("__mn");
648 IDENTIFIER_OPNAME_P (ansi_opname[(int) MIN_EXPR]) = 1;
649 ansi_opname[(int) MAX_EXPR] = get_identifier ("__mx");
650 IDENTIFIER_OPNAME_P (ansi_opname[(int) MAX_EXPR]) = 1;
651 ansi_opname[(int) COND_EXPR] = get_identifier ("__cn");
652 IDENTIFIER_OPNAME_P (ansi_opname[(int) COND_EXPR]) = 1;
653 ansi_opname[(int) SIZEOF_EXPR] = get_identifier ("__sz");
654 IDENTIFIER_OPNAME_P (ansi_opname[(int) SIZEOF_EXPR]) = 1;
658 gcc_obstack_init (&inline_text_obstack);
659 inline_text_firstobj = (char *) obstack_alloc (&inline_text_obstack, 0);
661 /* Start it at 0, because check_newline is called at the very beginning
662 and will increment it to 1. */
664 input_filename = "<internal>";
665 current_function_decl = NULL;
668 token_buffer = (char *) xmalloc (maxtoken + 2);
670 ridpointers[(int) RID_INT] = get_identifier ("int");
671 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INT],
672 build_tree_list (NULL_TREE, ridpointers[(int) RID_INT]));
673 ridpointers[(int) RID_BOOL] = get_identifier ("bool");
674 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_BOOL],
675 build_tree_list (NULL_TREE, ridpointers[(int) RID_BOOL]));
676 ridpointers[(int) RID_CHAR] = get_identifier ("char");
677 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CHAR],
678 build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]));
679 ridpointers[(int) RID_VOID] = get_identifier ("void");
680 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOID],
681 build_tree_list (NULL_TREE, ridpointers[(int) RID_VOID]));
682 ridpointers[(int) RID_FLOAT] = get_identifier ("float");
683 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FLOAT],
684 build_tree_list (NULL_TREE, ridpointers[(int) RID_FLOAT]));
685 ridpointers[(int) RID_DOUBLE] = get_identifier ("double");
686 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_DOUBLE],
687 build_tree_list (NULL_TREE, ridpointers[(int) RID_DOUBLE]));
688 ridpointers[(int) RID_SHORT] = get_identifier ("short");
689 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SHORT],
690 build_tree_list (NULL_TREE, ridpointers[(int) RID_SHORT]));
691 ridpointers[(int) RID_LONG] = get_identifier ("long");
692 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_LONG],
693 build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]));
694 ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned");
695 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_UNSIGNED],
696 build_tree_list (NULL_TREE, ridpointers[(int) RID_UNSIGNED]));
697 ridpointers[(int) RID_SIGNED] = get_identifier ("signed");
698 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SIGNED],
699 build_tree_list (NULL_TREE, ridpointers[(int) RID_SIGNED]));
700 ridpointers[(int) RID_INLINE] = get_identifier ("inline");
701 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INLINE],
702 build_tree_list (NULL_TREE, ridpointers[(int) RID_INLINE]));
703 ridpointers[(int) RID_CONST] = get_identifier ("const");
704 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CONST],
705 build_tree_list (NULL_TREE, ridpointers[(int) RID_CONST]));
706 ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
707 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOLATILE],
708 build_tree_list (NULL_TREE, ridpointers[(int) RID_VOLATILE]));
709 ridpointers[(int) RID_AUTO] = get_identifier ("auto");
710 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_AUTO],
711 build_tree_list (NULL_TREE, ridpointers[(int) RID_AUTO]));
712 ridpointers[(int) RID_STATIC] = get_identifier ("static");
713 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_STATIC],
714 build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC]));
715 ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
716 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_EXTERN],
717 build_tree_list (NULL_TREE, ridpointers[(int) RID_EXTERN]));
718 ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
719 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_TYPEDEF],
720 build_tree_list (NULL_TREE, ridpointers[(int) RID_TYPEDEF]));
721 ridpointers[(int) RID_REGISTER] = get_identifier ("register");
722 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_REGISTER],
723 build_tree_list (NULL_TREE, ridpointers[(int) RID_REGISTER]));
724 ridpointers[(int) RID_COMPLEX] = get_identifier ("__complex");
725 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_COMPLEX],
726 build_tree_list (NULL_TREE, ridpointers[(int) RID_COMPLEX]));
728 /* C++ extensions. These are probably not correctly named. */
729 ridpointers[(int) RID_WCHAR] = get_identifier ("__wchar_t");
730 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_WCHAR],
731 build_tree_list (NULL_TREE, ridpointers[(int) RID_WCHAR]));
732 class_type_node = build_int_2 (class_type, 0);
733 TREE_TYPE (class_type_node) = class_type_node;
734 ridpointers[(int) RID_CLASS] = class_type_node;
736 record_type_node = build_int_2 (record_type, 0);
737 TREE_TYPE (record_type_node) = record_type_node;
738 ridpointers[(int) RID_RECORD] = record_type_node;
740 union_type_node = build_int_2 (union_type, 0);
741 TREE_TYPE (union_type_node) = union_type_node;
742 ridpointers[(int) RID_UNION] = union_type_node;
744 enum_type_node = build_int_2 (enum_type, 0);
745 TREE_TYPE (enum_type_node) = enum_type_node;
746 ridpointers[(int) RID_ENUM] = enum_type_node;
748 ridpointers[(int) RID_VIRTUAL] = get_identifier ("virtual");
749 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VIRTUAL],
750 build_tree_list (NULL_TREE, ridpointers[(int) RID_VIRTUAL]));
751 ridpointers[(int) RID_EXPLICIT] = get_identifier ("explicit");
752 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_EXPLICIT],
753 build_tree_list (NULL_TREE, ridpointers[(int) RID_EXPLICIT]));
754 ridpointers[(int) RID_FRIEND] = get_identifier ("friend");
755 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FRIEND],
756 build_tree_list (NULL_TREE, ridpointers[(int) RID_FRIEND]));
758 ridpointers[(int) RID_PUBLIC] = get_identifier ("public");
759 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_PUBLIC],
760 build_tree_list (NULL_TREE, ridpointers[(int) RID_PUBLIC]));
761 ridpointers[(int) RID_PRIVATE] = get_identifier ("private");
762 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_PRIVATE],
763 build_tree_list (NULL_TREE, ridpointers[(int) RID_PRIVATE]));
764 ridpointers[(int) RID_PROTECTED] = get_identifier ("protected");
765 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_PROTECTED],
766 build_tree_list (NULL_TREE, ridpointers[(int) RID_PROTECTED]));
767 ridpointers[(int) RID_TEMPLATE] = get_identifier ("template");
768 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_TEMPLATE],
769 build_tree_list (NULL_TREE, ridpointers[(int) RID_TEMPLATE]));
770 /* This is for ANSI C++. */
771 ridpointers[(int) RID_MUTABLE] = get_identifier ("mutable");
772 SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_MUTABLE],
773 build_tree_list (NULL_TREE, ridpointers[(int) RID_MUTABLE]));
775 /* Signature handling extensions. */
776 signature_type_node = build_int_2 (signature_type, 0);
777 TREE_TYPE (signature_type_node) = signature_type_node;
778 ridpointers[(int) RID_SIGNATURE] = signature_type_node;
780 /* Create the built-in __null node. Note that we can't yet call for
781 type_for_size here because integer_type_node and so forth are not
782 set up. Therefore, we don't set the type of these nodes until
783 init_decl_processing. */
784 null_node = build_int_2 (0, 0);
785 ridpointers[RID_NULL] = null_node;
787 opname_tab[(int) COMPONENT_REF] = "->";
788 opname_tab[(int) MEMBER_REF] = "->*";
789 opname_tab[(int) INDIRECT_REF] = "*";
790 opname_tab[(int) ARRAY_REF] = "[]";
791 opname_tab[(int) MODIFY_EXPR] = "=";
792 opname_tab[(int) NEW_EXPR] = "new";
793 opname_tab[(int) DELETE_EXPR] = "delete";
794 opname_tab[(int) VEC_NEW_EXPR] = "new []";
795 opname_tab[(int) VEC_DELETE_EXPR] = "delete []";
796 opname_tab[(int) COND_EXPR] = "?:";
797 opname_tab[(int) CALL_EXPR] = "()";
798 opname_tab[(int) PLUS_EXPR] = "+";
799 opname_tab[(int) MINUS_EXPR] = "-";
800 opname_tab[(int) MULT_EXPR] = "*";
801 opname_tab[(int) TRUNC_DIV_EXPR] = "/";
802 opname_tab[(int) CEIL_DIV_EXPR] = "(ceiling /)";
803 opname_tab[(int) FLOOR_DIV_EXPR] = "(floor /)";
804 opname_tab[(int) ROUND_DIV_EXPR] = "(round /)";
805 opname_tab[(int) TRUNC_MOD_EXPR] = "%";
806 opname_tab[(int) CEIL_MOD_EXPR] = "(ceiling %)";
807 opname_tab[(int) FLOOR_MOD_EXPR] = "(floor %)";
808 opname_tab[(int) ROUND_MOD_EXPR] = "(round %)";
809 opname_tab[(int) NEGATE_EXPR] = "-";
810 opname_tab[(int) MIN_EXPR] = "<?";
811 opname_tab[(int) MAX_EXPR] = ">?";
812 opname_tab[(int) ABS_EXPR] = "abs";
813 opname_tab[(int) FFS_EXPR] = "ffs";
814 opname_tab[(int) LSHIFT_EXPR] = "<<";
815 opname_tab[(int) RSHIFT_EXPR] = ">>";
816 opname_tab[(int) BIT_IOR_EXPR] = "|";
817 opname_tab[(int) BIT_XOR_EXPR] = "^";
818 opname_tab[(int) BIT_AND_EXPR] = "&";
819 opname_tab[(int) BIT_ANDTC_EXPR] = "&~";
820 opname_tab[(int) BIT_NOT_EXPR] = "~";
821 opname_tab[(int) TRUTH_ANDIF_EXPR] = "&&";
822 opname_tab[(int) TRUTH_ORIF_EXPR] = "||";
823 opname_tab[(int) TRUTH_AND_EXPR] = "strict &&";
824 opname_tab[(int) TRUTH_OR_EXPR] = "strict ||";
825 opname_tab[(int) TRUTH_NOT_EXPR] = "!";
826 opname_tab[(int) LT_EXPR] = "<";
827 opname_tab[(int) LE_EXPR] = "<=";
828 opname_tab[(int) GT_EXPR] = ">";
829 opname_tab[(int) GE_EXPR] = ">=";
830 opname_tab[(int) EQ_EXPR] = "==";
831 opname_tab[(int) NE_EXPR] = "!=";
832 opname_tab[(int) IN_EXPR] = "in";
833 opname_tab[(int) RANGE_EXPR] = "...";
834 opname_tab[(int) CONVERT_EXPR] = "+";
835 opname_tab[(int) ADDR_EXPR] = "&";
836 opname_tab[(int) PREDECREMENT_EXPR] = "--";
837 opname_tab[(int) PREINCREMENT_EXPR] = "++";
838 opname_tab[(int) POSTDECREMENT_EXPR] = "--";
839 opname_tab[(int) POSTINCREMENT_EXPR] = "++";
840 opname_tab[(int) COMPOUND_EXPR] = ",";
842 assignop_tab[(int) NOP_EXPR] = "=";
843 assignop_tab[(int) PLUS_EXPR] = "+=";
844 assignop_tab[(int) CONVERT_EXPR] = "+=";
845 assignop_tab[(int) MINUS_EXPR] = "-=";
846 assignop_tab[(int) NEGATE_EXPR] = "-=";
847 assignop_tab[(int) MULT_EXPR] = "*=";
848 assignop_tab[(int) INDIRECT_REF] = "*=";
849 assignop_tab[(int) TRUNC_DIV_EXPR] = "/=";
850 assignop_tab[(int) EXACT_DIV_EXPR] = "(exact /=)";
851 assignop_tab[(int) CEIL_DIV_EXPR] = "(ceiling /=)";
852 assignop_tab[(int) FLOOR_DIV_EXPR] = "(floor /=)";
853 assignop_tab[(int) ROUND_DIV_EXPR] = "(round /=)";
854 assignop_tab[(int) TRUNC_MOD_EXPR] = "%=";
855 assignop_tab[(int) CEIL_MOD_EXPR] = "(ceiling %=)";
856 assignop_tab[(int) FLOOR_MOD_EXPR] = "(floor %=)";
857 assignop_tab[(int) ROUND_MOD_EXPR] = "(round %=)";
858 assignop_tab[(int) MIN_EXPR] = "<?=";
859 assignop_tab[(int) MAX_EXPR] = ">?=";
860 assignop_tab[(int) LSHIFT_EXPR] = "<<=";
861 assignop_tab[(int) RSHIFT_EXPR] = ">>=";
862 assignop_tab[(int) BIT_IOR_EXPR] = "|=";
863 assignop_tab[(int) BIT_XOR_EXPR] = "^=";
864 assignop_tab[(int) BIT_AND_EXPR] = "&=";
865 assignop_tab[(int) ADDR_EXPR] = "&=";
867 init_filename_times ();
869 /* Some options inhibit certain reserved words.
870 Clear those words out of the hash table so they won't be recognized. */
871 #define UNSET_RESERVED_WORD(STRING) \
872 do { struct resword *s = is_reserved_word (STRING, sizeof (STRING) - 1); \
873 if (s) s->name = ""; } while (0)
876 /* let's parse things, and if they use it, then give them an error. */
877 if (!flag_exceptions)
879 UNSET_RESERVED_WORD ("throw");
880 UNSET_RESERVED_WORD ("try");
881 UNSET_RESERVED_WORD ("catch");
885 if (!flag_rtti || flag_no_gnu_keywords)
887 UNSET_RESERVED_WORD ("classof");
888 UNSET_RESERVED_WORD ("headof");
891 if (! flag_handle_signatures || flag_no_gnu_keywords)
893 /* Easiest way to not recognize signature
894 handling extensions... */
895 UNSET_RESERVED_WORD ("signature");
896 UNSET_RESERVED_WORD ("sigof");
898 if (flag_no_asm || flag_no_gnu_keywords)
899 UNSET_RESERVED_WORD ("typeof");
900 if (! flag_operator_names)
902 /* These are new ANSI keywords that may break code. */
903 UNSET_RESERVED_WORD ("and");
904 UNSET_RESERVED_WORD ("and_eq");
905 UNSET_RESERVED_WORD ("bitand");
906 UNSET_RESERVED_WORD ("bitor");
907 UNSET_RESERVED_WORD ("compl");
908 UNSET_RESERVED_WORD ("not");
909 UNSET_RESERVED_WORD ("not_eq");
910 UNSET_RESERVED_WORD ("or");
911 UNSET_RESERVED_WORD ("or_eq");
912 UNSET_RESERVED_WORD ("xor");
913 UNSET_RESERVED_WORD ("xor_eq");
916 token_count = init_cpp_parse ();
917 interface_unknown = 1;
926 cpp_finish (&parse_in);
933 reinit_parse_for_function ()
935 current_base_init_list = NULL_TREE;
936 current_member_init_list = NULL_TREE;
943 yyprint (file, yychar, yylval)
955 case IDENTIFIER_DEFN:
959 case PRE_PARSED_CLASS_DECL:
961 if (TREE_CODE (t) == TYPE_DECL || TREE_CODE (t) == TEMPLATE_DECL)
963 fprintf (file, " `%s'", IDENTIFIER_POINTER (DECL_NAME (t)));
966 my_friendly_assert (TREE_CODE (t) == IDENTIFIER_NODE, 224);
967 if (IDENTIFIER_POINTER (t))
968 fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
971 if (yylval.ttype == class_type_node)
972 fprintf (file, " `class'");
973 else if (yylval.ttype == record_type_node)
974 fprintf (file, " `struct'");
975 else if (yylval.ttype == union_type_node)
976 fprintf (file, " `union'");
977 else if (yylval.ttype == enum_type_node)
978 fprintf (file, " `enum'");
979 else if (yylval.ttype == signature_type_node)
980 fprintf (file, " `signature'");
982 my_friendly_abort (80);
987 #if defined(GATHER_STATISTICS) && defined(REDUCE_LENGTH)
988 static int *reduce_count;
994 #define REDUCE_LENGTH (sizeof (yyr2) / sizeof (yyr2[0]))
995 #define TOKEN_LENGTH (256 + sizeof (yytname) / sizeof (yytname[0]))
998 #ifdef GATHER_STATISTICS
1004 reduce_count[yyn] += 1;
1011 return reduce_count[*q] - reduce_count[*p];
1018 return token_count[*q] - token_count[*p];
1024 print_parse_statistics ()
1026 #ifdef GATHER_STATISTICS
1027 #ifdef REDUCE_LENGTH
1030 int maxlen = REDUCE_LENGTH;
1033 if (reduce_count[-1] == 0)
1036 if (TOKEN_LENGTH > REDUCE_LENGTH)
1037 maxlen = TOKEN_LENGTH;
1038 sorted = (unsigned *) alloca (sizeof (int) * maxlen);
1040 for (i = 0; i < TOKEN_LENGTH; i++)
1042 qsort (sorted, TOKEN_LENGTH, sizeof (int), token_cmp);
1043 for (i = 0; i < TOKEN_LENGTH; i++)
1045 int idx = sorted[i];
1046 if (token_count[idx] == 0)
1048 if (token_count[idx] < token_count[-1])
1050 fprintf (stderr, "token %d, `%s', count = %d\n",
1051 idx, yytname[YYTRANSLATE (idx)], token_count[idx]);
1053 fprintf (stderr, "\n");
1054 for (i = 0; i < REDUCE_LENGTH; i++)
1056 qsort (sorted, REDUCE_LENGTH, sizeof (int), reduce_cmp);
1057 for (i = 0; i < REDUCE_LENGTH; i++)
1059 int idx = sorted[i];
1060 if (reduce_count[idx] == 0)
1062 if (reduce_count[idx] < reduce_count[-1])
1064 fprintf (stderr, "rule %d, line %d, count = %d\n",
1065 idx, yyrline[idx], reduce_count[idx]);
1067 fprintf (stderr, "\n");
1073 /* Sets the value of the 'yydebug' variable to VALUE.
1074 This is a function so we don't have to have YYDEBUG defined
1075 in order to build the compiler. */
1085 warning ("YYDEBUG not defined.");
1090 /* Functions and data structures for #pragma interface.
1092 `#pragma implementation' means that the main file being compiled
1093 is considered to implement (provide) the classes that appear in
1094 its main body. I.e., if this is file "foo.cc", and class `bar'
1095 is defined in "foo.cc", then we say that "foo.cc implements bar".
1097 All main input files "implement" themselves automagically.
1099 `#pragma interface' means that unless this file (of the form "foo.h"
1100 is not presently being included by file "foo.cc", the
1101 CLASSTYPE_INTERFACE_ONLY bit gets set. The effect is that none
1102 of the vtables nor any of the inline functions defined in foo.h
1103 will ever be output.
1105 There are cases when we want to link files such as "defs.h" and
1106 "main.cc". In this case, we give "defs.h" a `#pragma interface',
1107 and "main.cc" has `#pragma implementation "defs.h"'. */
1112 struct impl_files *next;
1115 static struct impl_files *impl_file_chain;
1117 /* Helper function to load global variables with interface
1121 extract_interface_info ()
1125 if (flag_alt_external_templates)
1127 struct tinst_level *til = tinst_for_decl ();
1130 fileinfo = get_time_identifier (til->file);
1133 fileinfo = get_time_identifier (input_filename);
1134 fileinfo = IDENTIFIER_CLASS_VALUE (fileinfo);
1135 interface_only = TREE_INT_CST_LOW (fileinfo);
1136 interface_unknown = TREE_INT_CST_HIGH (fileinfo);
1139 /* Return nonzero if S is not considered part of an
1140 INTERFACE/IMPLEMENTATION pair. Otherwise, return 0. */
1143 interface_strcmp (s)
1146 /* Set the interface/implementation bits for this scope. */
1147 struct impl_files *ifiles;
1150 for (ifiles = impl_file_chain; ifiles; ifiles = ifiles->next)
1152 char *t1 = ifiles->filename;
1155 if (*s1 != *t1 || *s1 == 0)
1158 while (*s1 == *t1 && *s1 != 0)
1165 /* Don't get faked out by xxx.yyy.cc vs xxx.zzz.cc. */
1166 if (index (s1, '.') || index (t1, '.'))
1169 if (*s1 == '\0' || s1[-1] != '.' || t1[-1] != '.')
1181 set_typedecl_interface_info (prev, vars)
1184 tree id = get_time_identifier (DECL_SOURCE_FILE (vars));
1185 tree fileinfo = IDENTIFIER_CLASS_VALUE (id);
1186 tree type = TREE_TYPE (vars);
1188 CLASSTYPE_INTERFACE_ONLY (type) = TREE_INT_CST_LOW (fileinfo)
1189 = interface_strcmp (file_name_nondirectory (DECL_SOURCE_FILE (vars)));
1193 set_vardecl_interface_info (prev, vars)
1196 tree type = DECL_CONTEXT (vars);
1198 if (CLASSTYPE_INTERFACE_KNOWN (type))
1200 if (CLASSTYPE_INTERFACE_ONLY (type))
1201 set_typedecl_interface_info (prev, TYPE_MAIN_DECL (type));
1203 CLASSTYPE_VTABLE_NEEDS_WRITING (type) = 1;
1204 DECL_EXTERNAL (vars) = CLASSTYPE_INTERFACE_ONLY (type);
1205 TREE_PUBLIC (vars) = 1;
1211 /* Called from the top level: if there are any pending inlines to
1212 do, set up to process them now. This function sets up the first function
1213 to be parsed; after it has been, the rule for fndef in parse.y will
1214 call process_next_inline to start working on the next one. */
1217 do_pending_inlines ()
1219 struct pending_inline *t;
1222 /* Oops, we're still dealing with the last batch. */
1223 if (yychar == PRE_PARSED_FUNCTION_DECL)
1226 /* Reverse the pending inline functions, since
1227 they were cons'd instead of appended. */
1229 struct pending_inline *prev = 0, *tail;
1230 t = pending_inlines;
1231 pending_inlines = 0;
1246 /* Now start processing the first inline function. */
1247 context = hack_decl_function_context (t->fndecl);
1249 push_cp_function_context (context);
1250 maybe_begin_member_template_processing (t->fndecl);
1253 feed_input (t->buf, t->len);
1256 if (input_filename != t->filename)
1258 input_filename = t->filename;
1259 /* Get interface/implementation back in sync. */
1260 extract_interface_info ();
1263 input_filename = t->filename;
1264 interface_unknown = t->interface == 1;
1265 interface_only = t->interface == 0;
1267 yychar = PRE_PARSED_FUNCTION_DECL;
1269 /* Pass back a handle on the rest of the inline functions, so that they
1270 can be processed later. */
1271 yylval.ttype = build_tree_list ((tree) t, t->fndecl);
1272 DECL_PENDING_INLINE_INFO (t->fndecl) = 0;
1275 static int nextchar = -1;
1277 /* Called from the fndecl rule in the parser when the function just parsed
1278 was declared using a PRE_PARSED_FUNCTION_DECL (i.e. came from
1279 do_pending_inlines). */
1282 process_next_inline (t)
1286 struct pending_inline *i = (struct pending_inline *) TREE_PURPOSE (t);
1287 context = hack_decl_function_context (i->fndecl);
1288 maybe_end_member_template_processing (i->fndecl);
1290 pop_cp_function_context (context);
1292 if (yychar == YYEMPTY)
1294 if (yychar != END_OF_SAVED_INPUT)
1296 error ("parse error at end of saved function text");
1298 /* restore_pending_input will abort unless yychar is either
1299 END_OF_SAVED_INPUT or YYEMPTY; since we already know we're
1300 hosed, feed back YYEMPTY. We also need to discard nextchar,
1301 since that may have gotten set as well. */
1306 if (i && i->fndecl != NULL_TREE)
1308 context = hack_decl_function_context (i->fndecl);
1310 push_cp_function_context (context);
1311 maybe_begin_member_template_processing (i->fndecl);
1312 feed_input (i->buf, i->len);
1314 input_filename = i->filename;
1315 yychar = PRE_PARSED_FUNCTION_DECL;
1316 yylval.ttype = build_tree_list ((tree) i, i->fndecl);
1317 DECL_PENDING_INLINE_INFO (i->fndecl) = 0;
1321 interface_unknown = i->interface == 1;
1322 interface_only = i->interface == 0;
1325 extract_interface_info ();
1328 /* Since inline methods can refer to text which has not yet been seen,
1329 we store the text of the method in a structure which is placed in the
1330 DECL_PENDING_INLINE_INFO field of the FUNCTION_DECL.
1331 After parsing the body of the class definition, the FUNCTION_DECL's are
1332 scanned to see which ones have this field set. Those are then digested
1335 This function's FUNCTION_DECL will have a bit set in its common so
1336 that we know to watch out for it. */
1339 consume_string (this_obstack, matching_char)
1340 register struct obstack *this_obstack;
1344 int starting_lineno = lineno;
1350 int save_lineno = lineno;
1351 lineno = starting_lineno;
1352 if (matching_char == '"')
1353 error ("end of file encountered inside string constant");
1355 error ("end of file encountered inside character constant");
1356 lineno = save_lineno;
1361 obstack_1grow (this_obstack, c);
1363 obstack_1grow (this_obstack, c);
1365 /* Make sure we continue the loop */
1372 pedwarn ("ANSI C++ forbids newline in string constant");
1375 obstack_1grow (this_obstack, c);
1377 while (c != matching_char);
1380 static int nextyychar = YYEMPTY;
1381 static YYSTYPE nextyylval;
1383 struct pending_input {
1384 int nextchar, yychar, nextyychar, eof;
1385 YYSTYPE yylval, nextyylval;
1386 struct obstack token_obstack;
1390 struct pending_input *
1391 save_pending_input ()
1393 struct pending_input *p;
1394 p = (struct pending_input *) xmalloc (sizeof (struct pending_input));
1395 p->nextchar = nextchar;
1397 p->nextyychar = nextyychar;
1399 p->nextyylval = nextyylval;
1400 p->eof = end_of_file;
1401 yychar = nextyychar = YYEMPTY;
1403 p->first_token = first_token;
1404 p->token_obstack = token_obstack;
1407 gcc_obstack_init (&token_obstack);
1413 restore_pending_input (p)
1414 struct pending_input *p;
1416 my_friendly_assert (nextchar == -1, 229);
1417 nextchar = p->nextchar;
1418 my_friendly_assert (yychar == YYEMPTY || yychar == END_OF_SAVED_INPUT, 230);
1420 my_friendly_assert (nextyychar == YYEMPTY, 231);
1421 nextyychar = p->nextyychar;
1423 nextyylval = p->nextyylval;
1424 first_token = p->first_token;
1425 obstack_free (&token_obstack, (char *) 0);
1426 token_obstack = p->token_obstack;
1427 end_of_file = p->eof;
1431 /* Unget character CH from the input stream.
1432 If RESCAN is non-zero, then we want to `see' this
1433 character as the next input token. */
1436 yyungetc (ch, rescan)
1440 /* Unget a character from the input stream. */
1441 if (yychar == YYEMPTY || rescan == 0)
1444 put_back (nextchar);
1449 my_friendly_assert (nextyychar == YYEMPTY, 232);
1450 nextyychar = yychar;
1451 nextyylval = yylval;
1457 clear_inline_text_obstack ()
1459 obstack_free (&inline_text_obstack, inline_text_firstobj);
1462 /* This function stores away the text for an inline function that should
1463 be processed later. It decides how much later, and may need to move
1464 the info between obstacks; therefore, the caller should not refer to
1465 the T parameter after calling this function. */
1468 store_pending_inline (decl, t)
1470 struct pending_inline *t;
1473 DECL_PENDING_INLINE_INFO (decl) = t;
1475 /* Because we use obstacks, we must process these in precise order. */
1476 t->next = pending_inlines;
1477 pending_inlines = t;
1481 reinit_parse_for_method (yychar, decl)
1486 int starting_lineno = lineno;
1487 char *starting_filename = input_filename;
1489 reinit_parse_for_block (yychar, &inline_text_obstack);
1491 len = obstack_object_size (&inline_text_obstack);
1492 current_base_init_list = NULL_TREE;
1493 current_member_init_list = NULL_TREE;
1494 if (decl == void_type_node
1495 || (current_class_type && TYPE_REDEFINED (current_class_type)))
1497 /* Happens when we get two declarations of the same
1498 function in the same scope. */
1499 char *buf = obstack_finish (&inline_text_obstack);
1500 obstack_free (&inline_text_obstack, buf);
1505 struct pending_inline *t;
1506 char *buf = obstack_finish (&inline_text_obstack);
1508 t = (struct pending_inline *) obstack_alloc (&inline_text_obstack,
1509 sizeof (struct pending_inline));
1510 t->lineno = starting_lineno;
1511 t->filename = starting_filename;
1518 if (interface_unknown && processing_template_defn && flag_external_templates && ! DECL_IN_SYSTEM_HEADER (decl))
1519 warn_if_unknown_interface (decl);
1521 t->interface = (interface_unknown ? 1 : (interface_only ? 0 : 2));
1522 store_pending_inline (decl, t);
1526 /* Consume a block -- actually, a method beginning
1527 with `:' or `{' -- and save it away on the specified obstack. */
1530 reinit_parse_for_block (pyychar, obstackp)
1532 struct obstack *obstackp;
1536 int starting_lineno = lineno;
1537 char *starting_filename = input_filename;
1539 int look_for_semicolon = 0;
1540 int look_for_lbrac = 0;
1543 obstack_1grow (obstackp, '{');
1544 else if (pyychar == '=')
1545 look_for_semicolon = 1;
1546 else if (pyychar == ':')
1548 obstack_1grow (obstackp, pyychar);
1552 else if (pyychar == RETURN)
1554 obstack_grow (obstackp, "return", 6);
1558 else if (pyychar == TRY)
1560 obstack_grow (obstackp, "try", 3);
1566 yyerror ("parse error in method specification");
1567 obstack_1grow (obstackp, '{');
1570 if (nextchar != EOF)
1580 int this_lineno = lineno;
1582 c = skip_white_space (c);
1584 /* Don't lose our cool if there are lots of comments. */
1585 if (lineno == this_lineno + 1)
1586 obstack_1grow (obstackp, '\n');
1587 else if (lineno == this_lineno)
1589 else if (lineno - this_lineno < 10)
1592 for (i = lineno - this_lineno; i > 0; i--)
1593 obstack_1grow (obstackp, '\n');
1598 sprintf (buf, "\n# %d \"", lineno);
1600 obstack_grow (obstackp, buf, len);
1602 len = strlen (input_filename);
1603 obstack_grow (obstackp, input_filename, len);
1604 obstack_1grow (obstackp, '\"');
1605 obstack_1grow (obstackp, '\n');
1608 while (c > ' ') /* ASCII dependent... */
1610 obstack_1grow (obstackp, c);
1619 if (blev == 0 && !look_for_semicolon)
1623 if (peekyylex () == CATCH)
1626 obstack_grow (obstackp, " catch ", 7);
1643 /* Don't act on the next character...e.g, doing an escaped
1648 error_with_file_and_line (starting_filename,
1650 "end of file read inside definition");
1653 obstack_1grow (obstackp, c);
1656 consume_string (obstackp, c);
1658 consume_string (obstackp, c);
1663 error ("function body for constructor missing");
1664 obstack_1grow (obstackp, '{');
1665 obstack_1grow (obstackp, '}');
1669 else if (look_for_semicolon && blev == 0)
1677 error_with_file_and_line (starting_filename,
1679 "end of file read inside definition");
1684 obstack_1grow (obstackp, c);
1689 obstack_1grow (obstackp, '\0');
1692 /* Consume a no-commas expression -- actually, a default argument -- and
1693 save it away on the specified obstack. */
1696 reinit_parse_for_expr (obstackp)
1697 struct obstack *obstackp;
1700 int starting_lineno = lineno;
1701 char *starting_filename = input_filename;
1705 if (nextchar != EOF)
1715 int this_lineno = lineno;
1717 c = skip_white_space (c);
1719 /* Don't lose our cool if there are lots of comments. */
1720 if (lineno == this_lineno + 1)
1721 obstack_1grow (obstackp, '\n');
1722 else if (lineno == this_lineno)
1724 else if (lineno - this_lineno < 10)
1727 for (i = lineno - this_lineno; i > 0; --i)
1728 obstack_1grow (obstackp, '\n');
1733 sprintf (buf, "\n# %d \"", lineno);
1735 obstack_grow (obstackp, buf, len);
1737 len = strlen (input_filename);
1738 obstack_grow (obstackp, input_filename, len);
1739 obstack_1grow (obstackp, '\"');
1740 obstack_1grow (obstackp, '\n');
1743 while (c > ' ') /* ASCII dependent... */
1745 if (plev <= 0 && (c == ')' || c == ','))
1750 obstack_1grow (obstackp, c);
1751 if (c == '(' || c == '[')
1753 else if (c == ']' || c == ')')
1757 /* Don't act on the next character...e.g, doing an escaped
1762 error_with_file_and_line (starting_filename,
1764 "end of file read inside definition");
1767 obstack_1grow (obstackp, c);
1770 consume_string (obstackp, c);
1772 consume_string (obstackp, c);
1778 error_with_file_and_line (starting_filename,
1780 "end of file read inside definition");
1785 obstack_1grow (obstackp, c);
1790 obstack_1grow (obstackp, '\0');
1793 int do_snarf_defarg;
1795 /* Decide whether the default argument we are about to see should be
1796 gobbled up as text for later parsing. */
1799 maybe_snarf_defarg ()
1801 if (current_class_type && TYPE_BEING_DEFINED (current_class_type))
1802 do_snarf_defarg = 1;
1805 /* When we see a default argument in a method declaration, we snarf it as
1806 text using snarf_defarg. When we get up to namespace scope, we then go
1807 through and parse all of them using do_pending_defargs. Since yacc
1808 parsers are not reentrant, we retain defargs state in these two
1809 variables so that subsequent calls to do_pending_defargs can resume
1810 where the previous call left off. */
1822 reinit_parse_for_expr (&inline_text_obstack);
1823 len = obstack_object_size (&inline_text_obstack);
1824 buf = obstack_finish (&inline_text_obstack);
1826 push_obstacks (&inline_text_obstack, &inline_text_obstack);
1827 arg = make_node (DEFAULT_ARG);
1828 DEFARG_LENGTH (arg) = len - 1;
1829 DEFARG_POINTER (arg) = buf;
1835 /* Called from grokfndecl to note a function decl with unparsed default
1836 arguments for later processing. Also called from grokdeclarator
1837 for function types with unparsed defargs; the call from grokfndecl
1838 will always come second, so we can overwrite the entry from the type. */
1841 add_defarg_fn (decl)
1844 if (TREE_CODE (decl) == FUNCTION_DECL)
1845 TREE_VALUE (defarg_fns) = decl;
1848 push_obstacks (&inline_text_obstack, &inline_text_obstack);
1849 defarg_fns = tree_cons (current_class_type, decl, defarg_fns);
1854 /* Helper for do_pending_defargs. Starts the parsing of a default arg. */
1860 tree d = TREE_PURPOSE (p);
1861 feed_input (DEFARG_POINTER (d), DEFARG_LENGTH (d));
1862 if (TREE_CODE (f) == FUNCTION_DECL)
1864 lineno = DECL_SOURCE_LINE (f);
1865 input_filename = DECL_SOURCE_FILE (f);
1867 yychar = DEFARG_MARKER;
1871 /* Helper for do_pending_defargs. Ends the parsing of a default arg. */
1876 if (yychar == YYEMPTY)
1878 if (yychar != END_OF_SAVED_INPUT)
1880 error ("parse error at end of saved function text");
1882 /* restore_pending_input will abort unless yychar is either
1883 END_OF_SAVED_INPUT or YYEMPTY; since we already know we're
1884 hosed, feed back YYEMPTY. We also need to discard nextchar,
1885 since that may have gotten set as well. */
1892 /* Main function for deferred parsing of default arguments. Called from
1896 do_pending_defargs ()
1901 for (; defarg_fns; defarg_fns = TREE_CHAIN (defarg_fns))
1903 tree defarg_fn = TREE_VALUE (defarg_fns);
1904 if (defarg_parm == NULL_TREE)
1906 push_nested_class (TREE_PURPOSE (defarg_fns), 1);
1908 if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
1909 maybe_begin_member_template_processing (defarg_fn);
1911 if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
1915 for (p = DECL_ARGUMENTS (defarg_fn); p; p = TREE_CHAIN (p))
1916 pushdecl (copy_node (p));
1918 defarg_parm = TYPE_ARG_TYPES (TREE_TYPE (defarg_fn));
1921 defarg_parm = TYPE_ARG_TYPES (defarg_fn);
1924 defarg_parm = TREE_CHAIN (defarg_parm);
1926 for (; defarg_parm; defarg_parm = TREE_CHAIN (defarg_parm))
1927 if (TREE_PURPOSE (defarg_parm)
1928 && TREE_CODE (TREE_PURPOSE (defarg_parm)) == DEFAULT_ARG)
1930 feed_defarg (defarg_fn, defarg_parm);
1932 /* Return to the parser, which will process this defarg
1933 and call us again. */
1937 if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
1939 maybe_end_member_template_processing (defarg_fn);
1940 check_default_args (defarg_fn);
1944 pop_nested_class (1);
1948 /* Build a default function named NAME for type TYPE.
1949 KIND says what to build.
1951 When KIND == 0, build default destructor.
1952 When KIND == 1, build virtual destructor.
1953 When KIND == 2, build default constructor.
1954 When KIND == 3, build default X(const X&) constructor.
1955 When KIND == 4, build default X(X&) constructor.
1956 When KIND == 5, build default operator = (const X&).
1957 When KIND == 6, build default operator = (X&). */
1960 cons_up_default_function (type, full_name, kind)
1961 tree type, full_name;
1964 extern tree void_list_node;
1965 tree declspecs = NULL_TREE;
1966 tree fn, args = NULL_TREE;
1969 tree name = constructor_name (full_name);
1975 declspecs = build_decl_list (NULL_TREE, ridpointers [(int) RID_VIRTUAL]);
1976 /* Fall through... */
1978 name = build_parse_node (BIT_NOT_EXPR, name);
1979 args = void_list_node;
1983 /* Default constructor. */
1984 args = void_list_node;
1988 type = build_type_variant (type, 1, 0);
1989 /* Fall through... */
1991 /* According to ARM $12.8, the default copy ctor will be declared, but
1992 not defined, unless it's needed. */
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")),
2003 declspecs = build_decl_list (NULL_TREE, type);
2006 type = build_type_variant (type, 1, 0);
2008 name = ansi_opname [(int) MODIFY_EXPR];
2010 argtype = build_reference_type (type);
2011 args = tree_cons (NULL_TREE,
2012 build_tree_list (hash_tree_chain (argtype, NULL_TREE),
2013 get_identifier ("_ctor_arg")),
2018 my_friendly_abort (59);
2021 declspecs = decl_tree_cons (NULL_TREE, ridpointers [(int) RID_INLINE],
2024 TREE_PARMLIST (args) = 1;
2027 tree declarator = make_call_declarator (name, args, NULL_TREE, NULL_TREE);
2029 declarator = build_parse_node (ADDR_EXPR, declarator);
2031 fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE, NULL_TREE);
2034 if (fn == void_type_node)
2038 SET_DECL_ARTIFICIAL (TREE_CHAIN (DECL_ARGUMENTS (fn)));
2041 if (processing_template_defn)
2043 SET_DECL_IMPLICIT_INSTANTIATION (fn);
2044 repo_template_used (fn);
2049 if (CLASSTYPE_INTERFACE_KNOWN (type))
2051 DECL_INTERFACE_KNOWN (fn) = 1;
2052 DECL_NOT_REALLY_EXTERN (fn) = (!CLASSTYPE_INTERFACE_ONLY (type)
2053 && flag_implement_inlines);
2057 DECL_NOT_REALLY_EXTERN (fn) = 1;
2059 mark_inline_for_output (fn);
2061 #ifdef DEBUG_DEFAULT_FUNCTIONS
2062 { char *fn_type = NULL;
2066 case 0: fn_type = "default destructor"; break;
2067 case 1: fn_type = "virtual destructor"; break;
2068 case 2: fn_type = "default constructor"; break;
2069 case 3: fn_type = "default X(const X&)"; break;
2070 case 4: fn_type = "default X(X&)"; break;
2074 if (TREE_CODE (name) == BIT_NOT_EXPR)
2075 t = TREE_OPERAND (name, 0);
2076 fprintf (stderr, "[[[[ %s for %s:\n%s]]]]\n", fn_type,
2077 IDENTIFIER_POINTER (t), func_buf);
2080 #endif /* DEBUG_DEFAULT_FUNCTIONS */
2082 /* Show that this function was generated by the compiler. */
2083 SET_DECL_ARTIFICIAL (fn);
2088 /* Heuristic to tell whether the user is missing a semicolon
2089 after a struct or enum declaration. Emit an error message
2090 if we know the user has blown it. */
2093 check_for_missing_semicolon (type)
2101 && yychar != IDENTIFIER
2102 && yychar != TYPENAME
2103 && yychar != CV_QUALIFIER
2104 && yychar != SELFNAME)
2107 if (ANON_AGGRNAME_P (TYPE_IDENTIFIER (type)))
2108 error ("semicolon missing after %s declaration",
2109 TREE_CODE (type) == ENUMERAL_TYPE ? "enum" : "struct");
2111 cp_error ("semicolon missing after declaration of `%T'", type);
2112 shadow_tag (build_tree_list (0, type));
2114 /* Could probably also hack cases where class { ... } f (); appears. */
2119 note_got_semicolon (type)
2122 if (TREE_CODE_CLASS (TREE_CODE (type)) != 't')
2123 my_friendly_abort (60);
2124 if (IS_AGGR_TYPE (type))
2125 CLASSTYPE_GOT_SEMICOLON (type) = 1;
2129 note_list_got_semicolon (declspecs)
2134 for (link = declspecs; link; link = TREE_CHAIN (link))
2136 tree type = TREE_VALUE (link);
2137 if (TREE_CODE_CLASS (TREE_CODE (type)) == 't')
2138 note_got_semicolon (type);
2143 /* If C is not whitespace, return C.
2144 Otherwise skip whitespace and return first nonwhite char read. */
2147 skip_white_space (c)
2155 c = check_newline ();
2166 while (c == ' ' || c == '\t');
2174 error ("stray '\\' in program");
2186 /* Make the token buffer longer, preserving the data in it.
2187 P should point to just beyond the last valid character in the old buffer.
2188 The value we return is a pointer to the new buffer
2189 at a place corresponding to P. */
2192 extend_token_buffer (p)
2195 int offset = p - token_buffer;
2197 maxtoken = maxtoken * 2 + 10;
2198 token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2);
2200 return token_buffer + offset;
2204 get_last_nonwhite_on_line ()
2208 /* Is this the last nonwhite stuff on the line? */
2210 c = nextchar, nextchar = -1;
2214 while (c == ' ' || c == '\t')
2219 #if defined HANDLE_PRAGMA
2220 /* Local versions of these macros, that can be passed as function pointers. */
2226 if (nextchar != EOF)
2243 #endif /* HANDLE_PRAGMA */
2245 /* At the beginning of a line, increment the line number
2246 and process any #-directive on this line.
2247 If the line is a #-directive, read the entire line and return a newline.
2248 Otherwise, return the line's first non-whitespace character. */
2252 static int handle_cp_pragma PROTO((char *));
2260 /* Read first nonwhite char on the line. Do this before incrementing the
2261 line number, in case we're at the end of saved text. */
2265 while (c == ' ' || c == '\t');
2271 /* If not #, return it so caller will use it. */
2275 /* Don't read beyond this line. */
2278 /* Read first nonwhite char after the `#'. */
2282 while (c == ' ' || c == '\t');
2284 /* If a letter follows, then if the word here is `line', skip
2285 it and ignore it; otherwise, ignore the line, with an error
2286 if the word isn't `pragma'. */
2288 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
2298 token = real_yylex ();
2299 if (token == IDENTIFIER
2300 && TREE_CODE (yylval.ttype) == IDENTIFIER_NODE)
2302 /* If this is 1, we handled it; if it's -1, it was one we
2303 wanted but had something wrong with it. Only if it's
2304 0 was it not handled. */
2305 if (handle_cp_pragma (IDENTIFIER_POINTER (yylval.ttype)))
2308 else if (token == END_OF_LINE)
2311 #ifdef HANDLE_PRAGMA
2312 /* We invoke HANDLE_PRAGMA before HANDLE_SYSV_PRAGMA
2313 (if both are defined), in order to give the back
2314 end a chance to override the interpretation of
2315 SYSV style pragmas. */
2316 if (HANDLE_PRAGMA (pragma_getc, pragma_ungetc,
2317 IDENTIFIER_POINTER (yylval.ttype)))
2319 #endif /* HANDLE_PRAGMA */
2321 #ifdef HANDLE_SYSV_PRAGMA
2322 if (handle_sysv_pragma (token))
2324 #endif /* !HANDLE_SYSV_PRAGMA */
2326 /* Issue a warning message if we have been asked to do so.
2327 Ignoring unknown pragmas in system header file unless
2328 an explcit -Wunknown-pragmas has been given. */
2329 if (warn_unknown_pragmas > 1
2330 || (warn_unknown_pragmas && ! in_system_header))
2331 warning ("ignoring pragma: %s", token_buffer);
2343 && ((c = getch ()) == ' ' || c == '\t'))
2345 debug_define (lineno, GET_DIRECTIVE_LINE ());
2355 && ((c = getch ()) == ' ' || c == '\t'))
2357 debug_undef (lineno, GET_DIRECTIVE_LINE ());
2366 && ((c = getch ()) == ' ' || c == '\t'))
2375 && ((c = getch ()) == ' ' || c == '\t'))
2377 /* #ident. The pedantic warning is now in cccp.c. */
2379 /* Here we have just seen `#ident '.
2380 A string constant should follow. */
2382 token = real_yylex ();
2383 if (token == END_OF_LINE)
2386 || TREE_CODE (yylval.ttype) != STRING_CST)
2388 error ("invalid #ident");
2392 if (! flag_no_ident)
2394 #ifdef ASM_OUTPUT_IDENT
2395 ASM_OUTPUT_IDENT (asm_out_file,
2396 TREE_STRING_POINTER (yylval.ttype));
2400 /* Skip the rest of this line. */
2413 && ((c = getch ()) == ' ' || c == '\t'))
2415 /* Used to test incremental compilation. */
2416 sorry ("#pragma newworld");
2420 error ("undefined or invalid # directive");
2425 /* Here we have either `#line' or `# <nonletter>'.
2426 In either case, it should be a line number; a digit should follow. */
2428 while (c == ' ' || c == '\t')
2431 /* If the # is the only nonwhite char on the line,
2432 just ignore it. Check the new newline. */
2436 /* Something follows the #; read a token. */
2439 token = real_yylex ();
2441 if (token == CONSTANT
2442 && TREE_CODE (yylval.ttype) == INTEGER_CST)
2444 int old_lineno = lineno;
2445 enum { act_none, act_push, act_pop } action = act_none;
2446 int entering_system_header = 0;
2447 int entering_c_header = 0;
2449 /* subtract one, because it is the following line that
2450 gets the specified number */
2452 int l = TREE_INT_CST_LOW (yylval.ttype) - 1;
2453 c = get_last_nonwhite_on_line ();
2456 /* No more: store the line number and check following line. */
2462 /* More follows: it must be a string constant (filename). */
2464 /* Read the string constant, but don't treat \ as special. */
2465 ignore_escape_flag = 1;
2466 token = real_yylex ();
2467 ignore_escape_flag = 0;
2469 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
2471 error ("invalid #line");
2475 /* Changing files again. This means currently collected time
2476 is charged against header time, and body time starts back
2478 if (flag_detailed_statistics)
2480 int this_time = my_get_run_time ();
2481 tree time_identifier = get_time_identifier (TREE_STRING_POINTER (yylval.ttype));
2482 header_time += this_time - body_time;
2483 TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time))
2484 += this_time - body_time;
2485 this_filename_time = time_identifier;
2486 body_time = this_time;
2490 = (char *) permalloc (TREE_STRING_LENGTH (yylval.ttype) + 1);
2491 strcpy (input_filename, TREE_STRING_POINTER (yylval.ttype));
2493 GNU_xref_file (input_filename);
2495 if (main_input_filename == 0)
2497 struct impl_files *ifiles = impl_file_chain;
2501 while (ifiles->next)
2502 ifiles = ifiles->next;
2503 ifiles->filename = file_name_nondirectory (input_filename);
2506 main_input_filename = input_filename;
2507 if (write_virtuals == 3)
2508 walk_vtables (set_typedecl_interface_info, set_vardecl_interface_info);
2511 extract_interface_info ();
2513 c = get_last_nonwhite_on_line ();
2516 /* Update the name in the top element of input_file_stack. */
2517 if (input_file_stack)
2518 input_file_stack->name = input_filename;
2524 token = real_yylex ();
2526 /* `1' after file name means entering new file.
2527 `2' after file name means just left a file. */
2529 if (token == CONSTANT
2530 && TREE_CODE (yylval.ttype) == INTEGER_CST)
2532 if (TREE_INT_CST_LOW (yylval.ttype) == 1)
2534 else if (TREE_INT_CST_LOW (yylval.ttype) == 2)
2539 c = get_last_nonwhite_on_line ();
2543 token = real_yylex ();
2548 /* `3' after file name means this is a system header file. */
2550 if (token == CONSTANT
2551 && TREE_CODE (yylval.ttype) == INTEGER_CST
2552 && TREE_INT_CST_LOW (yylval.ttype) == 3)
2554 entering_system_header = 1;
2556 c = get_last_nonwhite_on_line ();
2560 token = real_yylex ();
2564 /* `4' after file name means this is a C header file. */
2566 if (token == CONSTANT
2567 && TREE_CODE (yylval.ttype) == INTEGER_CST
2568 && TREE_INT_CST_LOW (yylval.ttype) == 4)
2570 entering_c_header = 1;
2572 c = get_last_nonwhite_on_line ();
2576 token = real_yylex ();
2580 /* Do the actions implied by the preceding numbers. */
2582 if (action == act_push)
2584 /* Pushing to a new file. */
2585 struct file_stack *p;
2587 p = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2588 input_file_stack->line = old_lineno;
2589 p->next = input_file_stack;
2590 p->name = input_filename;
2591 input_file_stack = p;
2592 input_file_stack_tick++;
2593 debug_start_source_file (input_filename);
2594 in_system_header = entering_system_header;
2597 else if (entering_c_header)
2600 ++pending_lang_change;
2603 else if (action == act_pop)
2605 /* Popping out of a file. */
2606 if (input_file_stack->next)
2608 struct file_stack *p;
2610 if (c_header_level && --c_header_level == 0)
2612 if (entering_c_header)
2613 warning ("badly nested C headers from preprocessor");
2614 --pending_lang_change;
2616 in_system_header = entering_system_header;
2618 p = input_file_stack;
2619 input_file_stack = p->next;
2621 input_file_stack_tick++;
2622 debug_end_source_file (input_file_stack->line);
2625 error ("#-lines for entering and leaving files don't match");
2628 in_system_header = entering_system_header;
2631 /* If NEXTCHAR is not end of line, we don't care what it is. */
2632 if (nextchar == EOF)
2636 error ("invalid #-line");
2638 /* skip the rest of this line. */
2643 while ((c = getch ()) != EOF && c != '\n');
2648 do_pending_lang_change ()
2650 for (; pending_lang_change > 0; --pending_lang_change)
2651 push_lang_context (lang_name_c);
2652 for (; pending_lang_change < 0; ++pending_lang_change)
2653 pop_lang_context ();
2656 #define ENDFILE -1 /* token that represents end-of-file */
2658 /* Read an escape sequence, returning its equivalent as a character,
2659 or store 1 in *ignore_ptr if it is backslash-newline. */
2662 readescape (ignore_ptr)
2665 register int c = getch ();
2667 register unsigned count;
2668 unsigned firstdig = 0;
2686 if (c >= 'a' && c <= 'f')
2687 code += c - 'a' + 10;
2688 if (c >= 'A' && c <= 'F')
2689 code += c - 'A' + 10;
2690 if (c >= '0' && c <= '9')
2692 if (code != 0 || count != 0)
2701 error ("\\x used with no following hex digits");
2702 else if (count == 0)
2703 /* Digits are all 0's. Ok. */
2705 else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node)
2707 && ((1 << (TYPE_PRECISION (integer_type_node) - (count - 1) * 4))
2709 pedwarn ("hex escape out of range");
2712 case '0': case '1': case '2': case '3': case '4':
2713 case '5': case '6': case '7':
2716 while ((c <= '7') && (c >= '0') && (count++ < 3))
2718 code = (code * 8) + (c - '0');
2724 case '\\': case '\'': case '"':
2733 return TARGET_NEWLINE;
2756 pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c);
2762 /* `\(', etc, are used at beginning of line to avoid confusing Emacs. */
2766 /* `\%' is used to prevent SCCS from getting confused. */
2769 pedwarn ("unknown escape sequence `\\%c'", c);
2772 if (c >= 040 && c < 0177)
2773 pedwarn ("unknown escape sequence `\\%c'", c);
2775 pedwarn ("unknown escape sequence: `\\' followed by char code 0x%x", c);
2779 /* Value is 1 (or 2) if we should try to make the next identifier look like
2780 a typename (when it may be a local variable or a class variable).
2781 Value is 0 if we treat this name in a default fashion. */
2782 int looking_for_typename;
2788 identifier_type (decl)
2792 if (TREE_CODE (decl) == TEMPLATE_DECL)
2794 if (TREE_CODE (DECL_RESULT (decl)) == TYPE_DECL)
2796 else if (looking_for_template)
2799 if (looking_for_template && really_overloaded_fn (decl))
2801 for (t = decl; t != NULL_TREE; t = OVL_CHAIN (t))
2802 if (DECL_FUNCTION_TEMPLATE_P (OVL_FUNCTION (t)))
2805 if (TREE_CODE (decl) == NAMESPACE_DECL)
2807 if (TREE_CODE (decl) != TYPE_DECL)
2809 if (DECL_ARTIFICIAL (decl) && TREE_TYPE (decl) == current_class_type)
2812 /* A constructor declarator for a template type will get here as an
2813 implicit typename, a TYPENAME_TYPE with a type. */
2815 if (t && TREE_CODE (t) == TYPENAME_TYPE)
2817 decl = TREE_TYPE (decl);
2818 if (TREE_CODE (decl) == TYPENAME_TYPE)
2819 decl = TREE_TYPE (decl);
2829 /* Only types expected, not even namespaces. */
2830 looking_for_typename = 2;
2832 if ((yychar = yylex ()) < 0) yychar = 0;
2833 looking_for_typename = 0;
2834 if (yychar == IDENTIFIER)
2836 lastiddecl = lookup_name (yylval.ttype, -2);
2837 if (lastiddecl == 0)
2840 lastiddecl = IDENTIFIER_LABEL_VALUE (yylval.ttype);
2843 yychar = identifier_type (lastiddecl);
2847 /* Return true if d is in a global scope. */
2854 switch (TREE_CODE (d))
2856 case OVERLOAD: d = OVL_FUNCTION (d); continue;
2857 case TREE_LIST: d = TREE_VALUE (d); continue;
2859 my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (d)) == 'd', 980629);
2860 d = CP_DECL_CONTEXT (d);
2861 return TREE_CODE (d) == NAMESPACE_DECL;
2866 do_identifier (token, parsing, args)
2867 register tree token;
2872 int lexing = (parsing == 1);
2873 int in_call = (parsing == 2);
2875 if (! lexing || IDENTIFIER_OPNAME_P (token))
2876 id = lookup_name (token, 0);
2880 /* Scope class declarations before global
2882 if ((!id || is_global (id))
2883 && current_class_type != 0
2884 && TYPE_SIZE (current_class_type) == 0)
2886 /* Could be from one of the base classes. */
2887 tree field = lookup_field (current_class_type, token, 1, 0);
2890 else if (field == error_mark_node)
2891 /* We have already generated the error message.
2892 But we still want to return this value. */
2893 id = lookup_field (current_class_type, token, 0, 0);
2894 else if (TREE_CODE (field) == VAR_DECL
2895 || TREE_CODE (field) == CONST_DECL
2896 || TREE_CODE (field) == TEMPLATE_DECL)
2898 else if (TREE_CODE (field) != FIELD_DECL)
2899 my_friendly_abort (61);
2902 cp_error ("invalid use of member `%D' from base class `%T'", field,
2903 DECL_FIELD_CONTEXT (field));
2904 id = error_mark_node;
2909 /* Do Koenig lookup if appropriate (inside templates we build lookup
2910 expressions instead). */
2911 if (args && !current_template_parms && (!id || is_global (id)))
2913 /* If we have arguments and we only found global names,
2914 do Koenig lookup. */
2915 id = lookup_arg_dependent (token, id, args);
2918 /* Remember that this name has been used in the class definition, as per
2920 if (id && current_class_type && parsing
2921 && TYPE_BEING_DEFINED (current_class_type)
2922 && ! IDENTIFIER_CLASS_VALUE (token)
2923 /* Avoid breaking if we get called for a default argument that
2924 refers to an overloaded method. Eventually this will not be
2925 necessary, since default arguments shouldn't be parsed until
2926 after the class is complete. (jason 3/12/97) */
2927 && TREE_CODE (id) != OVERLOAD)
2928 pushdecl_class_level (id);
2930 if (!id || id == error_mark_node)
2932 if (id == error_mark_node && current_class_type != NULL_TREE)
2934 id = lookup_nested_field (token, 1);
2935 /* In lookup_nested_field(), we marked this so we can gracefully
2936 leave this whole mess. */
2937 if (id && id != error_mark_node && TREE_TYPE (id) == error_mark_node)
2941 if (current_template_parms)
2942 return build_min_nt (LOOKUP_EXPR, token);
2943 else if (IDENTIFIER_OPNAME_P (token))
2945 if (token != ansi_opname[ERROR_MARK])
2946 cp_error ("`%D' not defined", token);
2947 id = error_mark_node;
2949 else if (in_call && ! flag_strict_prototype)
2951 id = implicitly_declare (token);
2953 else if (current_function_decl == 0)
2955 cp_error ("`%D' was not declared in this scope", token);
2956 id = error_mark_node;
2960 if (IDENTIFIER_NAMESPACE_VALUE (token) != error_mark_node
2961 || IDENTIFIER_ERROR_LOCUS (token) != current_function_decl)
2963 static int undeclared_variable_notice;
2965 cp_error ("`%D' undeclared (first use this function)", token);
2967 if (! undeclared_variable_notice)
2969 error ("(Each undeclared identifier is reported only once");
2970 error ("for each function it appears in.)");
2971 undeclared_variable_notice = 1;
2974 id = error_mark_node;
2975 /* Prevent repeated error messages. */
2976 SET_IDENTIFIER_NAMESPACE_VALUE (token, error_mark_node);
2977 SET_IDENTIFIER_ERROR_LOCUS (token, current_function_decl);
2981 if (TREE_CODE (id) == VAR_DECL && DECL_DEAD_FOR_LOCAL (id))
2983 tree shadowed = DECL_SHADOWED_FOR_VAR (id);
2984 while (shadowed != NULL_TREE && TREE_CODE (shadowed) == VAR_DECL
2985 && DECL_DEAD_FOR_LOCAL (shadowed))
2986 shadowed = DECL_SHADOWED_FOR_VAR (shadowed);
2988 shadowed = IDENTIFIER_NAMESPACE_VALUE (DECL_NAME (id));
2991 if (!DECL_ERROR_REPORTED (id))
2993 warning ("name lookup of `%s' changed",
2994 IDENTIFIER_POINTER (token));
2995 cp_warning_at (" matches this `%D' under current ANSI rules",
2997 cp_warning_at (" matches this `%D' under old rules", id);
2998 DECL_ERROR_REPORTED (id) = 1;
3002 else if (!DECL_ERROR_REPORTED (id))
3005 = "name lookup of `%s' changed for new ANSI `for' scoping";
3006 DECL_ERROR_REPORTED (id) = 1;
3007 if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (id)))
3009 error (msg, IDENTIFIER_POINTER (token));
3010 cp_error_at (" cannot use obsolete binding at `%D' because it has a destructor", id);
3011 id = error_mark_node;
3015 pedwarn (msg, IDENTIFIER_POINTER (token));
3016 cp_pedwarn_at (" using obsolete binding at `%D'", id);
3020 /* TREE_USED is set in `hack_identifier'. */
3021 if (TREE_CODE (id) == CONST_DECL)
3023 if (IDENTIFIER_CLASS_VALUE (token) == id)
3026 tree access = compute_access (TYPE_BINFO (current_class_type), id);
3027 if (access == access_private_node)
3028 cp_error ("enum `%D' is private", id);
3029 /* protected is OK, since it's an enum of `this'. */
3031 if (!processing_template_decl
3032 /* Really, if we're processing a template, we just want to
3033 resolve template parameters, and not enumeration
3034 constants. But, they're hard to tell apart. (Note that
3035 a non-type template parameter may have enumeration type.)
3036 Fortunately, there's no harm in resolving *global*
3037 enumeration constants, since they can't depend on
3038 template parameters. */
3039 || (TREE_CODE (CP_DECL_CONTEXT (id)) == NAMESPACE_DECL
3040 && TREE_CODE (DECL_INITIAL (id)) == TEMPLATE_PARM_INDEX))
3041 id = DECL_INITIAL (id);
3044 id = hack_identifier (id, token);
3046 /* We must look up dependent names when the template is
3047 instantiated, not while parsing it. For now, we don't
3048 distinguish between dependent and independent names. So, for
3049 example, we look up all overloaded functions at
3050 instantiation-time, even though in some cases we should just use
3051 the DECL we have here. We also use LOOKUP_EXPRs to find things
3052 like local variables, rather than creating TEMPLATE_DECLs for the
3053 local variables and then finding matching instantiations. */
3054 if (current_template_parms
3055 && (is_overloaded_fn (id)
3056 /* If it's not going to be around at instantiation time, we
3057 look it up then. This is a hack, and should go when we
3058 really get dependent/independent name lookup right. */
3059 || !TREE_PERMANENT (id)
3060 /* Some local VAR_DECLs (such as those for local variables
3061 in member functions of local classes) are built on the
3062 permanent obstack. */
3063 || (TREE_CODE (id) == VAR_DECL
3064 && CP_DECL_CONTEXT (id)
3065 && TREE_CODE (CP_DECL_CONTEXT (id)) == FUNCTION_DECL)
3066 || TREE_CODE (id) == PARM_DECL
3067 || TREE_CODE (id) == USING_DECL))
3068 id = build_min_nt (LOOKUP_EXPR, token);
3074 do_scoped_id (token, parsing)
3079 /* during parsing, this is ::name. Otherwise, it is black magic. */
3082 struct tree_binding _b;
3083 id = binding_init (&_b);
3084 if (!qualified_lookup_using_namespace (token, global_namespace, id, 0))
3087 id = BINDING_VALUE (id);
3090 id = IDENTIFIER_GLOBAL_VALUE (token);
3091 if (parsing && yychar == YYEMPTY)
3095 if (processing_template_decl)
3097 id = build_min_nt (LOOKUP_EXPR, token);
3098 LOOKUP_EXPR_GLOBAL (id) = 1;
3101 if (parsing && (yychar == '(' || yychar == LEFT_RIGHT)
3102 && ! flag_strict_prototype)
3103 id = implicitly_declare (token);
3106 if (IDENTIFIER_NAMESPACE_VALUE (token) != error_mark_node)
3107 cp_error ("`::%D' undeclared (first use here)", token);
3108 id = error_mark_node;
3109 /* Prevent repeated error messages. */
3110 SET_IDENTIFIER_NAMESPACE_VALUE (token, error_mark_node);
3115 if (TREE_CODE (id) == ADDR_EXPR)
3116 mark_used (TREE_OPERAND (id, 0));
3117 else if (TREE_CODE (id) != OVERLOAD)
3120 if (TREE_CODE (id) == CONST_DECL && ! processing_template_decl)
3122 /* XXX CHS - should we set TREE_USED of the constant? */
3123 id = DECL_INITIAL (id);
3124 /* This is to prevent an enum whose value is 0
3125 from being considered a null pointer constant. */
3126 id = build1 (NOP_EXPR, TREE_TYPE (id), id);
3127 TREE_CONSTANT (id) = 1;
3130 if (processing_template_decl)
3132 if (is_overloaded_fn (id))
3134 id = build_min_nt (LOOKUP_EXPR, token);
3135 LOOKUP_EXPR_GLOBAL (id) = 1;
3138 /* else just use the decl */
3140 return convert_from_reference (id);
3144 identifier_typedecl_value (node)
3148 type = IDENTIFIER_TYPE_VALUE (node);
3149 if (type == NULL_TREE)
3154 if (t && TREE_CODE (t) == TYPE_DECL && TREE_TYPE (t) == type) \
3157 do (IDENTIFIER_LOCAL_VALUE (node));
3158 do (IDENTIFIER_CLASS_VALUE (node));
3159 do (IDENTIFIER_NAMESPACE_VALUE (node));
3161 /* Will this one ever happen? */
3162 if (TYPE_MAIN_DECL (type))
3163 return TYPE_MAIN_DECL (type);
3165 /* We used to do an internal error of 62 here, but instead we will
3166 handle the return of a null appropriately in the callers. */
3176 int dollar_seen = 0;
3180 c = nextchar, nextchar = -1;
3184 /* Effectively do c = skip_white_space (c)
3185 but do it faster in the usual cases. */
3198 /* Call skip_white_space so we can warn if appropriate. */
3203 c = skip_white_space (c);
3205 goto found_nonwhite;
3209 token_buffer[0] = c;
3210 token_buffer[1] = 0;
3212 /* yylloc.first_line = lineno; */
3217 token_buffer[0] = '\0';
3219 if (input_redirected ())
3220 value = END_OF_SAVED_INPUT;
3222 value = END_OF_LINE;
3228 if (! dollars_in_ident)
3229 error ("`$' in identifier");
3231 pedwarn ("`$' in identifier");
3236 /* Capital L may start a wide-string or wide-character constant. */
3238 register int c = getch ();
3247 goto string_constant;
3252 case 'A': case 'B': case 'C': case 'D': case 'E':
3253 case 'F': case 'G': case 'H': case 'I': case 'J':
3254 case 'K': case 'M': case 'N': case 'O':
3255 case 'P': case 'Q': case 'R': case 'S': case 'T':
3256 case 'U': case 'V': case 'W': case 'X': case 'Y':
3258 case 'a': case 'b': case 'c': case 'd': case 'e':
3259 case 'f': case 'g': case 'h': case 'i': case 'j':
3260 case 'k': case 'l': case 'm': case 'n': case 'o':
3261 case 'p': case 'q': case 'r': case 's': case 't':
3262 case 'u': case 'v': case 'w': case 'x': case 'y':
3272 /* We know that `token_buffer' can hold at least on char,
3273 so we install C immediately.
3274 We may have to read the value in `putback_char', so call
3279 /* Make this run fast. We know that we are reading straight
3280 from FINPUT in this case (since identifiers cannot straddle
3282 while (ISALNUM (c) || (c == '_') || c == '$')
3286 if (! dollars_in_ident)
3287 error ("`$' in identifier");
3289 pedwarn ("`$' in identifier");
3292 if (p >= token_buffer + maxtoken)
3293 p = extend_token_buffer (p);
3299 if (linemode && c == '\n')
3307 /* We know that `token_buffer' can hold at least on char,
3308 so we install C immediately. */
3312 while (ISALNUM (c) || (c == '_') || c == '$')
3316 if (! dollars_in_ident)
3317 error ("`$' in identifier");
3319 pedwarn ("`$' in identifier");
3322 if (p >= token_buffer + maxtoken)
3323 p = extend_token_buffer (p);
3336 /* Try to recognize a keyword. Uses minimum-perfect hash function */
3339 register struct resword *ptr;
3341 if ((ptr = is_reserved_word (token_buffer, p - token_buffer)))
3345 tree old_ttype = ridpointers[(int) ptr->rid];
3347 /* If this provides a type for us, then revert lexical
3348 state to standard state. */
3349 if (TREE_CODE (old_ttype) == IDENTIFIER_NODE
3350 && IDENTIFIER_GLOBAL_VALUE (old_ttype) != 0
3351 && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (old_ttype)) == TYPE_DECL)
3352 looking_for_typename = 0;
3353 else if (ptr->token == AGGR || ptr->token == ENUM)
3354 looking_for_typename = 2;
3356 /* Check if this is a language-type declaration.
3357 Just glimpse the next non-white character. */
3358 nextchar = skip_white_space (nextchar);
3359 if (nextchar == '"')
3361 /* We are looking at a string. Complain
3362 if the token before the string is no `extern'.
3364 Could cheat some memory by placing this string
3365 on the temporary_, instead of the saveable_
3368 if (ptr->rid != RID_EXTERN)
3369 error ("invalid modifier `%s' for language string",
3372 value = EXTERN_LANG_STRING;
3373 yylval.ttype = get_identifier (TREE_STRING_POINTER (yylval.ttype));
3376 if (ptr->token == VISSPEC)
3381 yylval.ttype = access_public_node;
3384 yylval.ttype = access_private_node;
3387 yylval.ttype = access_protected_node;
3390 my_friendly_abort (63);
3394 yylval.ttype = old_ttype;
3396 else if (ptr->token == EQCOMPARE)
3398 yylval.code = NE_EXPR;
3399 token_buffer[0] = '!';
3400 token_buffer[1] = '=';
3401 token_buffer[2] = 0;
3403 else if (ptr->token == ASSIGN)
3405 if (strcmp ("and_eq", token_buffer) == 0)
3407 yylval.code = BIT_AND_EXPR;
3408 token_buffer[0] = '&';
3410 else if (strcmp ("or_eq", token_buffer) == 0)
3412 yylval.code = BIT_IOR_EXPR;
3413 token_buffer[0] = '|';
3415 else if (strcmp ("xor_eq", token_buffer) == 0)
3417 yylval.code = BIT_XOR_EXPR;
3418 token_buffer[0] = '^';
3420 token_buffer[1] = '=';
3421 token_buffer[2] = 0;
3423 else if (ptr->token == '&')
3425 yylval.code = BIT_AND_EXPR;
3426 token_buffer[0] = '&';
3427 token_buffer[1] = 0;
3429 else if (ptr->token == '|')
3431 yylval.code = BIT_IOR_EXPR;
3432 token_buffer[0] = '|';
3433 token_buffer[1] = 0;
3435 else if (ptr->token == '^')
3437 yylval.code = BIT_XOR_EXPR;
3438 token_buffer[0] = '^';
3439 token_buffer[1] = 0;
3442 value = (int) ptr->token;
3446 /* If we did not find a keyword, look for an identifier
3449 if (value == IDENTIFIER || value == TYPESPEC)
3450 GNU_xref_ref (current_function_decl, token_buffer);
3452 if (value == IDENTIFIER)
3454 register tree tmp = get_identifier (token_buffer);
3456 #if !defined(VMS) && defined(JOINER)
3457 /* Make sure that user does not collide with our internal
3461 && (THIS_NAME_P (tmp)
3462 || VPTR_NAME_P (tmp)
3463 || DESTRUCTOR_NAME_P (tmp)
3464 || VTABLE_NAME_P (tmp)
3465 || TEMP_NAME_P (tmp)
3466 || ANON_AGGRNAME_P (tmp)
3467 || ANON_PARMNAME_P (tmp)))
3468 warning ("identifier name `%s' conflicts with GNU C++ internal naming strategy",
3474 if (value == NEW && ! global_bindings_p ())
3484 register int c1 = getch ();
3485 token_buffer[0] = c;
3486 token_buffer[1] = c1;
3490 token_buffer[2] = 0;
3498 token_buffer[2] = c1;
3499 token_buffer[3] = 0;
3503 error ("parse error at `..'");
3508 goto resume_numerical_scan;
3512 token_buffer[1] = 0;
3516 /* Optimize for most frequent case. */
3518 register int c1 = getch ();
3519 if (! ISALNUM (c1) && c1 != '.')
3521 /* Terminate string. */
3522 token_buffer[0] = c;
3523 token_buffer[1] = 0;
3525 yylval.ttype = integer_zero_node;
3527 yylval.ttype = integer_one_node;
3534 /* fall through... */
3535 case '2': case '3': case '4':
3536 case '5': case '6': case '7': case '8': case '9':
3537 resume_numerical_scan:
3542 int largest_digit = 0;
3544 /* for multi-precision arithmetic,
3545 we actually store only HOST_BITS_PER_CHAR bits in each part.
3546 The number of parts is chosen so as to be sufficient to hold
3547 the enough bits to fit into the two HOST_WIDE_INTs that contain
3548 the integer value (this is always at least as many bits as are
3549 in a target `long long' value, but may be wider). */
3550 #define TOTAL_PARTS ((HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2 + 2)
3551 int parts[TOTAL_PARTS];
3554 enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS} floatflag
3557 for (count = 0; count < TOTAL_PARTS; count++)
3565 *p++ = (c = getch ());
3566 if ((c == 'x') || (c == 'X'))
3569 *p++ = (c = getch ());
3571 /* Leading 0 forces octal unless the 0 is the only digit. */
3572 else if (c >= '0' && c <= '9')
3581 /* Read all the digits-and-decimal-points. */
3584 || (ISALNUM (c) && (c != 'l') && (c != 'L')
3585 && (c != 'u') && (c != 'U')
3586 && c != 'i' && c != 'I' && c != 'j' && c != 'J'
3587 && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
3592 error ("floating constant may not be in radix 16");
3593 if (floatflag == TOO_MANY_POINTS)
3594 /* We have already emitted an error. Don't need another. */
3596 else if (floatflag == AFTER_POINT)
3598 error ("malformed floating constant");
3599 floatflag = TOO_MANY_POINTS;
3600 /* Avoid another error from atof by forcing all characters
3601 from here on to be ignored. */
3605 floatflag = AFTER_POINT;
3608 *p++ = c = getch ();
3609 /* Accept '.' as the start of a floating-point number
3610 only when it is followed by a digit.
3611 Otherwise, unread the following non-digit
3612 and use the '.' as a structural token. */
3613 if (p == token_buffer + 2 && !ISDIGIT (c))
3625 error ("parse error at `..'");
3628 token_buffer[1] = '\0';
3635 /* It is not a decimal point.
3636 It should be a digit (perhaps a hex digit). */
3642 else if (base <= 10)
3644 if (c == 'e' || c == 'E')
3647 floatflag = AFTER_POINT;
3648 break; /* start of exponent */
3650 error ("nondigits in number and not hexadecimal");
3661 if (c >= largest_digit)
3665 for (count = 0; count < TOTAL_PARTS; count++)
3667 parts[count] *= base;
3671 += (parts[count-1] >> HOST_BITS_PER_CHAR);
3673 &= (1 << HOST_BITS_PER_CHAR) - 1;
3679 /* If the extra highest-order part ever gets anything in it,
3680 the number is certainly too big. */
3681 if (parts[TOTAL_PARTS - 1] != 0)
3684 if (p >= token_buffer + maxtoken - 3)
3685 p = extend_token_buffer (p);
3686 *p++ = (c = getch ());
3691 error ("numeric constant with no digits");
3693 if (largest_digit >= base)
3694 error ("numeric constant contains digits beyond the radix");
3696 /* Remove terminating char from the token buffer and delimit the string */
3699 if (floatflag != NOT_FLOAT)
3701 tree type = double_type_node;
3702 int exceeds_double = 0;
3704 REAL_VALUE_TYPE value;
3707 /* Read explicit exponent if any, and put it in tokenbuf. */
3709 if ((c == 'e') || (c == 'E'))
3711 if (p >= token_buffer + maxtoken - 3)
3712 p = extend_token_buffer (p);
3715 if ((c == '+') || (c == '-'))
3721 error ("floating constant exponent has no digits");
3724 if (p >= token_buffer + maxtoken - 3)
3725 p = extend_token_buffer (p);
3734 /* Convert string to a double, checking for overflow. */
3735 if (setjmp (handler))
3737 error ("floating constant out of range");
3742 int fflag = 0, lflag = 0;
3743 /* Copy token_buffer now, while it has just the number
3744 and not the suffixes; once we add `f' or `i',
3745 REAL_VALUE_ATOF may not work any more. */
3746 char *copy = (char *) alloca (p - token_buffer + 1);
3747 bcopy (token_buffer, copy, p - token_buffer + 1);
3749 set_float_handler (handler);
3755 /* Read the suffixes to choose a data type. */
3760 error ("more than one `f' in numeric constant");
3766 error ("more than one `l' in numeric constant");
3772 error ("more than one `i' or `j' in numeric constant");
3774 pedwarn ("ANSI C++ forbids imaginary numeric constants");
3785 if (p >= token_buffer + maxtoken - 3)
3786 p = extend_token_buffer (p);
3792 /* The second argument, machine_mode, of REAL_VALUE_ATOF
3793 tells the desired precision of the binary result
3794 of decimal-to-binary conversion. */
3799 error ("both `f' and `l' in floating constant");
3801 type = float_type_node;
3802 value = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
3803 /* A diagnostic is required here by some ANSI C testsuites.
3804 This is not pedwarn, become some people don't want
3805 an error for this. */
3806 if (REAL_VALUE_ISINF (value) && pedantic)
3807 warning ("floating point number exceeds range of `float'");
3811 type = long_double_type_node;
3812 value = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
3813 if (REAL_VALUE_ISINF (value) && pedantic)
3814 warning ("floating point number exceeds range of `long double'");
3818 value = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
3819 if (REAL_VALUE_ISINF (value) && pedantic)
3820 warning ("floating point number exceeds range of `double'");
3823 set_float_handler (NULL_PTR);
3826 if (errno == ERANGE && pedantic)
3828 /* ERANGE is also reported for underflow,
3829 so test the value to distinguish overflow from that. */
3830 if (REAL_VALUES_LESS (dconst1, value)
3831 || REAL_VALUES_LESS (value, dconstm1))
3833 pedwarn ("floating point number exceeds range of `%s'",
3834 IDENTIFIER_POINTER (TYPE_IDENTIFIER (type)));
3840 /* If the result is not a number, assume it must have been
3841 due to some error message above, so silently convert
3843 if (REAL_VALUE_ISNAN (value))
3846 /* Create a node with determined type and value. */
3848 yylval.ttype = build_complex (NULL_TREE,
3849 cp_convert (type, integer_zero_node),
3850 build_real (type, value));
3852 yylval.ttype = build_real (type, value);
3857 HOST_WIDE_INT high, low;
3858 int spec_unsigned = 0;
3860 int spec_long_long = 0;
3866 if (c == 'u' || c == 'U')
3869 error ("two `u's in integer constant");
3872 else if (c == 'l' || c == 'L')
3877 error ("three `l's in integer constant");
3878 else if (pedantic && ! in_system_header && warn_long_long)
3879 pedwarn ("ANSI C++ forbids long long integer constants");
3884 else if (c == 'i' || c == 'j' || c == 'I' || c == 'J')
3887 error ("more than one `i' or `j' in numeric constant");
3889 pedwarn ("ANSI C++ forbids imaginary numeric constants");
3894 if (p >= token_buffer + maxtoken - 3)
3895 p = extend_token_buffer (p);
3900 /* If the constant is not long long and it won't fit in an
3901 unsigned long, or if the constant is long long and won't fit
3902 in an unsigned long long, then warn that the constant is out
3905 /* ??? This assumes that long long and long integer types are
3906 a multiple of 8 bits. This better than the original code
3907 though which assumed that long was exactly 32 bits and long
3908 long was exactly 64 bits. */
3911 bytes = TYPE_PRECISION (long_long_integer_type_node) / 8;
3913 bytes = TYPE_PRECISION (long_integer_type_node) / 8;
3916 for (i = bytes; i < TOTAL_PARTS; i++)
3920 pedwarn ("integer constant out of range");
3922 /* This is simplified by the fact that our constant
3923 is always positive. */
3926 for (i = 0; i < HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR; i++)
3928 high |= ((HOST_WIDE_INT) parts[i + (HOST_BITS_PER_WIDE_INT
3929 / HOST_BITS_PER_CHAR)]
3930 << (i * HOST_BITS_PER_CHAR));
3931 low |= (HOST_WIDE_INT) parts[i] << (i * HOST_BITS_PER_CHAR);
3935 yylval.ttype = build_int_2 (low, high);
3936 TREE_TYPE (yylval.ttype) = long_long_unsigned_type_node;
3938 /* Calculate the ANSI type. */
3939 if (!spec_long && !spec_unsigned
3940 && int_fits_type_p (yylval.ttype, integer_type_node))
3941 type = integer_type_node;
3942 else if (!spec_long && (base != 10 || spec_unsigned)
3943 && int_fits_type_p (yylval.ttype, unsigned_type_node))
3944 /* Nondecimal constants try unsigned even in traditional C. */
3945 type = unsigned_type_node;
3946 else if (!spec_unsigned && !spec_long_long
3947 && int_fits_type_p (yylval.ttype, long_integer_type_node))
3948 type = long_integer_type_node;
3949 else if (! spec_long_long)
3950 type = long_unsigned_type_node;
3951 else if (! spec_unsigned
3952 /* Verify value does not overflow into sign bit. */
3953 && TREE_INT_CST_HIGH (yylval.ttype) >= 0
3954 && int_fits_type_p (yylval.ttype,
3955 long_long_integer_type_node))
3956 type = long_long_integer_type_node;
3958 type = long_long_unsigned_type_node;
3960 if (!int_fits_type_p (yylval.ttype, type) && !warn)
3961 pedwarn ("integer constant out of range");
3963 if (base == 10 && ! spec_unsigned && TREE_UNSIGNED (type))
3964 warning ("decimal integer constant is so large that it is unsigned");
3968 if (TYPE_PRECISION (type)
3969 <= TYPE_PRECISION (integer_type_node))
3971 = build_complex (NULL_TREE, integer_zero_node,
3972 cp_convert (integer_type_node,
3975 error ("complex integer constant is too wide for `__complex int'");
3978 TREE_TYPE (yylval.ttype) = type;
3984 value = CONSTANT; break;
3990 register int result = 0;
3991 register int num_chars = 0;
3993 unsigned width = TYPE_PRECISION (char_type_node);
3995 #ifdef MULTIBYTE_CHARS
3996 int longest_char = local_mb_cur_max ();
3997 (void) local_mbtowc (NULL_PTR, NULL_PTR, 0);
4000 max_chars = TYPE_PRECISION (integer_type_node) / width;
4002 width = WCHAR_TYPE_SIZE;
4009 if (c == '\'' || c == EOF)
4016 c = readescape (&ignore);
4019 if (width < HOST_BITS_PER_INT
4020 && (unsigned) c >= (1 << width))
4021 pedwarn ("escape sequence out of range for character");
4022 #ifdef MAP_CHARACTER
4024 c = MAP_CHARACTER (c);
4030 pedwarn ("ANSI C forbids newline in character constant");
4035 #ifdef MULTIBYTE_CHARS
4039 for (i = 1; i <= longest_char; ++i)
4041 if (i > maxtoken - 4)
4042 extend_token_buffer (token_buffer);
4044 token_buffer[i] = c;
4045 char_len = local_mbtowc (& wc,
4054 /* mbtowc sometimes needs an extra char before accepting */
4059 /* Merge character into result; ignore excess chars. */
4060 for (i = 1; i <= char_len; ++i)
4064 if (width < HOST_BITS_PER_INT)
4065 result = (result << width)
4067 & ((1 << width) - 1));
4069 result = token_buffer[i];
4071 num_chars += char_len;
4079 warning ("Ignoring invalid multibyte character");
4082 #ifdef MAP_CHARACTER
4084 c = MAP_CHARACTER (c);
4087 #else /* ! MULTIBYTE_CHARS */
4088 #ifdef MAP_CHARACTER
4089 c = MAP_CHARACTER (c);
4091 #endif /* ! MULTIBYTE_CHARS */
4096 if (chars_seen == 1) /* only keep the first one */
4101 /* Merge character into result; ignore excess chars. */
4103 if (num_chars < max_chars + 1)
4105 if (width < HOST_BITS_PER_INT)
4106 result = (result << width) | (c & ((1 << width) - 1));
4113 error ("malformatted character constant");
4114 else if (chars_seen == 0)
4115 error ("empty character constant");
4116 else if (num_chars > max_chars)
4118 num_chars = max_chars;
4119 error ("character constant too long");
4121 else if (chars_seen != 1 && warn_multichar)
4122 warning ("multi-character character constant");
4124 /* If char type is signed, sign-extend the constant. */
4127 int num_bits = num_chars * width;
4129 /* We already got an error; avoid invalid shift. */
4130 yylval.ttype = build_int_2 (0, 0);
4131 else if (TREE_UNSIGNED (char_type_node)
4132 || ((result >> (num_bits - 1)) & 1) == 0)
4134 = build_int_2 (result & (~(unsigned HOST_WIDE_INT) 0
4135 >> (HOST_BITS_PER_WIDE_INT - num_bits)),
4139 = build_int_2 (result | ~(~(unsigned HOST_WIDE_INT) 0
4140 >> (HOST_BITS_PER_WIDE_INT - num_bits)),
4142 if (chars_seen <= 1)
4143 TREE_TYPE (yylval.ttype) = char_type_node;
4145 TREE_TYPE (yylval.ttype) = integer_type_node;
4149 yylval.ttype = build_int_2 (result, 0);
4150 TREE_TYPE (yylval.ttype) = wchar_type_node;
4161 unsigned width = wide_flag ? WCHAR_TYPE_SIZE
4162 : TYPE_PRECISION (char_type_node);
4163 #ifdef MULTIBYTE_CHARS
4164 int longest_char = local_mb_cur_max ();
4165 (void) local_mbtowc (NULL_PTR, NULL_PTR, 0);
4169 p = token_buffer + 1;
4171 while (c != '"' && c >= 0)
4173 /* ignore_escape_flag is set for reading the filename in #line. */
4174 if (!ignore_escape_flag && c == '\\')
4177 c = readescape (&ignore);
4180 if (width < HOST_BITS_PER_INT
4181 && (unsigned) c >= (1 << width))
4182 warning ("escape sequence out of range for character");
4187 pedwarn ("ANSI C++ forbids newline in string constant");
4192 #ifdef MULTIBYTE_CHARS
4196 for (i = 0; i < longest_char; ++i)
4198 if (p + i >= token_buffer + maxtoken)
4199 p = extend_token_buffer (p);
4202 char_len = local_mbtowc (& wc, p, i + 1);
4208 warning ("Ignoring invalid multibyte character");
4211 /* mbtowc sometimes needs an extra char before accepting */
4224 #endif /* MULTIBYTE_CHARS */
4227 /* Add this single character into the buffer either as a wchar_t
4228 or as a single byte. */
4231 unsigned width = TYPE_PRECISION (char_type_node);
4232 unsigned bytemask = (1 << width) - 1;
4235 if (p + WCHAR_BYTES > token_buffer + maxtoken)
4236 p = extend_token_buffer (p);
4238 for (byte = 0; byte < WCHAR_BYTES; ++byte)
4241 if (byte >= sizeof (c))
4244 value = (c >> (byte * width)) & bytemask;
4245 if (BYTES_BIG_ENDIAN)
4246 p[WCHAR_BYTES - byte - 1] = value;
4254 if (p >= token_buffer + maxtoken)
4255 p = extend_token_buffer (p);
4262 error ("Unterminated string");
4267 /* Terminate the string value, either with a single byte zero
4268 or with a wide zero. */
4271 if (p + WCHAR_BYTES > token_buffer + maxtoken)
4272 p = extend_token_buffer (p);
4273 bzero (p, WCHAR_BYTES);
4278 if (p >= token_buffer + maxtoken)
4279 p = extend_token_buffer (p);
4283 /* We have read the entire constant.
4284 Construct a STRING_CST for the result. */
4286 if (processing_template_decl)
4287 push_obstacks (&permanent_obstack, &permanent_obstack);
4288 yylval.ttype = build_string (p - (token_buffer + 1), token_buffer + 1);
4289 if (processing_template_decl)
4293 TREE_TYPE (yylval.ttype) = wchar_array_type_node;
4295 TREE_TYPE (yylval.ttype) = char_array_type_node;
4297 value = STRING; break;
4320 yylval.code = PLUS_EXPR; break;
4322 yylval.code = MINUS_EXPR; break;
4324 yylval.code = BIT_AND_EXPR; break;
4326 yylval.code = BIT_IOR_EXPR; break;
4328 yylval.code = MULT_EXPR; break;
4330 yylval.code = TRUNC_DIV_EXPR; break;
4332 yylval.code = TRUNC_MOD_EXPR; break;
4334 yylval.code = BIT_XOR_EXPR; break;
4336 yylval.code = LSHIFT_EXPR; break;
4338 yylval.code = RSHIFT_EXPR; break;
4340 yylval.code = LT_EXPR; break;
4342 yylval.code = GT_EXPR; break;
4345 token_buffer[1] = c1 = getch ();
4346 token_buffer[2] = 0;
4353 value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done;
4355 value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done;
4357 value = EQCOMPARE; yylval.code = NE_EXPR; goto done;
4359 value = EQCOMPARE; yylval.code = EQ_EXPR; goto done;
4361 value = ASSIGN; goto done;
4367 value = PLUSPLUS; goto done;
4369 value = MINUSMINUS; goto done;
4371 value = ANDAND; goto done;
4373 value = OROR; goto done;
4381 else if ((c == '-') && (c1 == '>'))
4383 nextchar = getch ();
4384 if (nextchar == '*')
4387 value = POINTSAT_STAR;
4393 else if (c1 == '?' && (c == '<' || c == '>'))
4395 token_buffer[3] = 0;
4398 yylval.code = (c == '<' ? MIN_EXPR : MAX_EXPR);
4401 /* <?= or >?= expression. */
4402 token_buffer[2] = c1;
4411 pedwarn ("use of `operator %s' is not standard C++",
4416 else if (c == '<' && c1 == '%')
4417 { value = '{'; goto done; }
4418 else if (c == '<' && c1 == ':')
4419 { value = '['; goto done; }
4420 else if (c == '%' && c1 == '>')
4421 { value = '}'; goto done; }
4422 else if (c == '%' && c1 == ':')
4423 { value = '#'; goto done; }
4426 token_buffer[1] = 0;
4436 token_buffer[1] = ':';
4437 token_buffer[2] = '\0';
4454 /* Don't make yyparse think this is eof. */
4459 /* try, weakly, to handle casts to pointers to functions. */
4460 nextchar = skip_white_space (getch ());
4461 if (nextchar == '*')
4463 int next_c = skip_white_space (getch ());
4467 yylval.ttype = build1 (INDIRECT_REF, 0, 0);
4468 value = PAREN_STAR_PAREN;
4476 else if (nextchar == ')')
4479 yylval.ttype = NULL_TREE;
4490 /* yylloc.last_line = lineno; */
4491 #ifdef GATHER_STATISTICS
4492 #ifdef REDUCE_LENGTH
4493 token_count[value] += 1;
4504 return !!is_reserved_word (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t));
4507 #ifdef GATHER_STATISTICS
4508 /* The original for tree_node_kind is in the toplevel tree.c; changes there
4509 need to be brought into here, unless this were actually put into a header
4511 /* Statistics-gathering stuff. */
4532 extern int tree_node_counts[];
4533 extern int tree_node_sizes[];
4536 /* Place to save freed lang_decls which were allocated on the
4537 permanent_obstack. @@ Not currently used. */
4538 tree free_lang_decl_chain;
4541 build_lang_decl (code, name, type)
4542 enum tree_code code;
4546 register tree t = build_decl (code, name, type);
4547 struct obstack *obstack = current_obstack;
4548 register int i = sizeof (struct lang_decl) / sizeof (int);
4551 if (! TREE_PERMANENT (t))
4552 obstack = saveable_obstack;
4554 /* Could be that saveable is permanent and current is not. */
4555 obstack = &permanent_obstack;
4557 if (free_lang_decl_chain && obstack == &permanent_obstack)
4559 pi = (int *)free_lang_decl_chain;
4560 free_lang_decl_chain = TREE_CHAIN (free_lang_decl_chain);
4563 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
4568 DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
4569 LANG_DECL_PERMANENT ((struct lang_decl *) pi)
4570 = obstack == &permanent_obstack;
4571 my_friendly_assert (LANG_DECL_PERMANENT ((struct lang_decl *) pi)
4572 == TREE_PERMANENT (t), 234);
4573 DECL_MAIN_VARIANT (t) = t;
4574 if (current_lang_name == lang_name_cplusplus)
4575 DECL_LANGUAGE (t) = lang_cplusplus;
4576 else if (current_lang_name == lang_name_c)
4577 DECL_LANGUAGE (t) = lang_c;
4578 else if (current_lang_name == lang_name_java)
4579 DECL_LANGUAGE (t) = lang_java;
4580 else my_friendly_abort (64);
4582 #if 0 /* not yet, should get fixed properly later */
4583 if (code == TYPE_DECL)
4586 id = get_identifier (build_overload_name (type, 1, 1));
4587 DECL_ASSEMBLER_NAME (t) = id;
4591 #ifdef GATHER_STATISTICS
4592 tree_node_counts[(int)lang_decl] += 1;
4593 tree_node_sizes[(int)lang_decl] += sizeof (struct lang_decl);
4600 build_lang_field_decl (code, name, type)
4601 enum tree_code code;
4605 extern struct obstack *current_obstack, *saveable_obstack;
4606 register tree t = build_decl (code, name, type);
4607 struct obstack *obstack = current_obstack;
4608 register int i = sizeof (struct lang_decl_flags) / sizeof (int);
4610 #if 0 /* not yet, should get fixed properly later */
4612 if (code == TYPE_DECL)
4615 id = get_identifier (build_overload_name (type, 1, 1));
4616 DECL_ASSEMBLER_NAME (t) = id;
4620 if (! TREE_PERMANENT (t))
4621 obstack = saveable_obstack;
4623 my_friendly_assert (obstack == &permanent_obstack, 235);
4625 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl_flags));
4629 DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
4634 copy_lang_decl (node)
4640 if (! DECL_LANG_SPECIFIC (node))
4643 if (TREE_CODE (node) == FIELD_DECL)
4644 size = sizeof (struct lang_decl_flags);
4646 size = sizeof (struct lang_decl);
4647 pi = (int *)obstack_alloc (&permanent_obstack, size);
4648 bcopy ((char *)DECL_LANG_SPECIFIC (node), (char *)pi, size);
4649 DECL_LANG_SPECIFIC (node) = (struct lang_decl *)pi;
4653 make_lang_type (code)
4654 enum tree_code code;
4656 extern struct obstack *current_obstack, *saveable_obstack;
4657 register tree t = make_node (code);
4658 struct obstack *obstack = current_obstack;
4659 register int i = sizeof (struct lang_type) / sizeof (int);
4662 /* Set up some flags that give proper default behavior. */
4663 IS_AGGR_TYPE (t) = 1;
4665 if (! TREE_PERMANENT (t))
4666 obstack = saveable_obstack;
4668 my_friendly_assert (obstack == &permanent_obstack, 236);
4670 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_type));
4674 TYPE_LANG_SPECIFIC (t) = (struct lang_type *) pi;
4675 CLASSTYPE_AS_LIST (t) = build_expr_list (NULL_TREE, t);
4676 SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, interface_unknown);
4677 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
4678 TYPE_BINFO (t) = make_binfo (integer_zero_node, t, NULL_TREE, NULL_TREE);
4679 CLASSTYPE_BINFO_AS_LIST (t) = build_tree_list (NULL_TREE, TYPE_BINFO (t));
4681 /* Make sure this is laid out, for ease of use later.
4682 In the presence of parse errors, the normal was of assuring
4683 this might not ever get executed, so we lay it out *immediately*. */
4684 build_pointer_type (t);
4686 #ifdef GATHER_STATISTICS
4687 tree_node_counts[(int)lang_type] += 1;
4688 tree_node_sizes[(int)lang_type] += sizeof (struct lang_type);
4695 dump_time_statistics ()
4697 register tree prev = 0, decl, next;
4698 int this_time = my_get_run_time ();
4699 TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time))
4700 += this_time - body_time;
4702 fprintf (stderr, "\n******\n");
4703 print_time ("header files (total)", header_time);
4704 print_time ("main file (total)", this_time - body_time);
4705 fprintf (stderr, "ratio = %g : 1\n",
4706 (double)header_time / (double)(this_time - body_time));
4707 fprintf (stderr, "\n******\n");
4709 for (decl = filename_times; decl; decl = next)
4711 next = IDENTIFIER_GLOBAL_VALUE (decl);
4712 SET_IDENTIFIER_GLOBAL_VALUE (decl, prev);
4716 for (decl = prev; decl; decl = IDENTIFIER_GLOBAL_VALUE (decl))
4717 print_time (IDENTIFIER_POINTER (decl),
4718 TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (decl)));
4722 compiler_error (s, v, v2)
4724 HOST_WIDE_INT v, v2; /* @@also used as pointer */
4727 sprintf (buf, s, v, v2);
4728 error_with_file_and_line (input_filename, lineno, "%s (compiler error)", buf);
4735 extern int end_of_file;
4738 strcpy (buf, string);
4740 /* We can't print string and character constants well
4741 because the token_buffer contains the result of processing escapes. */
4743 strcat (buf, input_redirected ()
4744 ? " at end of saved text"
4745 : " at end of input");
4746 else if (token_buffer[0] == 0)
4747 strcat (buf, " at null character");
4748 else if (token_buffer[0] == '"')
4749 strcat (buf, " before string constant");
4750 else if (token_buffer[0] == '\'')
4751 strcat (buf, " before character constant");
4752 else if (token_buffer[0] < 040 || (unsigned char) token_buffer[0] >= 0177)
4753 sprintf (buf + strlen (buf), " before character 0%o",
4754 (unsigned char) token_buffer[0]);
4756 strcat (buf, " before `%s'");
4758 error (buf, token_buffer);
4762 handle_cp_pragma (pname)
4767 if (! strcmp (pname, "vtable"))
4769 extern tree pending_vtables;
4771 /* More follows: it must be a string constant (class name). */
4772 token = real_yylex ();
4773 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
4775 error ("invalid #pragma vtable");
4779 if (write_virtuals != 2)
4781 warning ("use `+e2' option to enable #pragma vtable");
4785 = perm_tree_cons (NULL_TREE,
4786 get_identifier (TREE_STRING_POINTER (yylval.ttype)),
4788 token = real_yylex ();
4789 if (token != END_OF_LINE)
4790 warning ("trailing characters ignored");
4793 else if (! strcmp (pname, "unit"))
4795 /* More follows: it must be a string constant (unit name). */
4796 token = real_yylex ();
4797 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
4799 error ("invalid #pragma unit");
4802 token = real_yylex ();
4803 if (token != END_OF_LINE)
4804 warning ("trailing characters ignored");
4807 else if (! strcmp (pname, "interface"))
4809 tree fileinfo = IDENTIFIER_CLASS_VALUE (get_time_identifier (input_filename));
4810 char *main_filename = input_filename;
4812 main_filename = file_name_nondirectory (main_filename);
4814 token = real_yylex ();
4816 if (token != END_OF_LINE)
4819 || TREE_CODE (yylval.ttype) != STRING_CST)
4821 error ("invalid `#pragma interface'");
4824 main_filename = TREE_STRING_POINTER (yylval.ttype);
4825 token = real_yylex ();
4828 if (token != END_OF_LINE)
4829 warning ("garbage after `#pragma interface' ignored");
4831 #ifndef NO_LINKAGE_HEURISTICS
4834 if (impl_file_chain == 0)
4836 /* If this is zero at this point, then we are
4837 auto-implementing. */
4838 if (main_input_filename == 0)
4839 main_input_filename = input_filename;
4841 #ifdef AUTO_IMPLEMENT
4842 filename = file_name_nondirectory (main_input_filename);
4843 fi = get_time_identifier (filename);
4844 fi = IDENTIFIER_CLASS_VALUE (fi);
4845 TREE_INT_CST_LOW (fi) = 0;
4846 TREE_INT_CST_HIGH (fi) = 1;
4848 impl_file_chain = (struct impl_files *)permalloc (sizeof (struct impl_files));
4849 impl_file_chain->filename = filename;
4850 impl_file_chain->next = 0;
4854 interface_only = interface_strcmp (main_filename);
4855 interface_unknown = 0;
4856 TREE_INT_CST_LOW (fileinfo) = interface_only;
4857 TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
4858 #endif /* NO_LINKAGE_HEURISTICS */
4862 else if (! strcmp (pname, "implementation"))
4864 tree fileinfo = IDENTIFIER_CLASS_VALUE (get_time_identifier (input_filename));
4865 char *main_filename = main_input_filename ? main_input_filename : input_filename;
4867 main_filename = file_name_nondirectory (main_filename);
4868 token = real_yylex ();
4869 if (token != END_OF_LINE)
4872 || TREE_CODE (yylval.ttype) != STRING_CST)
4874 error ("invalid `#pragma implementation'");
4877 main_filename = TREE_STRING_POINTER (yylval.ttype);
4878 token = real_yylex ();
4881 if (token != END_OF_LINE)
4882 warning ("garbage after `#pragma implementation' ignored");
4884 #ifndef NO_LINKAGE_HEURISTICS
4885 if (write_virtuals == 3)
4887 struct impl_files *ifiles = impl_file_chain;
4890 if (! strcmp (ifiles->filename, main_filename))
4892 ifiles = ifiles->next;
4896 ifiles = (struct impl_files*) permalloc (sizeof (struct impl_files));
4897 ifiles->filename = main_filename;
4898 ifiles->next = impl_file_chain;
4899 impl_file_chain = ifiles;
4902 else if ((main_input_filename != 0
4903 && ! strcmp (main_input_filename, input_filename))
4904 || ! strcmp (input_filename, main_filename))
4907 if (impl_file_chain == 0)
4909 impl_file_chain = (struct impl_files*) permalloc (sizeof (struct impl_files));
4910 impl_file_chain->filename = main_filename;
4911 impl_file_chain->next = 0;
4915 error ("`#pragma implementation' can only appear at top-level");
4918 /* We make this non-zero so that we infer decl linkage
4919 in the impl file only for variables first declared
4920 in the interface file. */
4921 interface_unknown = 1;
4923 /* We make this zero so that templates in the impl
4924 file will be emitted properly. */
4925 interface_unknown = 0;
4927 TREE_INT_CST_LOW (fileinfo) = interface_only;
4928 TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
4929 #endif /* NO_LINKAGE_HEURISTICS */
4937 #ifdef HANDLE_SYSV_PRAGMA
4939 /* Handle a #pragma directive. INPUT is the current input stream,
4940 and C is a character to reread. Processes the entire input line
4941 and returns a character for the caller to reread: either \n or EOF. */
4943 /* This function has to be in this file, in order to get at
4947 handle_sysv_pragma (token)
4958 handle_pragma_token (IDENTIFIER_POINTER(yylval.ttype), yylval.ttype);
4961 handle_pragma_token ("(", NULL_TREE);
4964 handle_pragma_token (")", NULL_TREE);
4967 handle_pragma_token (",", NULL_TREE);
4970 handle_pragma_token ("=", NULL_TREE);
4973 handle_pragma_token ("(", NULL_TREE);
4974 handle_pragma_token (")", NULL_TREE);
4978 return handle_pragma_token (NULL_PTR, NULL_TREE);
4980 token = real_yylex ();
4983 #endif /* HANDLE_SYSV_PRAGMA */