1 /* Separate lexical analyzer for GNU C++.
2 Copyright (C) 1987, 89, 92-98, 1999 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. */
41 #ifdef MULTIBYTE_CHARS
46 #define obstack_chunk_alloc xmalloc
47 #define obstack_chunk_free free
50 #define DIR_SEPARATOR '/'
53 extern struct obstack permanent_obstack;
54 extern struct obstack *current_obstack, *saveable_obstack;
56 extern void yyprint PROTO((FILE *, int, YYSTYPE));
58 static tree get_time_identifier PROTO((const char *));
59 static int check_newline PROTO((void));
60 static int whitespace_cr PROTO((int));
61 static int skip_white_space PROTO((int));
62 static void finish_defarg PROTO((void));
63 static int my_get_run_time PROTO((void));
64 static int interface_strcmp PROTO((const char *));
65 static int readescape PROTO((int *));
66 static char *extend_token_buffer PROTO((const char *));
67 static void consume_string PROTO((struct obstack *, int));
68 static void feed_defarg PROTO((tree, tree));
69 static void store_pending_inline PROTO((tree, struct pending_inline *));
70 static void reinit_parse_for_expr PROTO((struct obstack *));
71 static int *init_cpp_parse PROTO((void));
72 static void cp_pragma_interface PROTO((char *));
73 static void cp_pragma_implementation PROTO ((char *));
74 static int handle_cp_pragma PROTO((const char *));
75 #ifdef HANDLE_GENERIC_PRAGMAS
76 static int handle_generic_pragma PROTO((int));
78 #ifdef GATHER_STATISTICS
80 static int reduce_cmp PROTO((int *, int *));
81 static int token_cmp PROTO((int *, int *));
84 static void begin_definition_of_inclass_inline PROTO((struct pending_inline*));
85 static void parse_float PROTO((PTR));
86 static int is_global PROTO((tree));
87 static void init_filename_times PROTO((void));
88 static void extend_token_buffer_to PROTO((int));
90 static int pragma_getc PROTO((void));
91 static void pragma_ungetc PROTO((int));
93 static int read_line_number PROTO((int *));
95 /* Given a file name X, return the nondirectory portion.
96 Keep in mind that X can be computed more than once. */
98 file_name_nondirectory (x)
101 char *tmp = (char *) rindex (x, '/');
102 if (DIR_SEPARATOR != '/' && ! tmp)
103 tmp = (char *) rindex (x, DIR_SEPARATOR);
105 return (char *) (tmp + 1);
110 /* This obstack is needed to hold text. It is not safe to use
111 TOKEN_BUFFER because `check_newline' calls `yylex'. */
112 struct obstack inline_text_obstack;
113 char *inline_text_firstobj;
117 extern cpp_reader parse_in;
118 extern cpp_options parse_options;
119 extern unsigned char *yy_cur, *yy_lim;
120 extern enum cpp_token cpp_token;
128 /* Pending language change.
129 Positive is push count, negative is pop count. */
130 int pending_lang_change = 0;
132 /* Wrap the current header file in extern "C". */
133 static int c_header_level = 0;
135 extern int first_token;
136 extern struct obstack token_obstack;
138 /* ??? Don't really know where this goes yet. */
141 /* Holds translations from TREE_CODEs to operator name strings,
142 i.e., opname_tab[PLUS_EXPR] == "+". */
143 const char **opname_tab;
144 const char **assignop_tab;
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. */
312 static int indent_level; /* Number of { minus number of }. */
317 /* Nonzero tells yylex to ignore \ in string constants. */
318 static int ignore_escape_flag;
321 get_time_identifier (name)
324 tree time_identifier;
325 int len = strlen (name);
326 char *buf = (char *) alloca (len + 6);
327 strcpy (buf, "file ");
328 bcopy (name, buf+5, len);
330 time_identifier = get_identifier (buf);
331 if (TIME_IDENTIFIER_TIME (time_identifier) == NULL_TREE)
333 push_obstacks_nochange ();
334 end_temporary_allocation ();
335 TIME_IDENTIFIER_TIME (time_identifier) = build_int_2 (0, 0);
336 TIME_IDENTIFIER_FILEINFO (time_identifier)
337 = build_int_2 (0, 1);
338 SET_IDENTIFIER_GLOBAL_VALUE (time_identifier, filename_times);
339 filename_times = time_identifier;
342 return time_identifier;
351 int old_quiet_flag = quiet_flag;
354 this_time = get_run_time ();
355 quiet_flag = old_quiet_flag;
359 /* Table indexed by tree code giving a string containing a character
360 classifying the tree code. Possibilities are
361 t, d, s, c, r, <, 1 and 2. See cp/cp-tree.def for details. */
363 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
365 char cplus_tree_code_type[] = {
367 #include "cp-tree.def"
371 /* Table indexed by tree code giving number of expression
372 operands beyond the fixed part of the node structure.
373 Not used for types or decls. */
375 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
377 int cplus_tree_code_length[] = {
379 #include "cp-tree.def"
383 /* Names of tree components.
384 Used for printing out the tree and error messages. */
385 #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
387 const char *cplus_tree_code_name[] = {
389 #include "cp-tree.def"
393 /* toplev.c needs to call these. */
399 cpp_reader_init (&parse_in);
400 parse_in.opts = &parse_options;
401 cpp_options_init (&parse_options);
402 parse_options.cplusplus = 1;
405 /* Default exceptions on. */
412 /* the beginning of the file is a new line; check for # */
413 /* With luck, we discover the real source file's name from that
414 and put it in input_filename. */
415 put_back (check_newline ());
416 if (flag_gnu_xref) GNU_xref_begin (input_filename);
417 init_repo (input_filename);
423 if (flag_gnu_xref) GNU_xref_end (errorcount+sorrycount);
433 init_filename_times ()
435 this_filename_time = get_time_identifier ("<top level>");
436 if (flag_detailed_statistics)
439 body_time = my_get_run_time ();
440 TREE_INT_CST_LOW (TIME_IDENTIFIER_TIME (this_filename_time))
445 /* Change by Bryan Boreham, Kewill, Thu Jul 27 09:46:05 1989.
446 Stuck this hack in to get the files open correctly; this is called
447 in place of init_parse if we are an unexec'd binary. */
451 reinit_lang_specific ()
453 init_filename_times ();
454 reinit_search_statistics ();
461 #ifdef GATHER_STATISTICS
463 reduce_count = (int *)malloc (sizeof (int) * (REDUCE_LENGTH + 1));
464 bzero (reduce_count, sizeof (int) * (REDUCE_LENGTH + 1));
466 token_count = (int *)malloc (sizeof (int) * (TOKEN_LENGTH + 1));
467 bzero (token_count, sizeof (int) * (TOKEN_LENGTH + 1));
475 init_parse (filename)
478 extern int flag_no_gnu_keywords;
479 extern int flag_operator_names;
483 #ifdef MULTIBYTE_CHARS
484 /* Change to the native locale for multibyte conversions. */
485 setlocale (LC_CTYPE, "");
486 literal_codeset = getenv ("LANG");
490 /* Open input file. */
491 if (filename == 0 || !strcmp (filename, "-"))
497 finput = fopen (filename, "r");
499 pfatal_with_name (filename);
501 #ifdef IO_BUFFER_SIZE
502 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
504 #else /* !USE_CPPLIB */
505 parse_in.show_column = 1;
506 if (! cpp_start_read (&parse_in, filename))
509 if (filename == 0 || !strcmp (filename, "-"))
512 /* cpp_start_read always puts at least one line directive into the
513 token buffer. We must arrange to read it out here. */
514 yy_cur = parse_in.token_buffer;
515 yy_lim = CPP_PWRITTEN (&parse_in);
516 cpp_token = CPP_DIRECTIVE;
518 #endif /* !USE_CPPLIB */
520 /* Initialize the lookahead machinery. */
523 /* Make identifier nodes long enough for the language-specific slots. */
524 set_identifier_size (sizeof (struct lang_identifier));
525 decl_printable_name = lang_printable_name;
527 init_cplus_unsave ();
528 init_cplus_expand ();
530 bcopy (cplus_tree_code_type,
531 tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
532 (int)LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE);
533 bcopy ((char *)cplus_tree_code_length,
534 (char *)(tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE),
535 (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
536 bcopy ((char *)cplus_tree_code_name,
537 (char *)(tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
538 (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
540 opname_tab = (const char **)oballoc ((int)LAST_CPLUS_TREE_CODE * sizeof (char *));
541 bzero ((char *)opname_tab, (int)LAST_CPLUS_TREE_CODE * sizeof (char *));
542 assignop_tab = (const char **)oballoc ((int)LAST_CPLUS_TREE_CODE * sizeof (char *));
543 bzero ((char *)assignop_tab, (int)LAST_CPLUS_TREE_CODE * sizeof (char *));
545 ansi_opname[0] = get_identifier ("<invalid operator>");
546 for (i = 0; i < (int) LAST_CPLUS_TREE_CODE; i++)
548 ansi_opname[i] = ansi_opname[0];
549 ansi_assopname[i] = ansi_opname[0];
552 ansi_opname[(int) MULT_EXPR] = get_identifier ("__ml");
553 IDENTIFIER_OPNAME_P (ansi_opname[(int) MULT_EXPR]) = 1;
554 ansi_opname[(int) INDIRECT_REF] = ansi_opname[(int) MULT_EXPR];
555 ansi_assopname[(int) MULT_EXPR] = get_identifier ("__aml");
556 IDENTIFIER_OPNAME_P (ansi_assopname[(int) MULT_EXPR]) = 1;
557 ansi_assopname[(int) INDIRECT_REF] = ansi_assopname[(int) MULT_EXPR];
558 ansi_opname[(int) TRUNC_MOD_EXPR] = get_identifier ("__md");
559 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUNC_MOD_EXPR]) = 1;
560 ansi_assopname[(int) TRUNC_MOD_EXPR] = get_identifier ("__amd");
561 IDENTIFIER_OPNAME_P (ansi_assopname[(int) TRUNC_MOD_EXPR]) = 1;
562 ansi_opname[(int) CEIL_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
563 ansi_opname[(int) FLOOR_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
564 ansi_opname[(int) ROUND_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
565 ansi_opname[(int) MINUS_EXPR] = get_identifier ("__mi");
566 IDENTIFIER_OPNAME_P (ansi_opname[(int) MINUS_EXPR]) = 1;
567 ansi_opname[(int) NEGATE_EXPR] = ansi_opname[(int) MINUS_EXPR];
568 ansi_assopname[(int) MINUS_EXPR] = get_identifier ("__ami");
569 IDENTIFIER_OPNAME_P (ansi_assopname[(int) MINUS_EXPR]) = 1;
570 ansi_assopname[(int) NEGATE_EXPR] = ansi_assopname[(int) MINUS_EXPR];
571 ansi_opname[(int) RSHIFT_EXPR] = get_identifier ("__rs");
572 IDENTIFIER_OPNAME_P (ansi_opname[(int) RSHIFT_EXPR]) = 1;
573 ansi_assopname[(int) RSHIFT_EXPR] = get_identifier ("__ars");
574 IDENTIFIER_OPNAME_P (ansi_assopname[(int) RSHIFT_EXPR]) = 1;
575 ansi_opname[(int) NE_EXPR] = get_identifier ("__ne");
576 IDENTIFIER_OPNAME_P (ansi_opname[(int) NE_EXPR]) = 1;
577 ansi_opname[(int) GT_EXPR] = get_identifier ("__gt");
578 IDENTIFIER_OPNAME_P (ansi_opname[(int) GT_EXPR]) = 1;
579 ansi_opname[(int) GE_EXPR] = get_identifier ("__ge");
580 IDENTIFIER_OPNAME_P (ansi_opname[(int) GE_EXPR]) = 1;
581 ansi_opname[(int) BIT_IOR_EXPR] = get_identifier ("__or");
582 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_IOR_EXPR]) = 1;
583 ansi_assopname[(int) BIT_IOR_EXPR] = get_identifier ("__aor");
584 IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_IOR_EXPR]) = 1;
585 ansi_opname[(int) TRUTH_ANDIF_EXPR] = get_identifier ("__aa");
586 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_ANDIF_EXPR]) = 1;
587 ansi_opname[(int) TRUTH_NOT_EXPR] = get_identifier ("__nt");
588 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_NOT_EXPR]) = 1;
589 ansi_opname[(int) PREINCREMENT_EXPR] = get_identifier ("__pp");
590 IDENTIFIER_OPNAME_P (ansi_opname[(int) PREINCREMENT_EXPR]) = 1;
591 ansi_opname[(int) POSTINCREMENT_EXPR] = ansi_opname[(int) PREINCREMENT_EXPR];
592 ansi_opname[(int) MODIFY_EXPR] = get_identifier ("__as");
593 IDENTIFIER_OPNAME_P (ansi_opname[(int) MODIFY_EXPR]) = 1;
594 ansi_assopname[(int) NOP_EXPR] = ansi_opname[(int) MODIFY_EXPR];
595 ansi_opname[(int) COMPOUND_EXPR] = get_identifier ("__cm");
596 IDENTIFIER_OPNAME_P (ansi_opname[(int) COMPOUND_EXPR]) = 1;
597 ansi_opname[(int) EXACT_DIV_EXPR] = get_identifier ("__dv");
598 IDENTIFIER_OPNAME_P (ansi_opname[(int) EXACT_DIV_EXPR]) = 1;
599 ansi_assopname[(int) EXACT_DIV_EXPR] = get_identifier ("__adv");
600 IDENTIFIER_OPNAME_P (ansi_assopname[(int) EXACT_DIV_EXPR]) = 1;
601 ansi_opname[(int) TRUNC_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
602 ansi_opname[(int) CEIL_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
603 ansi_opname[(int) FLOOR_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
604 ansi_opname[(int) ROUND_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
605 ansi_opname[(int) PLUS_EXPR] = get_identifier ("__pl");
606 ansi_assopname[(int) TRUNC_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
607 ansi_assopname[(int) CEIL_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
608 ansi_assopname[(int) FLOOR_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
609 ansi_assopname[(int) ROUND_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
610 IDENTIFIER_OPNAME_P (ansi_opname[(int) PLUS_EXPR]) = 1;
611 ansi_assopname[(int) PLUS_EXPR] = get_identifier ("__apl");
612 IDENTIFIER_OPNAME_P (ansi_assopname[(int) PLUS_EXPR]) = 1;
613 ansi_opname[(int) CONVERT_EXPR] = ansi_opname[(int) PLUS_EXPR];
614 ansi_assopname[(int) CONVERT_EXPR] = ansi_assopname[(int) PLUS_EXPR];
615 ansi_opname[(int) LSHIFT_EXPR] = get_identifier ("__ls");
616 IDENTIFIER_OPNAME_P (ansi_opname[(int) LSHIFT_EXPR]) = 1;
617 ansi_assopname[(int) LSHIFT_EXPR] = get_identifier ("__als");
618 IDENTIFIER_OPNAME_P (ansi_assopname[(int) LSHIFT_EXPR]) = 1;
619 ansi_opname[(int) EQ_EXPR] = get_identifier ("__eq");
620 IDENTIFIER_OPNAME_P (ansi_opname[(int) EQ_EXPR]) = 1;
621 ansi_opname[(int) LT_EXPR] = get_identifier ("__lt");
622 IDENTIFIER_OPNAME_P (ansi_opname[(int) LT_EXPR]) = 1;
623 ansi_opname[(int) LE_EXPR] = get_identifier ("__le");
624 IDENTIFIER_OPNAME_P (ansi_opname[(int) LE_EXPR]) = 1;
625 ansi_opname[(int) BIT_AND_EXPR] = get_identifier ("__ad");
626 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_AND_EXPR]) = 1;
627 ansi_assopname[(int) BIT_AND_EXPR] = get_identifier ("__aad");
628 IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_AND_EXPR]) = 1;
629 ansi_opname[(int) ADDR_EXPR] = ansi_opname[(int) BIT_AND_EXPR];
630 ansi_assopname[(int) ADDR_EXPR] = ansi_assopname[(int) BIT_AND_EXPR];
631 ansi_opname[(int) BIT_XOR_EXPR] = get_identifier ("__er");
632 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_XOR_EXPR]) = 1;
633 ansi_assopname[(int) BIT_XOR_EXPR] = get_identifier ("__aer");
634 IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_XOR_EXPR]) = 1;
635 ansi_opname[(int) TRUTH_ORIF_EXPR] = get_identifier ("__oo");
636 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_ORIF_EXPR]) = 1;
637 ansi_opname[(int) BIT_NOT_EXPR] = get_identifier ("__co");
638 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_NOT_EXPR]) = 1;
639 ansi_opname[(int) PREDECREMENT_EXPR] = get_identifier ("__mm");
640 IDENTIFIER_OPNAME_P (ansi_opname[(int) PREDECREMENT_EXPR]) = 1;
641 ansi_opname[(int) POSTDECREMENT_EXPR] = ansi_opname[(int) PREDECREMENT_EXPR];
642 ansi_opname[(int) COMPONENT_REF] = get_identifier ("__rf");
643 IDENTIFIER_OPNAME_P (ansi_opname[(int) COMPONENT_REF]) = 1;
644 ansi_opname[(int) MEMBER_REF] = get_identifier ("__rm");
645 IDENTIFIER_OPNAME_P (ansi_opname[(int) MEMBER_REF]) = 1;
646 ansi_opname[(int) CALL_EXPR] = get_identifier ("__cl");
647 IDENTIFIER_OPNAME_P (ansi_opname[(int) CALL_EXPR]) = 1;
648 ansi_opname[(int) ARRAY_REF] = get_identifier ("__vc");
649 IDENTIFIER_OPNAME_P (ansi_opname[(int) ARRAY_REF]) = 1;
650 ansi_opname[(int) NEW_EXPR] = get_identifier ("__nw");
651 IDENTIFIER_OPNAME_P (ansi_opname[(int) NEW_EXPR]) = 1;
652 ansi_opname[(int) DELETE_EXPR] = get_identifier ("__dl");
653 IDENTIFIER_OPNAME_P (ansi_opname[(int) DELETE_EXPR]) = 1;
654 ansi_opname[(int) VEC_NEW_EXPR] = get_identifier ("__vn");
655 IDENTIFIER_OPNAME_P (ansi_opname[(int) VEC_NEW_EXPR]) = 1;
656 ansi_opname[(int) VEC_DELETE_EXPR] = get_identifier ("__vd");
657 IDENTIFIER_OPNAME_P (ansi_opname[(int) VEC_DELETE_EXPR]) = 1;
658 ansi_opname[(int) TYPE_EXPR] = get_identifier (OPERATOR_TYPENAME_FORMAT);
659 IDENTIFIER_OPNAME_P (ansi_opname[(int) TYPE_EXPR]) = 1;
661 /* This is not true: these operators are not defined in ANSI,
662 but we need them anyway. */
663 ansi_opname[(int) MIN_EXPR] = get_identifier ("__mn");
664 IDENTIFIER_OPNAME_P (ansi_opname[(int) MIN_EXPR]) = 1;
665 ansi_opname[(int) MAX_EXPR] = get_identifier ("__mx");
666 IDENTIFIER_OPNAME_P (ansi_opname[(int) MAX_EXPR]) = 1;
667 ansi_opname[(int) COND_EXPR] = get_identifier ("__cn");
668 IDENTIFIER_OPNAME_P (ansi_opname[(int) COND_EXPR]) = 1;
669 ansi_opname[(int) SIZEOF_EXPR] = get_identifier ("__sz");
670 IDENTIFIER_OPNAME_P (ansi_opname[(int) SIZEOF_EXPR]) = 1;
674 gcc_obstack_init (&inline_text_obstack);
675 inline_text_firstobj = (char *) obstack_alloc (&inline_text_obstack, 0);
677 /* Start it at 0, because check_newline is called at the very beginning
678 and will increment it to 1. */
680 input_filename = "<internal>";
681 current_function_decl = NULL;
684 token_buffer = (char *) xmalloc (maxtoken + 2);
686 ridpointers[(int) RID_INT] = get_identifier ("int");
687 ridpointers[(int) RID_BOOL] = get_identifier ("bool");
688 ridpointers[(int) RID_CHAR] = get_identifier ("char");
689 ridpointers[(int) RID_VOID] = get_identifier ("void");
690 ridpointers[(int) RID_FLOAT] = get_identifier ("float");
691 ridpointers[(int) RID_DOUBLE] = get_identifier ("double");
692 ridpointers[(int) RID_SHORT] = get_identifier ("short");
693 ridpointers[(int) RID_LONG] = get_identifier ("long");
694 ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned");
695 ridpointers[(int) RID_SIGNED] = get_identifier ("signed");
696 ridpointers[(int) RID_INLINE] = get_identifier ("inline");
697 ridpointers[(int) RID_CONST] = get_identifier ("const");
698 ridpointers[(int) RID_RESTRICT] = get_identifier ("__restrict");
699 ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
700 ridpointers[(int) RID_AUTO] = get_identifier ("auto");
701 ridpointers[(int) RID_STATIC] = get_identifier ("static");
702 ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
703 ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
704 ridpointers[(int) RID_REGISTER] = get_identifier ("register");
705 ridpointers[(int) RID_COMPLEX] = get_identifier ("__complex");
707 /* C++ extensions. These are probably not correctly named. */
708 ridpointers[(int) RID_WCHAR] = get_identifier ("__wchar_t");
709 class_type_node = build_int_2 (class_type, 0);
710 TREE_TYPE (class_type_node) = class_type_node;
711 ridpointers[(int) RID_CLASS] = class_type_node;
713 record_type_node = build_int_2 (record_type, 0);
714 TREE_TYPE (record_type_node) = record_type_node;
715 ridpointers[(int) RID_RECORD] = record_type_node;
717 union_type_node = build_int_2 (union_type, 0);
718 TREE_TYPE (union_type_node) = union_type_node;
719 ridpointers[(int) RID_UNION] = union_type_node;
721 enum_type_node = build_int_2 (enum_type, 0);
722 TREE_TYPE (enum_type_node) = enum_type_node;
723 ridpointers[(int) RID_ENUM] = enum_type_node;
725 ridpointers[(int) RID_VIRTUAL] = get_identifier ("virtual");
726 ridpointers[(int) RID_EXPLICIT] = get_identifier ("explicit");
727 ridpointers[(int) RID_EXPORT] = get_identifier ("export");
728 ridpointers[(int) RID_FRIEND] = get_identifier ("friend");
730 ridpointers[(int) RID_PUBLIC] = get_identifier ("public");
731 ridpointers[(int) RID_PRIVATE] = get_identifier ("private");
732 ridpointers[(int) RID_PROTECTED] = get_identifier ("protected");
733 ridpointers[(int) RID_TEMPLATE] = get_identifier ("template");
734 /* This is for ANSI C++. */
735 ridpointers[(int) RID_MUTABLE] = get_identifier ("mutable");
737 /* Create the built-in __null node. Note that we can't yet call for
738 type_for_size here because integer_type_node and so forth are not
739 set up. Therefore, we don't set the type of these nodes until
740 init_decl_processing. */
741 null_node = build_int_2 (0, 0);
742 ridpointers[RID_NULL] = null_node;
744 opname_tab[(int) COMPONENT_REF] = "->";
745 opname_tab[(int) MEMBER_REF] = "->*";
746 opname_tab[(int) INDIRECT_REF] = "*";
747 opname_tab[(int) ARRAY_REF] = "[]";
748 opname_tab[(int) MODIFY_EXPR] = "=";
749 opname_tab[(int) NEW_EXPR] = "new";
750 opname_tab[(int) DELETE_EXPR] = "delete";
751 opname_tab[(int) VEC_NEW_EXPR] = "new []";
752 opname_tab[(int) VEC_DELETE_EXPR] = "delete []";
753 opname_tab[(int) COND_EXPR] = "?:";
754 opname_tab[(int) CALL_EXPR] = "()";
755 opname_tab[(int) PLUS_EXPR] = "+";
756 opname_tab[(int) MINUS_EXPR] = "-";
757 opname_tab[(int) MULT_EXPR] = "*";
758 opname_tab[(int) TRUNC_DIV_EXPR] = "/";
759 opname_tab[(int) CEIL_DIV_EXPR] = "(ceiling /)";
760 opname_tab[(int) FLOOR_DIV_EXPR] = "(floor /)";
761 opname_tab[(int) ROUND_DIV_EXPR] = "(round /)";
762 opname_tab[(int) TRUNC_MOD_EXPR] = "%";
763 opname_tab[(int) CEIL_MOD_EXPR] = "(ceiling %)";
764 opname_tab[(int) FLOOR_MOD_EXPR] = "(floor %)";
765 opname_tab[(int) ROUND_MOD_EXPR] = "(round %)";
766 opname_tab[(int) EXACT_DIV_EXPR] = "/";
767 opname_tab[(int) NEGATE_EXPR] = "-";
768 opname_tab[(int) MIN_EXPR] = "<?";
769 opname_tab[(int) MAX_EXPR] = ">?";
770 opname_tab[(int) ABS_EXPR] = "abs";
771 opname_tab[(int) FFS_EXPR] = "ffs";
772 opname_tab[(int) LSHIFT_EXPR] = "<<";
773 opname_tab[(int) RSHIFT_EXPR] = ">>";
774 opname_tab[(int) BIT_IOR_EXPR] = "|";
775 opname_tab[(int) BIT_XOR_EXPR] = "^";
776 opname_tab[(int) BIT_AND_EXPR] = "&";
777 opname_tab[(int) BIT_ANDTC_EXPR] = "&~";
778 opname_tab[(int) BIT_NOT_EXPR] = "~";
779 opname_tab[(int) TRUTH_ANDIF_EXPR] = "&&";
780 opname_tab[(int) TRUTH_ORIF_EXPR] = "||";
781 opname_tab[(int) TRUTH_AND_EXPR] = "strict &&";
782 opname_tab[(int) TRUTH_OR_EXPR] = "strict ||";
783 opname_tab[(int) TRUTH_NOT_EXPR] = "!";
784 opname_tab[(int) LT_EXPR] = "<";
785 opname_tab[(int) LE_EXPR] = "<=";
786 opname_tab[(int) GT_EXPR] = ">";
787 opname_tab[(int) GE_EXPR] = ">=";
788 opname_tab[(int) EQ_EXPR] = "==";
789 opname_tab[(int) NE_EXPR] = "!=";
790 opname_tab[(int) IN_EXPR] = "in";
791 opname_tab[(int) RANGE_EXPR] = "...";
792 opname_tab[(int) CONVERT_EXPR] = "+";
793 opname_tab[(int) ADDR_EXPR] = "&";
794 opname_tab[(int) PREDECREMENT_EXPR] = "--";
795 opname_tab[(int) PREINCREMENT_EXPR] = "++";
796 opname_tab[(int) POSTDECREMENT_EXPR] = "--";
797 opname_tab[(int) POSTINCREMENT_EXPR] = "++";
798 opname_tab[(int) COMPOUND_EXPR] = ",";
800 assignop_tab[(int) NOP_EXPR] = "=";
801 assignop_tab[(int) PLUS_EXPR] = "+=";
802 assignop_tab[(int) CONVERT_EXPR] = "+=";
803 assignop_tab[(int) MINUS_EXPR] = "-=";
804 assignop_tab[(int) NEGATE_EXPR] = "-=";
805 assignop_tab[(int) MULT_EXPR] = "*=";
806 assignop_tab[(int) INDIRECT_REF] = "*=";
807 assignop_tab[(int) TRUNC_DIV_EXPR] = "/=";
808 assignop_tab[(int) EXACT_DIV_EXPR] = "(exact /=)";
809 assignop_tab[(int) CEIL_DIV_EXPR] = "(ceiling /=)";
810 assignop_tab[(int) FLOOR_DIV_EXPR] = "(floor /=)";
811 assignop_tab[(int) ROUND_DIV_EXPR] = "(round /=)";
812 assignop_tab[(int) TRUNC_MOD_EXPR] = "%=";
813 assignop_tab[(int) CEIL_MOD_EXPR] = "(ceiling %=)";
814 assignop_tab[(int) FLOOR_MOD_EXPR] = "(floor %=)";
815 assignop_tab[(int) ROUND_MOD_EXPR] = "(round %=)";
816 assignop_tab[(int) MIN_EXPR] = "<?=";
817 assignop_tab[(int) MAX_EXPR] = ">?=";
818 assignop_tab[(int) LSHIFT_EXPR] = "<<=";
819 assignop_tab[(int) RSHIFT_EXPR] = ">>=";
820 assignop_tab[(int) BIT_IOR_EXPR] = "|=";
821 assignop_tab[(int) BIT_XOR_EXPR] = "^=";
822 assignop_tab[(int) BIT_AND_EXPR] = "&=";
823 assignop_tab[(int) ADDR_EXPR] = "&=";
825 init_filename_times ();
827 /* Some options inhibit certain reserved words.
828 Clear those words out of the hash table so they won't be recognized. */
829 #define UNSET_RESERVED_WORD(STRING) \
830 do { struct resword *s = is_reserved_word (STRING, sizeof (STRING) - 1); \
831 if (s) s->name = ""; } while (0)
834 /* let's parse things, and if they use it, then give them an error. */
835 if (!flag_exceptions)
837 UNSET_RESERVED_WORD ("throw");
838 UNSET_RESERVED_WORD ("try");
839 UNSET_RESERVED_WORD ("catch");
843 if (!flag_rtti || flag_no_gnu_keywords)
845 UNSET_RESERVED_WORD ("classof");
846 UNSET_RESERVED_WORD ("headof");
849 if (flag_no_asm || flag_no_gnu_keywords)
850 UNSET_RESERVED_WORD ("typeof");
851 if (! flag_operator_names)
853 /* These are new ANSI keywords that may break code. */
854 UNSET_RESERVED_WORD ("and");
855 UNSET_RESERVED_WORD ("and_eq");
856 UNSET_RESERVED_WORD ("bitand");
857 UNSET_RESERVED_WORD ("bitor");
858 UNSET_RESERVED_WORD ("compl");
859 UNSET_RESERVED_WORD ("not");
860 UNSET_RESERVED_WORD ("not_eq");
861 UNSET_RESERVED_WORD ("or");
862 UNSET_RESERVED_WORD ("or_eq");
863 UNSET_RESERVED_WORD ("xor");
864 UNSET_RESERVED_WORD ("xor_eq");
867 token_count = init_cpp_parse ();
868 interface_unknown = 1;
877 cpp_finish (&parse_in);
878 errorcount += parse_in.errors;
885 reinit_parse_for_function ()
887 current_base_init_list = NULL_TREE;
888 current_member_init_list = NULL_TREE;
895 yyprint (file, yychar, yylval)
908 case IDENTIFIER_DEFN:
912 case PRE_PARSED_CLASS_DECL:
914 if (TREE_CODE (t) == TYPE_DECL || TREE_CODE (t) == TEMPLATE_DECL)
916 fprintf (file, " `%s'", IDENTIFIER_POINTER (DECL_NAME (t)));
919 my_friendly_assert (TREE_CODE (t) == IDENTIFIER_NODE, 224);
920 if (IDENTIFIER_POINTER (t))
921 fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
925 if (yylval.ttype == class_type_node)
926 fprintf (file, " `class'");
927 else if (yylval.ttype == record_type_node)
928 fprintf (file, " `struct'");
929 else if (yylval.ttype == union_type_node)
930 fprintf (file, " `union'");
931 else if (yylval.ttype == enum_type_node)
932 fprintf (file, " `enum'");
934 my_friendly_abort (80);
939 if (TREE_CODE (t) == INTEGER_CST)
941 #if HOST_BITS_PER_WIDE_INT == 64
942 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
945 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
952 #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
958 TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
963 #if defined(GATHER_STATISTICS) && defined(REDUCE_LENGTH)
964 static int *reduce_count;
970 #define REDUCE_LENGTH (sizeof (yyr2) / sizeof (yyr2[0]))
971 #define TOKEN_LENGTH (256 + sizeof (yytname) / sizeof (yytname[0]))
974 #ifdef GATHER_STATISTICS
980 reduce_count[yyn] += 1;
987 return reduce_count[*q] - reduce_count[*p];
994 return token_count[*q] - token_count[*p];
1000 print_parse_statistics ()
1002 #ifdef GATHER_STATISTICS
1003 #ifdef REDUCE_LENGTH
1006 int maxlen = REDUCE_LENGTH;
1009 if (reduce_count[-1] == 0)
1012 if (TOKEN_LENGTH > REDUCE_LENGTH)
1013 maxlen = TOKEN_LENGTH;
1014 sorted = (unsigned *) alloca (sizeof (int) * maxlen);
1016 for (i = 0; i < TOKEN_LENGTH; i++)
1018 qsort (sorted, TOKEN_LENGTH, sizeof (int), token_cmp);
1019 for (i = 0; i < TOKEN_LENGTH; i++)
1021 int idx = sorted[i];
1022 if (token_count[idx] == 0)
1024 if (token_count[idx] < token_count[-1])
1026 fprintf (stderr, "token %d, `%s', count = %d\n",
1027 idx, yytname[YYTRANSLATE (idx)], token_count[idx]);
1029 fprintf (stderr, "\n");
1030 for (i = 0; i < REDUCE_LENGTH; i++)
1032 qsort (sorted, REDUCE_LENGTH, sizeof (int), reduce_cmp);
1033 for (i = 0; i < REDUCE_LENGTH; i++)
1035 int idx = sorted[i];
1036 if (reduce_count[idx] == 0)
1038 if (reduce_count[idx] < reduce_count[-1])
1040 fprintf (stderr, "rule %d, line %d, count = %d\n",
1041 idx, yyrline[idx], reduce_count[idx]);
1043 fprintf (stderr, "\n");
1049 /* Sets the value of the 'yydebug' variable to VALUE.
1050 This is a function so we don't have to have YYDEBUG defined
1051 in order to build the compiler. */
1061 warning ("YYDEBUG not defined.");
1066 /* Functions and data structures for #pragma interface.
1068 `#pragma implementation' means that the main file being compiled
1069 is considered to implement (provide) the classes that appear in
1070 its main body. I.e., if this is file "foo.cc", and class `bar'
1071 is defined in "foo.cc", then we say that "foo.cc implements bar".
1073 All main input files "implement" themselves automagically.
1075 `#pragma interface' means that unless this file (of the form "foo.h"
1076 is not presently being included by file "foo.cc", the
1077 CLASSTYPE_INTERFACE_ONLY bit gets set. The effect is that none
1078 of the vtables nor any of the inline functions defined in foo.h
1079 will ever be output.
1081 There are cases when we want to link files such as "defs.h" and
1082 "main.cc". In this case, we give "defs.h" a `#pragma interface',
1083 and "main.cc" has `#pragma implementation "defs.h"'. */
1088 struct impl_files *next;
1091 static struct impl_files *impl_file_chain;
1093 /* Helper function to load global variables with interface
1097 extract_interface_info ()
1101 if (flag_alt_external_templates)
1103 struct tinst_level *til = tinst_for_decl ();
1106 fileinfo = get_time_identifier (til->file);
1109 fileinfo = get_time_identifier (input_filename);
1110 fileinfo = TIME_IDENTIFIER_FILEINFO (fileinfo);
1111 interface_only = TREE_INT_CST_LOW (fileinfo);
1112 interface_unknown = TREE_INT_CST_HIGH (fileinfo);
1115 /* Return nonzero if S is not considered part of an
1116 INTERFACE/IMPLEMENTATION pair. Otherwise, return 0. */
1119 interface_strcmp (s)
1122 /* Set the interface/implementation bits for this scope. */
1123 struct impl_files *ifiles;
1126 for (ifiles = impl_file_chain; ifiles; ifiles = ifiles->next)
1128 const char *t1 = ifiles->filename;
1131 if (*s1 != *t1 || *s1 == 0)
1134 while (*s1 == *t1 && *s1 != 0)
1141 /* Don't get faked out by xxx.yyy.cc vs xxx.zzz.cc. */
1142 if (index (s1, '.') || index (t1, '.'))
1145 if (*s1 == '\0' || s1[-1] != '.' || t1[-1] != '.')
1157 cp_pragma_interface (main_filename)
1158 char *main_filename;
1161 = TIME_IDENTIFIER_FILEINFO (get_time_identifier (input_filename));
1163 if (impl_file_chain == 0)
1165 /* If this is zero at this point, then we are
1166 auto-implementing. */
1167 if (main_input_filename == 0)
1168 main_input_filename = input_filename;
1170 #ifdef AUTO_IMPLEMENT
1171 filename = file_name_nondirectory (main_input_filename);
1172 fi = get_time_identifier (filename);
1173 fi = TIME_IDENTIFIER_FILEINFO (fi);
1174 TREE_INT_CST_LOW (fi) = 0;
1175 TREE_INT_CST_HIGH (fi) = 1;
1177 impl_file_chain = (struct impl_files *)permalloc (sizeof (struct impl_files));
1178 impl_file_chain->filename = filename;
1179 impl_file_chain->next = 0;
1183 interface_only = interface_strcmp (main_filename);
1184 #ifdef MULTIPLE_SYMBOL_SPACES
1185 if (! interface_only)
1186 interface_unknown = 0;
1187 #else /* MULTIPLE_SYMBOL_SPACES */
1188 interface_unknown = 0;
1189 #endif /* MULTIPLE_SYMBOL_SPACES */
1190 TREE_INT_CST_LOW (fileinfo) = interface_only;
1191 TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
1195 cp_pragma_implementation (main_filename)
1196 char *main_filename;
1199 = TIME_IDENTIFIER_FILEINFO (get_time_identifier (input_filename));
1201 if (impl_file_chain)
1203 struct impl_files *ifiles = impl_file_chain;
1206 if (! strcmp (ifiles->filename, main_filename))
1208 ifiles = ifiles->next;
1212 ifiles = (struct impl_files*) permalloc (sizeof (struct impl_files));
1213 ifiles->filename = main_filename;
1214 ifiles->next = impl_file_chain;
1215 impl_file_chain = ifiles;
1218 else if ((main_input_filename != 0
1219 && ! strcmp (main_input_filename, input_filename))
1220 || ! strcmp (main_filename, input_filename))
1222 impl_file_chain = (struct impl_files*) permalloc (sizeof (struct impl_files));
1223 impl_file_chain->filename = main_filename;
1224 impl_file_chain->next = 0;
1227 error ("`#pragma implementation' can only appear at top-level");
1230 /* We make this non-zero so that we infer decl linkage
1231 in the impl file only for variables first declared
1232 in the interface file. */
1233 interface_unknown = 1;
1235 /* We make this zero so that templates in the impl
1236 file will be emitted properly. */
1237 interface_unknown = 0;
1239 TREE_INT_CST_LOW (fileinfo) = interface_only;
1240 TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
1243 /* Set up the state required to correctly handle the definition of the
1244 inline function whose preparsed state has been saved in PI. */
1247 begin_definition_of_inclass_inline (pi)
1248 struct pending_inline* pi;
1255 /* If this is an inline function in a local class, we must make sure
1256 that we save all pertinent information about the function
1257 surrounding the local class. */
1258 context = hack_decl_function_context (pi->fndecl);
1260 push_cp_function_context (context);
1262 feed_input (pi->buf, pi->len, pi->filename, pi->lineno);
1263 yychar = PRE_PARSED_FUNCTION_DECL;
1264 yylval.ttype = build_tree_list ((tree) pi, pi->fndecl);
1265 /* Pass back a handle to the rest of the inline functions, so that they
1266 can be processed later. */
1267 DECL_PENDING_INLINE_INFO (pi->fndecl) = 0;
1268 interface_unknown = pi->interface == 1;
1269 interface_only = pi->interface == 0;
1272 /* Called from the top level: if there are any pending inlines to
1273 do, set up to process them now. This function sets up the first function
1274 to be parsed; after it has been, the rule for fndef in parse.y will
1275 call process_next_inline to start working on the next one. */
1278 do_pending_inlines ()
1280 struct pending_inline *t;
1282 /* Oops, we're still dealing with the last batch. */
1283 if (yychar == PRE_PARSED_FUNCTION_DECL)
1286 /* Reverse the pending inline functions, since
1287 they were cons'd instead of appended. */
1289 struct pending_inline *prev = 0, *tail;
1290 t = pending_inlines;
1291 pending_inlines = 0;
1306 /* Now start processing the first inline function. */
1307 begin_definition_of_inclass_inline (t);
1310 /* Called from the fndecl rule in the parser when the function just parsed
1311 was declared using a PRE_PARSED_FUNCTION_DECL (i.e. came from
1312 do_pending_inlines). */
1315 process_next_inline (t)
1319 struct pending_inline *i = (struct pending_inline *) TREE_PURPOSE (t);
1320 context = hack_decl_function_context (i->fndecl);
1322 pop_cp_function_context (context);
1324 if (yychar == YYEMPTY)
1326 if (yychar != END_OF_SAVED_INPUT)
1328 error ("parse error at end of saved function text");
1330 /* restore_pending_input will abort unless yychar is either
1331 END_OF_SAVED_INPUT or YYEMPTY; since we already know we're
1332 hosed, feed back YYEMPTY. */
1337 begin_definition_of_inclass_inline (i);
1339 extract_interface_info ();
1342 /* Since inline methods can refer to text which has not yet been seen,
1343 we store the text of the method in a structure which is placed in the
1344 DECL_PENDING_INLINE_INFO field of the FUNCTION_DECL.
1345 After parsing the body of the class definition, the FUNCTION_DECL's are
1346 scanned to see which ones have this field set. Those are then digested
1349 This function's FUNCTION_DECL will have a bit set in its common so
1350 that we know to watch out for it. */
1353 consume_string (this_obstack, matching_char)
1354 register struct obstack *this_obstack;
1358 int starting_lineno;
1361 if (cpp_token == CPP_STRING)
1363 /* The C preprocessor will warn about newlines in strings. */
1364 obstack_grow (this_obstack, yy_cur, (yy_lim - yy_cur));
1366 lineno = parse_in.lineno;
1371 starting_lineno = lineno;
1377 int save_lineno = lineno;
1378 lineno = starting_lineno;
1379 if (matching_char == '"')
1380 error ("end of file encountered inside string constant");
1382 error ("end of file encountered inside character constant");
1383 lineno = save_lineno;
1388 obstack_1grow (this_obstack, c);
1390 obstack_1grow (this_obstack, c);
1392 /* Make sure we continue the loop */
1399 pedwarn ("ANSI C++ forbids newline in string constant");
1402 obstack_1grow (this_obstack, c);
1404 while (c != matching_char);
1407 struct pending_input {
1410 struct obstack token_obstack;
1414 struct pending_input *
1415 save_pending_input ()
1417 struct pending_input *p;
1418 p = (struct pending_input *) xmalloc (sizeof (struct pending_input));
1421 p->eof = end_of_file;
1423 p->first_token = first_token;
1424 p->token_obstack = token_obstack;
1427 gcc_obstack_init (&token_obstack);
1433 restore_pending_input (p)
1434 struct pending_input *p;
1436 my_friendly_assert (yychar == YYEMPTY || yychar == END_OF_SAVED_INPUT, 230);
1439 first_token = p->first_token;
1440 obstack_free (&token_obstack, (char *) 0);
1441 token_obstack = p->token_obstack;
1442 end_of_file = p->eof;
1446 /* Unget character CH from the input stream.
1447 If RESCAN is non-zero, then we want to `see' this
1448 character as the next input token. */
1451 yyungetc (ch, rescan)
1455 /* Unget a character from the input stream. */
1456 if (yychar == YYEMPTY || rescan == 0)
1458 /* If we're putting back a brace, undo the change in indent_level
1459 from the first time we saw it. */
1474 clear_inline_text_obstack ()
1476 obstack_free (&inline_text_obstack, inline_text_firstobj);
1479 /* This function stores away the text for an inline function that should
1480 be processed later. It decides how much later, and may need to move
1481 the info between obstacks; therefore, the caller should not refer to
1482 the T parameter after calling this function. */
1485 store_pending_inline (decl, t)
1487 struct pending_inline *t;
1490 DECL_PENDING_INLINE_INFO (decl) = t;
1492 /* Because we use obstacks, we must process these in precise order. */
1493 t->next = pending_inlines;
1494 pending_inlines = t;
1498 reinit_parse_for_method (yychar, decl)
1503 int starting_lineno = lineno;
1504 char *starting_filename = input_filename;
1506 reinit_parse_for_block (yychar, &inline_text_obstack);
1508 len = obstack_object_size (&inline_text_obstack);
1509 current_base_init_list = NULL_TREE;
1510 current_member_init_list = NULL_TREE;
1511 if (decl == void_type_node
1512 || (current_class_type && TYPE_REDEFINED (current_class_type)))
1514 /* Happens when we get two declarations of the same
1515 function in the same scope. */
1516 char *buf = obstack_finish (&inline_text_obstack);
1517 obstack_free (&inline_text_obstack, buf);
1522 struct pending_inline *t;
1523 char *buf = obstack_finish (&inline_text_obstack);
1525 t = (struct pending_inline *) obstack_alloc (&inline_text_obstack,
1526 sizeof (struct pending_inline));
1527 t->lineno = starting_lineno;
1528 t->filename = starting_filename;
1535 if (interface_unknown && processing_template_defn && flag_external_templates && ! DECL_IN_SYSTEM_HEADER (decl))
1536 warn_if_unknown_interface (decl);
1538 t->interface = (interface_unknown ? 1 : (interface_only ? 0 : 2));
1539 store_pending_inline (decl, t);
1543 /* Consume a block -- actually, a method beginning
1544 with `:' or `{' -- and save it away on the specified obstack. */
1547 reinit_parse_for_block (pyychar, obstackp)
1549 struct obstack *obstackp;
1553 int starting_lineno = lineno;
1554 char *starting_filename = input_filename;
1556 int look_for_semicolon = 0;
1557 int look_for_lbrac = 0;
1561 obstack_1grow (obstackp, '{');
1562 /* We incremented indent_level in yylex; undo that. */
1565 else if (pyychar == '=')
1566 look_for_semicolon = 1;
1567 else if (pyychar == ':')
1569 obstack_1grow (obstackp, pyychar);
1570 /* Add a space so we don't get confused by ': ::A(20)'. */
1571 obstack_1grow (obstackp, ' ');
1575 else if (pyychar == RETURN_KEYWORD)
1577 obstack_grow (obstackp, "return", 6);
1581 else if (pyychar == TRY)
1583 obstack_grow (obstackp, "try", 3);
1589 yyerror ("parse error in method specification");
1590 obstack_1grow (obstackp, '{');
1597 int this_lineno = lineno;
1599 c = skip_white_space (c);
1601 /* Don't lose our cool if there are lots of comments. */
1602 if (lineno == this_lineno + 1)
1603 obstack_1grow (obstackp, '\n');
1604 else if (lineno == this_lineno)
1606 else if (lineno - this_lineno < 10)
1609 for (i = lineno - this_lineno; i > 0; i--)
1610 obstack_1grow (obstackp, '\n');
1615 sprintf (buf, "\n# %d \"", lineno);
1617 obstack_grow (obstackp, buf, len);
1619 len = strlen (input_filename);
1620 obstack_grow (obstackp, input_filename, len);
1621 obstack_1grow (obstackp, '\"');
1622 obstack_1grow (obstackp, '\n');
1625 while (c > ' ') /* ASCII dependent... */
1627 obstack_1grow (obstackp, c);
1636 if (blev == 0 && !look_for_semicolon)
1640 if (peekyylex () == CATCH)
1643 obstack_grow (obstackp, " catch ", 7);
1660 /* Don't act on the next character...e.g, doing an escaped
1665 error_with_file_and_line (starting_filename,
1667 "end of file read inside definition");
1670 obstack_1grow (obstackp, c);
1673 consume_string (obstackp, c);
1675 consume_string (obstackp, c);
1680 error ("function body for constructor missing");
1681 obstack_1grow (obstackp, '{');
1682 obstack_1grow (obstackp, '}');
1686 else if (look_for_semicolon && blev == 0)
1694 error_with_file_and_line (starting_filename,
1696 "end of file read inside definition");
1701 obstack_1grow (obstackp, c);
1706 obstack_1grow (obstackp, '\0');
1709 /* Consume a no-commas expression -- actually, a default argument -- and
1710 save it away on the specified obstack. */
1713 reinit_parse_for_expr (obstackp)
1714 struct obstack *obstackp;
1717 int starting_lineno = lineno;
1718 char *starting_filename = input_filename;
1726 int this_lineno = lineno;
1728 c = skip_white_space (c);
1730 /* Don't lose our cool if there are lots of comments. */
1731 if (lineno == this_lineno + 1)
1732 obstack_1grow (obstackp, '\n');
1733 else if (lineno == this_lineno)
1735 else if (lineno - this_lineno < 10)
1738 for (i = lineno - this_lineno; i > 0; --i)
1739 obstack_1grow (obstackp, '\n');
1744 sprintf (buf, "\n# %d \"", lineno);
1746 obstack_grow (obstackp, buf, len);
1748 len = strlen (input_filename);
1749 obstack_grow (obstackp, input_filename, len);
1750 obstack_1grow (obstackp, '\"');
1751 obstack_1grow (obstackp, '\n');
1754 while (c > ' ') /* ASCII dependent... */
1756 if (plev <= 0 && (c == ')' || c == ','))
1761 obstack_1grow (obstackp, c);
1762 if (c == '(' || c == '[')
1764 else if (c == ']' || c == ')')
1768 /* Don't act on the next character...e.g, doing an escaped
1773 error_with_file_and_line (starting_filename,
1775 "end of file read inside definition");
1778 obstack_1grow (obstackp, c);
1781 consume_string (obstackp, c);
1783 consume_string (obstackp, c);
1789 error_with_file_and_line (starting_filename,
1791 "end of file read inside definition");
1796 obstack_1grow (obstackp, c);
1801 obstack_1grow (obstackp, '\0');
1804 int do_snarf_defarg;
1806 /* Decide whether the default argument we are about to see should be
1807 gobbled up as text for later parsing. */
1810 maybe_snarf_defarg ()
1812 if (current_class_type && TYPE_BEING_DEFINED (current_class_type))
1813 do_snarf_defarg = 1;
1816 /* When we see a default argument in a method declaration, we snarf it as
1817 text using snarf_defarg. When we get up to namespace scope, we then go
1818 through and parse all of them using do_pending_defargs. Since yacc
1819 parsers are not reentrant, we retain defargs state in these two
1820 variables so that subsequent calls to do_pending_defargs can resume
1821 where the previous call left off. */
1833 reinit_parse_for_expr (&inline_text_obstack);
1834 len = obstack_object_size (&inline_text_obstack);
1835 buf = obstack_finish (&inline_text_obstack);
1837 push_obstacks (&inline_text_obstack, &inline_text_obstack);
1838 arg = make_node (DEFAULT_ARG);
1839 DEFARG_LENGTH (arg) = len - 1;
1840 DEFARG_POINTER (arg) = buf;
1846 /* Called from grokfndecl to note a function decl with unparsed default
1847 arguments for later processing. Also called from grokdeclarator
1848 for function types with unparsed defargs; the call from grokfndecl
1849 will always come second, so we can overwrite the entry from the type. */
1852 add_defarg_fn (decl)
1855 if (TREE_CODE (decl) == FUNCTION_DECL)
1856 TREE_VALUE (defarg_fns) = decl;
1859 push_obstacks (&inline_text_obstack, &inline_text_obstack);
1860 defarg_fns = tree_cons (current_class_type, decl, defarg_fns);
1865 /* Helper for do_pending_defargs. Starts the parsing of a default arg. */
1871 tree d = TREE_PURPOSE (p);
1874 if (TREE_CODE (f) == FUNCTION_DECL)
1876 line = DECL_SOURCE_LINE (f);
1877 file = DECL_SOURCE_FILE (f);
1882 file = input_filename;
1885 feed_input (DEFARG_POINTER (d), DEFARG_LENGTH (d), file, line);
1886 yychar = DEFARG_MARKER;
1890 /* Helper for do_pending_defargs. Ends the parsing of a default arg. */
1895 if (yychar == YYEMPTY)
1897 if (yychar != END_OF_SAVED_INPUT)
1899 error ("parse error at end of saved function text");
1901 /* restore_pending_input will abort unless yychar is either
1902 END_OF_SAVED_INPUT or YYEMPTY; since we already know we're
1903 hosed, feed back YYEMPTY. */
1909 /* Main function for deferred parsing of default arguments. Called from
1913 do_pending_defargs ()
1918 for (; defarg_fns; defarg_fns = TREE_CHAIN (defarg_fns))
1920 tree defarg_fn = TREE_VALUE (defarg_fns);
1921 if (defarg_parm == NULL_TREE)
1923 push_nested_class (TREE_PURPOSE (defarg_fns), 1);
1925 if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
1926 maybe_begin_member_template_processing (defarg_fn);
1928 if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
1932 for (p = DECL_ARGUMENTS (defarg_fn); p; p = TREE_CHAIN (p))
1933 pushdecl (copy_node (p));
1935 defarg_parm = TYPE_ARG_TYPES (TREE_TYPE (defarg_fn));
1938 defarg_parm = TYPE_ARG_TYPES (defarg_fn);
1941 defarg_parm = TREE_CHAIN (defarg_parm);
1943 for (; defarg_parm; defarg_parm = TREE_CHAIN (defarg_parm))
1944 if (TREE_PURPOSE (defarg_parm)
1945 && TREE_CODE (TREE_PURPOSE (defarg_parm)) == DEFAULT_ARG)
1947 feed_defarg (defarg_fn, defarg_parm);
1949 /* Return to the parser, which will process this defarg
1950 and call us again. */
1954 if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
1956 maybe_end_member_template_processing ();
1957 check_default_args (defarg_fn);
1961 pop_nested_class ();
1965 /* Build a default function named NAME for type TYPE.
1966 KIND says what to build.
1968 When KIND == 0, build default destructor.
1969 When KIND == 1, build virtual destructor.
1970 When KIND == 2, build default constructor.
1971 When KIND == 3, build default X(const X&) constructor.
1972 When KIND == 4, build default X(X&) constructor.
1973 When KIND == 5, build default operator = (const X&).
1974 When KIND == 6, build default operator = (X&). */
1977 cons_up_default_function (type, full_name, kind)
1978 tree type, full_name;
1981 tree declspecs = NULL_TREE;
1982 tree fn, args = NULL_TREE;
1985 tree name = constructor_name (full_name);
1991 declspecs = build_decl_list (NULL_TREE, ridpointers [(int) RID_VIRTUAL]);
1992 /* Fall through... */
1994 name = build_parse_node (BIT_NOT_EXPR, name);
1995 args = void_list_node;
1999 /* Default constructor. */
2000 args = void_list_node;
2004 type = build_qualified_type (type, TYPE_QUAL_CONST);
2005 /* Fall through... */
2007 /* According to ARM $12.8, the default copy ctor will be declared, but
2008 not defined, unless it's needed. */
2009 argtype = build_reference_type (type);
2010 args = tree_cons (NULL_TREE,
2011 build_tree_list (hash_tree_chain (argtype, NULL_TREE),
2012 get_identifier ("_ctor_arg")),
2019 declspecs = build_decl_list (NULL_TREE, type);
2022 type = build_qualified_type (type, TYPE_QUAL_CONST);
2024 name = ansi_opname [(int) MODIFY_EXPR];
2026 argtype = build_reference_type (type);
2027 args = tree_cons (NULL_TREE,
2028 build_tree_list (hash_tree_chain (argtype, NULL_TREE),
2029 get_identifier ("_ctor_arg")),
2034 my_friendly_abort (59);
2037 declspecs = decl_tree_cons (NULL_TREE, ridpointers [(int) RID_INLINE],
2040 TREE_PARMLIST (args) = 1;
2043 tree declarator = make_call_declarator (name, args, NULL_TREE, NULL_TREE);
2045 declarator = build_parse_node (ADDR_EXPR, declarator);
2047 fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE, NULL_TREE);
2050 if (fn == void_type_node)
2054 SET_DECL_ARTIFICIAL (TREE_CHAIN (DECL_ARGUMENTS (fn)));
2057 if (processing_template_defn)
2059 SET_DECL_IMPLICIT_INSTANTIATION (fn);
2060 repo_template_used (fn);
2065 if (CLASSTYPE_INTERFACE_KNOWN (type))
2067 DECL_INTERFACE_KNOWN (fn) = 1;
2068 DECL_NOT_REALLY_EXTERN (fn) = (!CLASSTYPE_INTERFACE_ONLY (type)
2069 && flag_implement_inlines);
2073 DECL_NOT_REALLY_EXTERN (fn) = 1;
2075 mark_inline_for_output (fn);
2077 #ifdef DEBUG_DEFAULT_FUNCTIONS
2078 { char *fn_type = NULL;
2082 case 0: fn_type = "default destructor"; break;
2083 case 1: fn_type = "virtual destructor"; break;
2084 case 2: fn_type = "default constructor"; break;
2085 case 3: fn_type = "default X(const X&)"; break;
2086 case 4: fn_type = "default X(X&)"; break;
2090 if (TREE_CODE (name) == BIT_NOT_EXPR)
2091 t = TREE_OPERAND (name, 0);
2092 fprintf (stderr, "[[[[ %s for %s:\n%s]]]]\n", fn_type,
2093 IDENTIFIER_POINTER (t), func_buf);
2096 #endif /* DEBUG_DEFAULT_FUNCTIONS */
2098 /* Show that this function was generated by the compiler. */
2099 SET_DECL_ARTIFICIAL (fn);
2104 /* Heuristic to tell whether the user is missing a semicolon
2105 after a struct or enum declaration. Emit an error message
2106 if we know the user has blown it. */
2109 check_for_missing_semicolon (type)
2117 && yychar != IDENTIFIER
2118 && yychar != TYPENAME
2119 && yychar != CV_QUALIFIER
2120 && yychar != SELFNAME)
2123 if (ANON_AGGRNAME_P (TYPE_IDENTIFIER (type)))
2124 error ("semicolon missing after %s declaration",
2125 TREE_CODE (type) == ENUMERAL_TYPE ? "enum" : "struct");
2127 cp_error ("semicolon missing after declaration of `%T'", type);
2128 shadow_tag (build_tree_list (0, type));
2130 /* Could probably also hack cases where class { ... } f (); appears. */
2135 note_got_semicolon (type)
2138 if (TREE_CODE_CLASS (TREE_CODE (type)) != 't')
2139 my_friendly_abort (60);
2140 if (CLASS_TYPE_P (type))
2141 CLASSTYPE_GOT_SEMICOLON (type) = 1;
2145 note_list_got_semicolon (declspecs)
2150 for (link = declspecs; link; link = TREE_CHAIN (link))
2152 tree type = TREE_VALUE (link);
2153 if (TREE_CODE_CLASS (TREE_CODE (type)) == 't')
2154 note_got_semicolon (type);
2159 /* Iff C is a carriage return, warn about it - if appropriate -
2160 and return nonzero. */
2165 static int newline_warning = 0;
2169 /* ANSI C says the effects of a carriage return in a source file
2171 if (pedantic && !newline_warning)
2173 warning ("carriage return in source file");
2174 warning ("(we only warn about the first carriage return)");
2175 newline_warning = 1;
2182 /* If C is not whitespace, return C.
2183 Otherwise skip whitespace and return first nonwhite char read. */
2186 skip_white_space (c)
2193 /* We don't recognize comments here, because
2194 cpp output can include / and * consecutively as operators.
2195 Also, there's no need, since cpp removes all comments. */
2203 c = check_newline ();
2212 /* While processing a # directive we don't get CPP_HSPACE
2213 tokens, so we also need to handle whitespace the normal way. */
2214 if (cpp_token == CPP_HSPACE)
2215 c = yy_get_token ();
2231 error ("stray '\\' in program");
2241 /* Make the token buffer longer, preserving the data in it.
2242 P should point to just beyond the last valid character in the old buffer.
2243 The value we return is a pointer to the new buffer
2244 at a place corresponding to P. */
2247 extend_token_buffer_to (size)
2251 maxtoken = maxtoken * 2 + 10;
2252 while (maxtoken < size);
2253 token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2);
2257 extend_token_buffer (p)
2260 int offset = p - token_buffer;
2261 extend_token_buffer_to (offset);
2262 return token_buffer + offset;
2265 #if defined HANDLE_PRAGMA
2266 /* Local versions of these macros, that can be passed as function pointers. */
2282 read_line_number (num)
2285 register int token = real_yylex ();
2287 if (token == CONSTANT
2288 && TREE_CODE (yylval.ttype) == INTEGER_CST)
2290 *num = TREE_INT_CST_LOW (yylval.ttype);
2295 if (token != END_OF_LINE)
2296 error ("invalid #-line");
2301 /* At the beginning of a line, increment the line number
2302 and process any #-directive on this line.
2303 If the line is a #-directive, read the entire line and return a newline.
2304 Otherwise, return the line's first non-whitespace character.
2306 Note that in the case of USE_CPPLIB, we get the whole line as one
2307 CPP_DIRECTIVE token. */
2315 enum { act_none, act_push, act_pop } action;
2316 int old_lineno, action_number, l;
2317 int entering_c_header;
2320 /* Read first nonwhite char on the line. Do this before incrementing the
2321 line number, in case we're at the end of saved text. */
2325 /* In some cases where we're leaving an include file, we can get multiple
2326 CPP_HSPACE tokens in a row, so we need to loop. */
2327 while (cpp_token == CPP_HSPACE)
2328 c = yy_get_token ();
2332 while (c == ' ' || c == '\t');
2339 /* Sequences of multiple newlines are very common; optimize them. */
2343 /* If not #, return it so caller will use it. */
2347 /* Don't read beyond this line. */
2352 if (cpp_token == CPP_VSPACE)
2354 /* Format is "<space> <line number> <filename> <newline>".
2355 Only the line number is interesting, and even that
2356 we can get more efficiently than scanning the line. */
2357 yy_cur = yy_lim - 1;
2358 lineno = parse_in.lineno - 1;
2363 token = real_yylex ();
2365 if (token == IDENTIFIER)
2367 /* If a letter follows, then if the word here is `line', skip
2368 it and ignore it; otherwise, ignore the line, with an error
2369 if the word isn't `pragma'. */
2371 const char *name = IDENTIFIER_POINTER (yylval.ttype);
2373 if (!strcmp (name, "pragma"))
2375 token = real_yylex ();
2376 if (token != IDENTIFIER
2377 || TREE_CODE (yylval.ttype) != IDENTIFIER_NODE)
2380 /* If this is 1, we handled it; if it's -1, it was one we
2381 wanted but had something wrong with it. Only if it's
2382 0 was it not handled. */
2383 if (handle_cp_pragma (IDENTIFIER_POINTER (yylval.ttype)))
2386 #ifdef HANDLE_PRAGMA
2387 /* We invoke HANDLE_PRAGMA before HANDLE_GENERIC_PRAGMAS
2388 (if both are defined), in order to give the back
2389 end a chance to override the interpretation of
2390 SYSV style pragmas. */
2391 if (HANDLE_PRAGMA (pragma_getc, pragma_ungetc,
2392 IDENTIFIER_POINTER (yylval.ttype)))
2394 #endif /* HANDLE_PRAGMA */
2396 #ifdef HANDLE_GENERIC_PRAGMAS
2397 if (handle_generic_pragma (token))
2399 #endif /* HANDLE_GENERIC_PRAGMAS */
2401 /* Issue a warning message if we have been asked to do so.
2402 Ignoring unknown pragmas in system header file unless
2403 an explcit -Wunknown-pragmas has been given. */
2404 if (warn_unknown_pragmas > 1
2405 || (warn_unknown_pragmas && ! in_system_header))
2406 warning ("ignoring pragma: %s", token_buffer);
2410 else if (!strcmp (name, "define"))
2412 debug_define (lineno, GET_DIRECTIVE_LINE ());
2415 else if (!strcmp (name, "undef"))
2417 debug_undef (lineno, GET_DIRECTIVE_LINE ());
2420 else if (!strcmp (name, "line"))
2423 token = real_yylex ();
2426 else if (!strcmp (name, "ident"))
2428 /* #ident. The pedantic warning is now in cccp.c. */
2430 /* Here we have just seen `#ident '.
2431 A string constant should follow. */
2433 token = real_yylex ();
2434 if (token == END_OF_LINE)
2437 || TREE_CODE (yylval.ttype) != STRING_CST)
2439 error ("invalid #ident");
2443 if (! flag_no_ident)
2445 #ifdef ASM_OUTPUT_IDENT
2446 ASM_OUTPUT_IDENT (asm_out_file,
2447 TREE_STRING_POINTER (yylval.ttype));
2451 /* Skip the rest of this line. */
2455 error ("undefined or invalid # directive `%s'", name);
2459 /* If the # is the only nonwhite char on the line,
2460 just ignore it. Check the new newline. */
2461 if (token == END_OF_LINE)
2465 /* Here we have either `#line' or `# <nonletter>'.
2466 In either case, it should be a line number; a digit should follow. */
2468 if (token != CONSTANT
2469 || TREE_CODE (yylval.ttype) != INTEGER_CST)
2471 error ("invalid #-line");
2475 /* subtract one, because it is the following line that
2476 gets the specified number */
2478 l = TREE_INT_CST_LOW (yylval.ttype) - 1;
2480 /* More follows: it must be a string constant (filename).
2481 It would be neat to use cpplib to quickly process the string, but
2482 (1) we don't have a handy tokenization of the string, and
2483 (2) I don't know how well that would work in the presense
2484 of filenames that contain wide characters. */
2488 /* Don't treat \ as special if we are processing #line 1 "...".
2489 If you want it to be treated specially, use # 1 "...". */
2490 ignore_escape_flag = 1;
2493 /* Read the string constant. */
2494 token = real_yylex ();
2496 ignore_escape_flag = 0;
2498 if (token == END_OF_LINE)
2500 /* No more: store the line number and check following line. */
2505 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
2507 error ("invalid #line");
2511 /* Changing files again. This means currently collected time
2512 is charged against header time, and body time starts back at 0. */
2513 if (flag_detailed_statistics)
2515 int this_time = my_get_run_time ();
2516 tree time_identifier = get_time_identifier (TREE_STRING_POINTER (yylval.ttype));
2517 header_time += this_time - body_time;
2518 TREE_INT_CST_LOW (TIME_IDENTIFIER_TIME (this_filename_time))
2519 += this_time - body_time;
2520 this_filename_time = time_identifier;
2521 body_time = this_time;
2524 if (!TREE_PERMANENT (yylval.ttype))
2527 = (char *) permalloc (TREE_STRING_LENGTH (yylval.ttype) + 1);
2528 strcpy (input_filename, TREE_STRING_POINTER (yylval.ttype));
2531 input_filename = TREE_STRING_POINTER (yylval.ttype);
2533 GNU_xref_file (input_filename);
2535 if (main_input_filename == 0)
2537 struct impl_files *ifiles = impl_file_chain;
2541 while (ifiles->next)
2542 ifiles = ifiles->next;
2543 ifiles->filename = file_name_nondirectory (input_filename);
2546 main_input_filename = input_filename;
2549 extract_interface_info ();
2551 old_lineno = lineno;
2556 /* Each change of file name
2557 reinitializes whether we are now in a system header. */
2558 in_system_header = 0;
2559 entering_c_header = 0;
2561 if (!read_line_number (&action_number))
2563 /* Update the name in the top element of input_file_stack. */
2564 if (input_file_stack)
2565 input_file_stack->name = input_filename;
2568 /* `1' after file name means entering new file.
2569 `2' after file name means just left a file. */
2571 if (action_number == 1)
2574 read_line_number (&action_number);
2576 else if (action_number == 2)
2579 read_line_number (&action_number);
2581 if (action_number == 3)
2583 /* `3' after file name means this is a system header file. */
2584 in_system_header = 1;
2585 read_line_number (&action_number);
2587 if (action_number == 4)
2589 /* `4' after file name means this is a C header file. */
2590 entering_c_header = 1;
2591 read_line_number (&action_number);
2594 /* Do the actions implied by the preceding numbers. */
2596 if (action == act_push)
2598 /* Pushing to a new file. */
2599 struct file_stack *p
2600 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2601 input_file_stack->line = old_lineno;
2602 p->next = input_file_stack;
2603 p->name = input_filename;
2604 p->indent_level = indent_level;
2605 input_file_stack = p;
2606 input_file_stack_tick++;
2607 debug_start_source_file (input_filename);
2610 else if (entering_c_header)
2613 ++pending_lang_change;
2616 else if (action == act_pop)
2618 /* Popping out of a file. */
2619 if (input_file_stack->next)
2621 struct file_stack *p = input_file_stack;
2623 if (c_header_level && --c_header_level == 0)
2625 if (entering_c_header)
2626 warning ("badly nested C headers from preprocessor");
2627 --pending_lang_change;
2630 if (indent_level != p->indent_level)
2632 warning_with_file_and_line
2633 (p->name, old_lineno,
2634 "This file contains more `%c's than `%c's.",
2635 indent_level > p->indent_level ? '{' : '}',
2636 indent_level > p->indent_level ? '}' : '{');
2638 input_file_stack = p->next;
2640 input_file_stack_tick++;
2641 debug_end_source_file (input_file_stack->line);
2644 error ("#-lines for entering and leaving files don't match");
2647 /* Now that we've pushed or popped the input stack,
2648 update the name in the top element. */
2649 if (input_file_stack)
2650 input_file_stack->name = input_filename;
2652 /* skip the rest of this line. */
2659 while (c != '\n' && c != EOF);
2663 #ifdef HANDLE_GENERIC_PRAGMAS
2665 /* Handle a #pragma directive.
2666 TOKEN is the token we read after `#pragma'. Processes the entire input
2667 line and return non-zero iff the pragma has been successfully parsed. */
2669 /* This function has to be in this file, in order to get at
2673 handle_generic_pragma (token)
2684 handle_pragma_token (token_buffer, yylval.ttype);
2688 handle_pragma_token ("(", NULL_TREE);
2689 handle_pragma_token (")", NULL_TREE);
2693 return handle_pragma_token (NULL_PTR, NULL_TREE);
2696 handle_pragma_token (token_buffer, NULL_TREE);
2699 token = real_yylex ();
2702 #endif /* HANDLE_GENERIC_PRAGMAS */
2705 handle_cp_pragma (pname)
2710 if (! strcmp (pname, "vtable"))
2712 extern tree pending_vtables;
2714 /* More follows: it must be a string constant (class name). */
2715 token = real_yylex ();
2716 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
2718 error ("invalid #pragma vtable");
2723 = perm_tree_cons (NULL_TREE,
2724 get_identifier (TREE_STRING_POINTER (yylval.ttype)),
2726 token = real_yylex ();
2727 if (token != END_OF_LINE)
2728 warning ("trailing characters ignored");
2731 else if (! strcmp (pname, "unit"))
2733 /* More follows: it must be a string constant (unit name). */
2734 token = real_yylex ();
2735 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
2737 error ("invalid #pragma unit");
2740 token = real_yylex ();
2741 if (token != END_OF_LINE)
2742 warning ("trailing characters ignored");
2745 else if (! strcmp (pname, "interface"))
2747 char *main_filename = input_filename;
2749 main_filename = file_name_nondirectory (main_filename);
2751 token = real_yylex ();
2753 if (token != END_OF_LINE)
2756 || TREE_CODE (yylval.ttype) != STRING_CST)
2758 error ("invalid `#pragma interface'");
2761 main_filename = TREE_STRING_POINTER (yylval.ttype);
2762 token = real_yylex ();
2765 if (token != END_OF_LINE)
2766 warning ("garbage after `#pragma interface' ignored");
2768 cp_pragma_interface (main_filename);
2772 else if (! strcmp (pname, "implementation"))
2774 char *main_filename = main_input_filename ? main_input_filename : input_filename;
2776 main_filename = file_name_nondirectory (main_filename);
2778 token = real_yylex ();
2780 if (token != END_OF_LINE)
2783 || TREE_CODE (yylval.ttype) != STRING_CST)
2785 error ("invalid `#pragma implementation'");
2788 main_filename = TREE_STRING_POINTER (yylval.ttype);
2789 token = real_yylex ();
2792 if (token != END_OF_LINE)
2793 warning ("garbage after `#pragma implementation' ignored");
2795 cp_pragma_implementation (main_filename);
2804 do_pending_lang_change ()
2806 for (; pending_lang_change > 0; --pending_lang_change)
2807 push_lang_context (lang_name_c);
2808 for (; pending_lang_change < 0; ++pending_lang_change)
2809 pop_lang_context ();
2812 #define ENDFILE -1 /* token that represents end-of-file */
2814 /* Read an escape sequence, returning its equivalent as a character,
2815 or store 1 in *ignore_ptr if it is backslash-newline. */
2818 readescape (ignore_ptr)
2821 register int c = getch ();
2823 register unsigned count;
2824 unsigned firstdig = 0;
2842 if (c >= 'a' && c <= 'f')
2843 code += c - 'a' + 10;
2844 if (c >= 'A' && c <= 'F')
2845 code += c - 'A' + 10;
2846 if (c >= '0' && c <= '9')
2848 if (code != 0 || count != 0)
2857 error ("\\x used with no following hex digits");
2858 else if (count == 0)
2859 /* Digits are all 0's. Ok. */
2861 else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node)
2864 << (TYPE_PRECISION (integer_type_node)
2867 pedwarn ("hex escape out of range");
2870 case '0': case '1': case '2': case '3': case '4':
2871 case '5': case '6': case '7':
2874 while ((c <= '7') && (c >= '0') && (count++ < 3))
2876 code = (code * 8) + (c - '0');
2882 case '\\': case '\'': case '"':
2891 return TARGET_NEWLINE;
2914 pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c);
2920 /* `\(', etc, are used at beginning of line to avoid confusing Emacs. */
2924 /* `\%' is used to prevent SCCS from getting confused. */
2927 pedwarn ("unknown escape sequence `\\%c'", c);
2931 pedwarn ("unknown escape sequence `\\%c'", c);
2933 pedwarn ("unknown escape sequence: `\\' followed by char code 0x%x", c);
2941 extern int end_of_file;
2944 strcpy (buf, string);
2946 /* We can't print string and character constants well
2947 because the token_buffer contains the result of processing escapes. */
2949 strcat (buf, input_redirected ()
2950 ? " at end of saved text"
2951 : " at end of input");
2952 else if (token_buffer[0] == 0)
2953 strcat (buf, " at null character");
2954 else if (token_buffer[0] == '"')
2955 strcat (buf, " before string constant");
2956 else if (token_buffer[0] == '\'')
2957 strcat (buf, " before character constant");
2958 else if (!ISGRAPH ((unsigned char)token_buffer[0]))
2959 sprintf (buf + strlen (buf), " before character 0%o",
2960 (unsigned char) token_buffer[0]);
2962 strcat (buf, " before `%s'");
2964 error (buf, token_buffer);
2967 /* Value is 1 (or 2) if we should try to make the next identifier look like
2968 a typename (when it may be a local variable or a class variable).
2969 Value is 0 if we treat this name in a default fashion. */
2970 int looking_for_typename;
2976 identifier_type (decl)
2980 if (TREE_CODE (decl) == TEMPLATE_DECL)
2982 if (TREE_CODE (DECL_RESULT (decl)) == TYPE_DECL)
2984 else if (looking_for_template)
2987 if (looking_for_template && really_overloaded_fn (decl))
2989 /* See through a baselink. */
2990 if (TREE_CODE (decl) == TREE_LIST)
2991 decl = TREE_VALUE (decl);
2993 for (t = decl; t != NULL_TREE; t = OVL_CHAIN (t))
2994 if (DECL_FUNCTION_TEMPLATE_P (OVL_FUNCTION (t)))
2997 if (TREE_CODE (decl) == NAMESPACE_DECL)
2999 if (TREE_CODE (decl) != TYPE_DECL)
3001 if (DECL_ARTIFICIAL (decl) && TREE_TYPE (decl) == current_class_type)
3004 /* A constructor declarator for a template type will get here as an
3005 implicit typename, a TYPENAME_TYPE with a type. */
3007 if (t && TREE_CODE (t) == TYPENAME_TYPE)
3009 decl = TREE_TYPE (decl);
3010 if (TREE_CODE (decl) == TYPENAME_TYPE)
3011 decl = TREE_TYPE (decl);
3021 /* Only types expected, not even namespaces. */
3022 looking_for_typename = 2;
3024 if ((yychar = yylex ()) < 0) yychar = 0;
3025 looking_for_typename = 0;
3026 if (yychar == IDENTIFIER)
3028 lastiddecl = lookup_name (yylval.ttype, -2);
3029 if (lastiddecl == 0)
3032 lastiddecl = IDENTIFIER_LABEL_VALUE (yylval.ttype);
3035 yychar = identifier_type (lastiddecl);
3039 /* Return true if d is in a global scope. */
3046 switch (TREE_CODE (d))
3051 case OVERLOAD: d = OVL_FUNCTION (d); continue;
3052 case TREE_LIST: d = TREE_VALUE (d); continue;
3054 my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (d)) == 'd', 980629);
3056 /* A template parameter is not really global, even though it
3057 has no enclosing scope. */
3058 if (DECL_TEMPLATE_PARM_P (d))
3061 d = CP_DECL_CONTEXT (d);
3062 return TREE_CODE (d) == NAMESPACE_DECL;
3067 do_identifier (token, parsing, args)
3068 register tree token;
3073 int lexing = (parsing == 1);
3074 int in_call = (parsing == 2);
3076 if (! lexing || IDENTIFIER_OPNAME_P (token))
3077 id = lookup_name (token, 0);
3081 /* Do Koenig lookup if appropriate (inside templates we build lookup
3082 expressions instead). */
3083 if (args && !current_template_parms && (!id || is_global (id)))
3084 /* If we have arguments and we only found global names, do Koenig
3086 id = lookup_arg_dependent (token, id, args);
3088 /* Remember that this name has been used in the class definition, as per
3091 /* Avoid breaking if we get called for a default argument that
3092 refers to an overloaded method. Eventually this will not be
3093 necessary, since default arguments shouldn't be parsed until
3094 after the class is complete. (jason 3/12/97) */
3095 && TREE_CODE (id) != OVERLOAD)
3096 maybe_note_name_used_in_class (token, id);
3098 if (id == error_mark_node)
3100 /* lookup_name quietly returns error_mark_node if we're parsing,
3101 as we don't want to complain about an identifier that ends up
3102 being used as a declarator. So we call it again to get the error
3104 id = lookup_name (token, 0);
3105 return error_mark_node;
3110 if (current_template_parms)
3111 return build_min_nt (LOOKUP_EXPR, token);
3112 else if (IDENTIFIER_OPNAME_P (token))
3114 if (token != ansi_opname[ERROR_MARK])
3115 cp_error ("`%D' not defined", token);
3116 id = error_mark_node;
3118 else if (in_call && ! flag_strict_prototype)
3120 id = implicitly_declare (token);
3122 else if (current_function_decl == 0)
3124 cp_error ("`%D' was not declared in this scope", token);
3125 id = error_mark_node;
3129 if (IDENTIFIER_NAMESPACE_VALUE (token) != error_mark_node
3130 || IDENTIFIER_ERROR_LOCUS (token) != current_function_decl)
3132 static int undeclared_variable_notice;
3134 cp_error ("`%D' undeclared (first use this function)", token);
3136 if (! undeclared_variable_notice)
3138 error ("(Each undeclared identifier is reported only once");
3139 error ("for each function it appears in.)");
3140 undeclared_variable_notice = 1;
3143 id = error_mark_node;
3144 /* Prevent repeated error messages. */
3145 SET_IDENTIFIER_NAMESPACE_VALUE (token, error_mark_node);
3146 SET_IDENTIFIER_ERROR_LOCUS (token, current_function_decl);
3150 if (TREE_CODE (id) == VAR_DECL && DECL_DEAD_FOR_LOCAL (id))
3152 tree shadowed = DECL_SHADOWED_FOR_VAR (id);
3153 while (shadowed != NULL_TREE && TREE_CODE (shadowed) == VAR_DECL
3154 && DECL_DEAD_FOR_LOCAL (shadowed))
3155 shadowed = DECL_SHADOWED_FOR_VAR (shadowed);
3157 shadowed = IDENTIFIER_NAMESPACE_VALUE (DECL_NAME (id));
3160 if (!DECL_ERROR_REPORTED (id))
3162 warning ("name lookup of `%s' changed",
3163 IDENTIFIER_POINTER (token));
3164 cp_warning_at (" matches this `%D' under current ANSI rules",
3166 cp_warning_at (" matches this `%D' under old rules", id);
3167 DECL_ERROR_REPORTED (id) = 1;
3171 else if (!DECL_ERROR_REPORTED (id))
3174 = "name lookup of `%s' changed for new ANSI `for' scoping";
3175 DECL_ERROR_REPORTED (id) = 1;
3176 if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (id)))
3178 error (msg, IDENTIFIER_POINTER (token));
3179 cp_error_at (" cannot use obsolete binding at `%D' because it has a destructor", id);
3180 id = error_mark_node;
3184 pedwarn (msg, IDENTIFIER_POINTER (token));
3185 cp_pedwarn_at (" using obsolete binding at `%D'", id);
3189 /* TREE_USED is set in `hack_identifier'. */
3190 if (TREE_CODE (id) == CONST_DECL)
3193 if (IDENTIFIER_CLASS_VALUE (token) == id)
3194 enforce_access (DECL_REAL_CONTEXT(id), id);
3195 if (!processing_template_decl || DECL_TEMPLATE_PARM_P (id))
3196 id = DECL_INITIAL (id);
3199 id = hack_identifier (id, token);
3201 /* We must look up dependent names when the template is
3202 instantiated, not while parsing it. For now, we don't
3203 distinguish between dependent and independent names. So, for
3204 example, we look up all overloaded functions at
3205 instantiation-time, even though in some cases we should just use
3206 the DECL we have here. We also use LOOKUP_EXPRs to find things
3207 like local variables, rather than creating TEMPLATE_DECLs for the
3208 local variables and then finding matching instantiations. */
3209 if (current_template_parms
3210 && (is_overloaded_fn (id)
3211 /* If it's not going to be around at instantiation time, we
3212 look it up then. This is a hack, and should go when we
3213 really get dependent/independent name lookup right. */
3214 || !TREE_PERMANENT (id)
3215 /* Some local VAR_DECLs (such as those for local variables
3216 in member functions of local classes) are built on the
3217 permanent obstack. */
3218 || (TREE_CODE (id) == VAR_DECL
3219 && CP_DECL_CONTEXT (id)
3220 && TREE_CODE (CP_DECL_CONTEXT (id)) == FUNCTION_DECL)
3221 || TREE_CODE (id) == PARM_DECL
3222 || TREE_CODE (id) == RESULT_DECL
3223 || TREE_CODE (id) == USING_DECL))
3224 id = build_min_nt (LOOKUP_EXPR, token);
3230 do_scoped_id (token, parsing)
3235 /* during parsing, this is ::name. Otherwise, it is black magic. */
3238 struct tree_binding _b;
3239 id = binding_init (&_b);
3240 if (!qualified_lookup_using_namespace (token, global_namespace, id, 0))
3243 id = BINDING_VALUE (id);
3246 id = IDENTIFIER_GLOBAL_VALUE (token);
3247 if (parsing && yychar == YYEMPTY)
3251 if (processing_template_decl)
3253 id = build_min_nt (LOOKUP_EXPR, token);
3254 LOOKUP_EXPR_GLOBAL (id) = 1;
3257 if (parsing && (yychar == '(' || yychar == LEFT_RIGHT)
3258 && ! flag_strict_prototype)
3259 id = implicitly_declare (token);
3262 if (IDENTIFIER_NAMESPACE_VALUE (token) != error_mark_node)
3263 cp_error ("`::%D' undeclared (first use here)", token);
3264 id = error_mark_node;
3265 /* Prevent repeated error messages. */
3266 SET_IDENTIFIER_NAMESPACE_VALUE (token, error_mark_node);
3271 if (TREE_CODE (id) == ADDR_EXPR)
3272 mark_used (TREE_OPERAND (id, 0));
3273 else if (TREE_CODE (id) != OVERLOAD)
3276 if (TREE_CODE (id) == CONST_DECL && ! processing_template_decl)
3278 /* XXX CHS - should we set TREE_USED of the constant? */
3279 id = DECL_INITIAL (id);
3280 /* This is to prevent an enum whose value is 0
3281 from being considered a null pointer constant. */
3282 id = build1 (NOP_EXPR, TREE_TYPE (id), id);
3283 TREE_CONSTANT (id) = 1;
3286 if (processing_template_decl)
3288 if (is_overloaded_fn (id))
3290 id = build_min_nt (LOOKUP_EXPR, token);
3291 LOOKUP_EXPR_GLOBAL (id) = 1;
3294 /* else just use the decl */
3296 return convert_from_reference (id);
3300 identifier_typedecl_value (node)
3304 type = IDENTIFIER_TYPE_VALUE (node);
3305 if (type == NULL_TREE)
3308 if (IDENTIFIER_BINDING (node))
3310 t = IDENTIFIER_VALUE (node);
3311 if (t && TREE_CODE (t) == TYPE_DECL && TREE_TYPE (t) == type)
3314 if (IDENTIFIER_NAMESPACE_VALUE (node))
3316 t = IDENTIFIER_NAMESPACE_VALUE (node);
3317 if (t && TREE_CODE (t) == TYPE_DECL && TREE_TYPE (t) == type)
3321 /* Will this one ever happen? */
3322 if (TYPE_MAIN_DECL (type))
3323 return TYPE_MAIN_DECL (type);
3325 /* We used to do an internal error of 62 here, but instead we will
3326 handle the return of a null appropriately in the callers. */
3340 int conversion_errno;
3341 REAL_VALUE_TYPE value;
3348 struct pf_args * args = (struct pf_args *) data;
3349 int fflag = 0, lflag = 0;
3350 /* Copy token_buffer now, while it has just the number
3351 and not the suffixes; once we add `f' or `i',
3352 REAL_VALUE_ATOF may not work any more. */
3353 char *copy = (char *) alloca (args->p - token_buffer + 1);
3354 bcopy (token_buffer, copy, args->p - token_buffer + 1);
3356 args->conversion_errno = 0;
3357 args->type = double_type_node;
3363 /* Read the suffixes to choose a data type. */
3368 error ("more than one `f' in numeric constant");
3374 error ("more than one `l' in numeric constant");
3380 error ("more than one `i' or `j' in numeric constant");
3382 pedwarn ("ANSI C++ forbids imaginary numeric constants");
3393 if (args->p >= token_buffer + maxtoken - 3)
3394 args->p = extend_token_buffer (args->p);
3395 *(args->p++) = args->c;
3400 /* The second argument, machine_mode, of REAL_VALUE_ATOF
3401 tells the desired precision of the binary result
3402 of decimal-to-binary conversion. */
3407 error ("both `f' and `l' in floating constant");
3409 args->type = float_type_node;
3411 if (args->base == 16)
3412 args->value = REAL_VALUE_HTOF (copy, TYPE_MODE (args->type));
3414 args->value = REAL_VALUE_ATOF (copy, TYPE_MODE (args->type));
3415 args->conversion_errno = errno;
3416 /* A diagnostic is required here by some ANSI C testsuites.
3417 This is not pedwarn, because some people don't want
3418 an error for this. */
3419 if (REAL_VALUE_ISINF (args->value) && pedantic)
3420 warning ("floating point number exceeds range of `float'");
3424 args->type = long_double_type_node;
3426 if (args->base == 16)
3427 args->value = REAL_VALUE_HTOF (copy, TYPE_MODE (args->type));
3429 args->value = REAL_VALUE_ATOF (copy, TYPE_MODE (args->type));
3430 args->conversion_errno = errno;
3431 if (REAL_VALUE_ISINF (args->value) && pedantic)
3432 warning ("floating point number exceeds range of `long double'");
3437 if (args->base == 16)
3438 args->value = REAL_VALUE_HTOF (copy, TYPE_MODE (args->type));
3440 args->value = REAL_VALUE_ATOF (copy, TYPE_MODE (args->type));
3441 args->conversion_errno = errno;
3442 if (REAL_VALUE_ISINF (args->value) && pedantic)
3443 warning ("floating point number exceeds range of `double'");
3447 /* Get the next character, staying within the current token if possible.
3448 If we're lexing a token, we don't want to look beyond the end of the
3449 token cpplib has prepared for us; otherwise, we end up reading in the
3450 next token, which screws up feed_input. So just return a null
3457 if (yy_cur == yy_lim)
3474 /* Read a single token from the input stream, and assign it lexical
3477 Note: We used to do token pasting here, to produce compound tokens like
3478 LEFT_RIGHT and EXTERN_LANG_STRING. That's now handled in spew.c, along
3479 with symbol table interaction and other context-sensitivity. */
3491 /* Effectively do c = skip_white_space (c)
3492 but do it faster in the usual cases. */
3502 if (cpp_token == CPP_HSPACE)
3503 c = yy_get_token ();
3510 /* Call skip_white_space so we can warn if appropriate. */
3515 c = skip_white_space (c);
3517 goto found_nonwhite;
3521 token_buffer[0] = c;
3522 token_buffer[1] = 0;
3524 /* yylloc.first_line = lineno; */
3530 token_buffer[0] = 0;
3532 value = END_OF_LINE;
3533 else if (input_redirected ())
3534 value = END_OF_SAVED_INPUT;
3541 if (cpp_token == CPP_NAME)
3544 /* Capital L may start a wide-string or wide-character constant. */
3546 register int c = token_getch ();
3555 goto string_constant;
3560 case 'A': case 'B': case 'C': case 'D': case 'E':
3561 case 'F': case 'G': case 'H': case 'I': case 'J':
3562 case 'K': case 'M': case 'N': case 'O':
3563 case 'P': case 'Q': case 'R': case 'S': case 'T':
3564 case 'U': case 'V': case 'W': case 'X': case 'Y':
3566 case 'a': case 'b': case 'c': case 'd': case 'e':
3567 case 'f': case 'g': case 'h': case 'i': case 'j':
3568 case 'k': case 'l': case 'm': case 'n': case 'o':
3569 case 'p': case 'q': case 'r': case 's': case 't':
3570 case 'u': case 'v': case 'w': case 'x': case 'y':
3576 if (cpp_token == CPP_NAME)
3578 /* Note that one character has already been read from
3579 yy_cur into token_buffer. Also, cpplib complains about
3580 $ in identifiers, so we don't have to. */
3582 int len = yy_lim - yy_cur + 1;
3583 if (len >= maxtoken)
3584 extend_token_buffer_to (len + 1);
3585 memcpy (token_buffer + 1, yy_cur, len);
3586 p = token_buffer + len;
3593 while (ISALNUM (c) || (c == '_') || c == '$')
3595 /* Make sure this char really belongs in an identifier. */
3598 if (! dollars_in_ident)
3599 error ("`$' in identifier");
3601 pedwarn ("`$' in identifier");
3604 if (p >= token_buffer + maxtoken)
3605 p = extend_token_buffer (p);
3618 /* Try to recognize a keyword. Uses minimum-perfect hash function */
3621 register struct resword *ptr;
3623 if ((ptr = is_reserved_word (token_buffer, p - token_buffer)))
3627 if (ptr->token == VISSPEC)
3632 yylval.ttype = access_public_node;
3635 yylval.ttype = access_private_node;
3638 yylval.ttype = access_protected_node;
3641 my_friendly_abort (63);
3645 yylval.ttype = ridpointers[(int) ptr->rid];
3647 else switch (ptr->token)
3650 yylval.code = NE_EXPR;
3651 token_buffer[0] = '!';
3652 token_buffer[1] = '=';
3653 token_buffer[2] = 0;
3657 if (strcmp ("and_eq", token_buffer) == 0)
3659 yylval.code = BIT_AND_EXPR;
3660 token_buffer[0] = '&';
3662 else if (strcmp ("or_eq", token_buffer) == 0)
3664 yylval.code = BIT_IOR_EXPR;
3665 token_buffer[0] = '|';
3667 else if (strcmp ("xor_eq", token_buffer) == 0)
3669 yylval.code = BIT_XOR_EXPR;
3670 token_buffer[0] = '^';
3672 token_buffer[1] = '=';
3673 token_buffer[2] = 0;
3677 yylval.code = BIT_AND_EXPR;
3678 token_buffer[0] = '&';
3679 token_buffer[1] = 0;
3683 yylval.code = BIT_IOR_EXPR;
3684 token_buffer[0] = '|';
3685 token_buffer[1] = 0;
3689 yylval.code = BIT_XOR_EXPR;
3690 token_buffer[0] = '^';
3691 token_buffer[1] = 0;
3695 value = (int) ptr->token;
3699 /* If we did not find a keyword, look for an identifier
3702 if (value == IDENTIFIER || value == TYPESPEC)
3703 GNU_xref_ref (current_function_decl, token_buffer);
3705 if (value == IDENTIFIER)
3707 register tree tmp = get_identifier (token_buffer);
3709 #if !defined(VMS) && defined(JOINER)
3710 /* Make sure that user does not collide with our internal
3713 && (THIS_NAME_P (tmp)
3714 || VPTR_NAME_P (tmp)
3715 || DESTRUCTOR_NAME_P (tmp)
3716 || VTABLE_NAME_P (tmp)
3717 || TEMP_NAME_P (tmp)
3718 || ANON_AGGRNAME_P (tmp)
3719 || ANON_PARMNAME_P (tmp)))
3720 warning ("identifier name `%s' conflicts with GNU C++ internal naming strategy",
3726 if (value == NEW && ! global_bindings_p ())
3735 if (yy_cur < yy_lim)
3738 /* It's hard to preserve tokenization on '.' because
3739 it could be a symbol by itself, or it could be the
3740 start of a floating point number and cpp won't tell us. */
3741 register int c1 = token_getch ();
3742 token_buffer[1] = c1;
3746 token_buffer[2] = 0;
3751 c1 = token_getch ();
3754 token_buffer[2] = c1;
3755 token_buffer[3] = 0;
3759 error ("parse error at `..'");
3763 token_put_back (c1);
3766 token_put_back (c1);
3769 token_buffer[1] = 0;
3773 /* Optimize for most frequent case. */
3778 cond = (yy_cur == yy_lim);
3780 register int c1 = token_getch ();
3781 token_put_back (c1);
3782 cond = (! ISALNUM (c1) && c1 != '.');
3786 yylval.ttype = (c == '0') ? integer_zero_node : integer_one_node;
3792 case '2': case '3': case '4':
3793 case '5': case '6': case '7': case '8': case '9':
3798 int largest_digit = 0;
3802 /* We actually store only HOST_BITS_PER_CHAR bits in each part.
3803 The code below which fills the parts array assumes that a host
3804 int is at least twice as wide as a host char, and that
3805 HOST_BITS_PER_WIDE_INT is an even multiple of HOST_BITS_PER_CHAR.
3806 Two HOST_WIDE_INTs is the largest int literal we can store.
3807 In order to detect overflow below, the number of parts (TOTAL_PARTS)
3808 must be exactly the number of parts needed to hold the bits
3809 of two HOST_WIDE_INTs. */
3810 #define TOTAL_PARTS ((HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2)
3811 unsigned int parts[TOTAL_PARTS];
3813 enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS, AFTER_EXPON }
3814 floatflag = NOT_FLOAT;
3816 for (count = 0; count < TOTAL_PARTS; count++)
3824 *p++ = (c = token_getch ());
3825 if ((c == 'x') || (c == 'X'))
3828 *p++ = (c = token_getch ());
3830 /* Leading 0 forces octal unless the 0 is the only digit. */
3831 else if (c >= '0' && c <= '9')
3840 /* Read all the digits-and-decimal-points. */
3843 || (ISALNUM (c) && c != 'l' && c != 'L'
3844 && c != 'u' && c != 'U'
3845 && c != 'i' && c != 'I' && c != 'j' && c != 'J'
3846 && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
3850 if (base == 16 && pedantic)
3851 pedwarn ("floating constant may not be in radix 16");
3852 if (floatflag == TOO_MANY_POINTS)
3853 /* We have already emitted an error. Don't need another. */
3855 else if (floatflag == AFTER_POINT || floatflag == AFTER_EXPON)
3857 error ("malformed floating constant");
3858 floatflag = TOO_MANY_POINTS;
3859 /* Avoid another error from atof by forcing all characters
3860 from here on to be ignored. */
3864 floatflag = AFTER_POINT;
3868 *p++ = c = token_getch ();
3869 /* Accept '.' as the start of a floating-point number
3870 only when it is followed by a digit. */
3871 if (p == token_buffer + 2 && !ISDIGIT (c))
3872 my_friendly_abort (990710);
3876 /* It is not a decimal point.
3877 It should be a digit (perhaps a hex digit). */
3883 else if (base <= 10)
3885 if (c == 'e' || c == 'E')
3888 floatflag = AFTER_EXPON;
3889 break; /* start of exponent */
3891 error ("nondigits in number and not hexadecimal");
3894 else if (base == 16 && (c == 'p' || c == 'P'))
3896 floatflag = AFTER_EXPON;
3897 break; /* start of exponent */
3907 if (c >= largest_digit)
3911 for (count = 0; count < TOTAL_PARTS; count++)
3913 parts[count] *= base;
3917 += (parts[count-1] >> HOST_BITS_PER_CHAR);
3919 &= (1 << HOST_BITS_PER_CHAR) - 1;
3925 /* If the highest-order part overflows (gets larger than
3926 a host char will hold) then the whole number has
3927 overflowed. Record this and truncate the highest-order
3929 if (parts[TOTAL_PARTS - 1] >> HOST_BITS_PER_CHAR)
3932 parts[TOTAL_PARTS - 1] &= (1 << HOST_BITS_PER_CHAR) - 1;
3935 if (p >= token_buffer + maxtoken - 3)
3936 p = extend_token_buffer (p);
3937 *p++ = (c = token_getch ());
3941 /* This can happen on input like `int i = 0x;' */
3943 error ("numeric constant with no digits");
3945 if (largest_digit >= base)
3946 error ("numeric constant contains digits beyond the radix");
3948 /* Remove terminating char from the token buffer and delimit the
3952 if (floatflag != NOT_FLOAT)
3955 int imag, conversion_errno;
3956 REAL_VALUE_TYPE value;
3957 struct pf_args args;
3959 /* Read explicit exponent if any, and put it in tokenbuf. */
3961 if ((base == 10 && ((c == 'e') || (c == 'E')))
3962 || (base == 16 && (c == 'p' || c == 'P')))
3964 if (p >= token_buffer + maxtoken - 3)
3965 p = extend_token_buffer (p);
3968 if ((c == '+') || (c == '-'))
3973 /* Exponent is decimal, even if string is a hex float. */
3975 error ("floating constant exponent has no digits");
3978 if (p >= token_buffer + maxtoken - 3)
3979 p = extend_token_buffer (p);
3984 if (base == 16 && floatflag != AFTER_EXPON)
3985 error ("hexadecimal floating constant has no exponent");
3989 /* Setup input for parse_float() */
3994 /* Convert string to a double, checking for overflow. */
3995 if (do_float_handler (parse_float, (PTR) &args))
3997 /* Receive output from parse_float() */
4002 /* We got an exception from parse_float() */
4003 error ("floating constant out of range");
4007 /* Receive output from parse_float() */
4011 conversion_errno = args.conversion_errno;
4014 /* ERANGE is also reported for underflow,
4015 so test the value to distinguish overflow from that. */
4016 if (conversion_errno == ERANGE && pedantic
4017 && (REAL_VALUES_LESS (dconst1, value)
4018 || REAL_VALUES_LESS (value, dconstm1)))
4019 warning ("floating point number exceeds range of `double'");
4022 /* If the result is not a number, assume it must have been
4023 due to some error message above, so silently convert
4025 if (REAL_VALUE_ISNAN (value))
4028 /* Create a node with determined type and value. */
4030 yylval.ttype = build_complex (NULL_TREE,
4031 convert (type, integer_zero_node),
4032 build_real (type, value));
4034 yylval.ttype = build_real (type, value);
4039 HOST_WIDE_INT high, low;
4040 int spec_unsigned = 0;
4042 int spec_long_long = 0;
4049 if (c == 'u' || c == 'U')
4052 error ("two `u's in integer constant");
4055 else if (c == 'l' || c == 'L')
4060 error ("three `l's in integer constant");
4061 else if (pedantic && ! in_system_header && warn_long_long)
4062 pedwarn ("ANSI C++ forbids long long integer constants");
4067 else if (c == 'i' || c == 'j' || c == 'I' || c == 'J')
4070 error ("more than one `i' or `j' in numeric constant");
4072 pedwarn ("ANSI C++ forbids imaginary numeric constants");
4077 if (p >= token_buffer + maxtoken - 3)
4078 p = extend_token_buffer (p);
4083 /* If the literal overflowed, pedwarn about it now. */
4087 pedwarn ("integer constant is too large for this configuration of the compiler - truncated to %d bits", HOST_BITS_PER_WIDE_INT * 2);
4090 /* This is simplified by the fact that our constant
4091 is always positive. */
4095 for (i = 0; i < HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR; i++)
4097 high |= ((HOST_WIDE_INT) parts[i + (HOST_BITS_PER_WIDE_INT
4098 / HOST_BITS_PER_CHAR)]
4099 << (i * HOST_BITS_PER_CHAR));
4100 low |= (HOST_WIDE_INT) parts[i] << (i * HOST_BITS_PER_CHAR);
4103 yylval.ttype = build_int_2 (low, high);
4104 TREE_TYPE (yylval.ttype) = long_long_unsigned_type_node;
4106 /* Calculate the ANSI type. */
4107 if (! spec_long && ! spec_unsigned
4108 && int_fits_type_p (yylval.ttype, integer_type_node))
4109 type = integer_type_node;
4110 else if (! spec_long && (base != 10 || spec_unsigned)
4111 && int_fits_type_p (yylval.ttype, unsigned_type_node))
4112 type = unsigned_type_node;
4113 else if (! spec_unsigned && !spec_long_long
4114 && int_fits_type_p (yylval.ttype, long_integer_type_node))
4115 type = long_integer_type_node;
4116 else if (! spec_long_long
4117 && int_fits_type_p (yylval.ttype,
4118 long_unsigned_type_node))
4119 type = long_unsigned_type_node;
4120 else if (! spec_unsigned
4121 && int_fits_type_p (yylval.ttype,
4122 long_long_integer_type_node))
4123 type = long_long_integer_type_node;
4124 else if (int_fits_type_p (yylval.ttype,
4125 long_long_unsigned_type_node))
4126 type = long_long_unsigned_type_node;
4127 else if (! spec_unsigned
4128 && int_fits_type_p (yylval.ttype,
4129 widest_integer_literal_type_node))
4130 type = widest_integer_literal_type_node;
4132 type = widest_unsigned_literal_type_node;
4134 if (pedantic && !spec_long_long && !warn
4135 && (TYPE_PRECISION (long_integer_type_node)
4136 < TYPE_PRECISION (type)))
4139 pedwarn ("integer constant larger than the maximum value of an unsigned long int");
4142 if (base == 10 && ! spec_unsigned && TREE_UNSIGNED (type))
4143 warning ("decimal constant is so large that it is unsigned");
4147 if (TYPE_PRECISION (type)
4148 <= TYPE_PRECISION (integer_type_node))
4150 = build_complex (NULL_TREE, integer_zero_node,
4151 convert (integer_type_node,
4154 error ("complex integer constant is too wide for `__complex int'");
4157 TREE_TYPE (yylval.ttype) = type;
4160 /* If it's still an integer (not a complex), and it doesn't
4161 fit in the type we choose for it, then pedwarn. */
4164 && TREE_CODE (TREE_TYPE (yylval.ttype)) == INTEGER_TYPE
4165 && ! int_fits_type_p (yylval.ttype, TREE_TYPE (yylval.ttype)))
4166 pedwarn ("integer constant is larger than the maximum value for its type");
4172 if (ISALNUM (c) || c == '.' || c == '_' || c == '$'
4173 || ((c == '-' || c == '+')
4174 && (p[-1] == 'e' || p[-1] == 'E')))
4175 error ("missing white space after number `%s'", token_buffer);
4177 value = CONSTANT; break;
4183 register int result = 0;
4184 register int num_chars = 0;
4186 unsigned width = TYPE_PRECISION (char_type_node);
4188 #ifdef MULTIBYTE_CHARS
4189 int longest_char = local_mb_cur_max ();
4190 local_mbtowc (NULL_PTR, NULL_PTR, 0);
4193 max_chars = TYPE_PRECISION (integer_type_node) / width;
4195 width = WCHAR_TYPE_SIZE;
4202 if (c == '\'' || c == EOF)
4209 c = readescape (&ignore);
4212 if (width < HOST_BITS_PER_INT
4213 && (unsigned) c >= ((unsigned)1 << width))
4214 pedwarn ("escape sequence out of range for character");
4215 #ifdef MAP_CHARACTER
4217 c = MAP_CHARACTER (c);
4223 pedwarn ("ANSI C forbids newline in character constant");
4228 #ifdef MULTIBYTE_CHARS
4232 for (i = 1; i <= longest_char; ++i)
4234 if (i > maxtoken - 4)
4235 extend_token_buffer (token_buffer);
4237 token_buffer[i] = c;
4238 char_len = local_mbtowc (& wc,
4247 /* mbtowc sometimes needs an extra char before accepting */
4252 /* Merge character into result; ignore excess chars. */
4253 for (i = 1; i <= char_len; ++i)
4257 if (width < HOST_BITS_PER_INT)
4258 result = (result << width)
4260 & ((1 << width) - 1));
4262 result = token_buffer[i];
4264 num_chars += char_len;
4273 warning ("Ignoring invalid multibyte character");
4274 /* Replace all but the first byte. */
4275 for (--i; i > 1; --i)
4276 token_put_back (token_buffer[i]);
4277 wc = token_buffer[1];
4279 #ifdef MAP_CHARACTER
4280 c = MAP_CHARACTER (wc);
4285 #else /* ! MULTIBYTE_CHARS */
4286 #ifdef MAP_CHARACTER
4287 c = MAP_CHARACTER (c);
4289 #endif /* ! MULTIBYTE_CHARS */
4294 if (chars_seen == 1) /* only keep the first one */
4299 /* Merge character into result; ignore excess chars. */
4300 num_chars += (width / TYPE_PRECISION (char_type_node));
4301 if (num_chars < max_chars + 1)
4303 if (width < HOST_BITS_PER_INT)
4304 result = (result << width) | (c & ((1 << width) - 1));
4311 error ("malformatted character constant");
4312 else if (chars_seen == 0)
4313 error ("empty character constant");
4314 else if (num_chars > max_chars)
4316 num_chars = max_chars;
4317 error ("character constant too long");
4319 else if (chars_seen != 1 && warn_multichar)
4320 warning ("multi-character character constant");
4322 /* If char type is signed, sign-extend the constant. */
4325 int num_bits = num_chars * width;
4327 /* We already got an error; avoid invalid shift. */
4328 yylval.ttype = build_int_2 (0, 0);
4329 else if (TREE_UNSIGNED (char_type_node)
4330 || ((result >> (num_bits - 1)) & 1) == 0)
4332 = build_int_2 (result & (~(unsigned HOST_WIDE_INT) 0
4333 >> (HOST_BITS_PER_WIDE_INT - num_bits)),
4337 = build_int_2 (result | ~(~(unsigned HOST_WIDE_INT) 0
4338 >> (HOST_BITS_PER_WIDE_INT - num_bits)),
4340 /* In C, a character constant has type 'int'; in C++, 'char'. */
4341 if (chars_seen <= 1)
4342 TREE_TYPE (yylval.ttype) = char_type_node;
4344 TREE_TYPE (yylval.ttype) = integer_type_node;
4348 yylval.ttype = build_int_2 (result, 0);
4349 TREE_TYPE (yylval.ttype) = wchar_type_node;
4359 unsigned width = wide_flag ? WCHAR_TYPE_SIZE
4360 : TYPE_PRECISION (char_type_node);
4361 #ifdef MULTIBYTE_CHARS
4362 int longest_char = local_mb_cur_max ();
4363 local_mbtowc (NULL_PTR, NULL_PTR, 0);
4367 p = token_buffer + 1;
4369 while (c != '"' && c != EOF)
4371 /* ignore_escape_flag is set for reading the filename in #line. */
4372 if (!ignore_escape_flag && c == '\\')
4375 c = readescape (&ignore);
4378 if (width < HOST_BITS_PER_INT
4379 && (unsigned) c >= ((unsigned)1 << width))
4380 pedwarn ("escape sequence out of range for character");
4385 pedwarn ("ANSI C++ forbids newline in string constant");
4390 #ifdef MULTIBYTE_CHARS
4394 for (i = 0; i < longest_char; ++i)
4396 if (p + i >= token_buffer + maxtoken)
4397 p = extend_token_buffer (p);
4400 char_len = local_mbtowc (& wc, p, i + 1);
4407 warning ("Ignoring invalid multibyte character");
4408 /* Replace all except the first byte. */
4410 for (--i; i > 0; --i)
4411 token_put_back (p[i]);
4414 /* mbtowc sometimes needs an extra char before accepting */
4424 #endif /* MULTIBYTE_CHARS */
4427 /* Add this single character into the buffer either as a wchar_t
4428 or as a single byte. */
4431 unsigned width = TYPE_PRECISION (char_type_node);
4432 unsigned bytemask = (1 << width) - 1;
4435 if (p + WCHAR_BYTES > token_buffer + maxtoken)
4436 p = extend_token_buffer (p);
4438 for (byte = 0; byte < WCHAR_BYTES; ++byte)
4441 if (byte >= (int) sizeof (c))
4444 value = (c >> (byte * width)) & bytemask;
4445 if (BYTES_BIG_ENDIAN)
4446 p[WCHAR_BYTES - byte - 1] = value;
4454 if (p >= token_buffer + maxtoken)
4455 p = extend_token_buffer (p);
4463 /* Terminate the string value, either with a single byte zero
4464 or with a wide zero. */
4467 if (p + WCHAR_BYTES > token_buffer + maxtoken)
4468 p = extend_token_buffer (p);
4469 bzero (p, WCHAR_BYTES);
4474 if (p >= token_buffer + maxtoken)
4475 p = extend_token_buffer (p);
4480 error ("Unterminated string constant");
4482 /* We have read the entire constant.
4483 Construct a STRING_CST for the result. */
4485 if (processing_template_decl)
4486 push_obstacks (&permanent_obstack, &permanent_obstack);
4487 yylval.ttype = build_string (p - (token_buffer + 1), token_buffer + 1);
4488 if (processing_template_decl)
4492 TREE_TYPE (yylval.ttype) = wchar_array_type_node;
4494 TREE_TYPE (yylval.ttype) = char_array_type_node;
4496 value = STRING; break;
4520 yylval.code = PLUS_EXPR; break;
4522 yylval.code = MINUS_EXPR; break;
4524 yylval.code = BIT_AND_EXPR; break;
4526 yylval.code = BIT_IOR_EXPR; break;
4528 yylval.code = MULT_EXPR; break;
4530 yylval.code = TRUNC_DIV_EXPR; break;
4532 yylval.code = TRUNC_MOD_EXPR; break;
4534 yylval.code = BIT_XOR_EXPR; break;
4536 yylval.code = LSHIFT_EXPR; break;
4538 yylval.code = RSHIFT_EXPR; break;
4540 yylval.code = LT_EXPR; break;
4542 yylval.code = GT_EXPR; break;
4545 token_buffer[1] = c1 = token_getch ();
4546 token_buffer[2] = 0;
4553 value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done;
4555 value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done;
4557 value = EQCOMPARE; yylval.code = NE_EXPR; goto done;
4559 value = EQCOMPARE; yylval.code = EQ_EXPR; goto done;
4561 value = ASSIGN; goto done;
4567 value = PLUSPLUS; goto done;
4569 value = MINUSMINUS; goto done;
4571 value = ANDAND; goto done;
4573 value = OROR; goto done;
4585 else if (c1 == '?' && (c == '<' || c == '>'))
4587 token_buffer[3] = 0;
4589 c1 = token_getch ();
4590 yylval.code = (c == '<' ? MIN_EXPR : MAX_EXPR);
4593 /* <?= or >?= expression. */
4594 token_buffer[2] = c1;
4600 token_put_back (c1);
4603 pedwarn ("use of `operator %s' is not standard C++",
4613 c1 = token_getch ();
4615 value = POINTSAT_STAR;
4618 token_put_back (c1);
4628 { value = ']'; goto done; }
4632 { value = '{'; indent_level++; goto done; }
4634 { value = '['; goto done; }
4638 { value = '}'; indent_level--; goto done; }
4642 token_put_back (c1);
4643 token_buffer[1] = 0;
4645 /* Here the C frontend changes < and > to ARITHCOMPARE. We don't
4646 do that because of templates. */
4653 /* Don't make yyparse think this is eof. */
4672 /* yylloc.last_line = lineno; */
4673 #ifdef GATHER_STATISTICS
4674 #ifdef REDUCE_LENGTH
4675 token_count[value] += 1;
4686 return !!is_reserved_word (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t));
4689 #ifdef GATHER_STATISTICS
4690 /* The original for tree_node_kind is in the toplevel tree.c; changes there
4691 need to be brought into here, unless this were actually put into a header
4693 /* Statistics-gathering stuff. */
4714 extern int tree_node_counts[];
4715 extern int tree_node_sizes[];
4718 /* Place to save freed lang_decls which were allocated on the
4719 permanent_obstack. @@ Not currently used. */
4720 tree free_lang_decl_chain;
4723 build_lang_decl (code, name, type)
4724 enum tree_code code;
4728 register tree t = build_decl (code, name, type);
4729 retrofit_lang_decl (t);
4733 /* Add DECL_LANG_SPECIFIC info to T. Called from build_lang_decl
4734 and pushdecl (for functions generated by the backend). */
4737 retrofit_lang_decl (t)
4740 struct obstack *obstack = current_obstack;
4741 register int i = sizeof (struct lang_decl) / sizeof (int);
4744 if (! TREE_PERMANENT (t))
4745 obstack = saveable_obstack;
4747 /* Could be that saveable is permanent and current is not. */
4748 obstack = &permanent_obstack;
4750 if (free_lang_decl_chain && obstack == &permanent_obstack)
4752 pi = (int *)free_lang_decl_chain;
4753 free_lang_decl_chain = TREE_CHAIN (free_lang_decl_chain);
4756 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
4761 DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
4762 LANG_DECL_PERMANENT ((struct lang_decl *) pi)
4763 = obstack == &permanent_obstack;
4764 my_friendly_assert (LANG_DECL_PERMANENT ((struct lang_decl *) pi)
4765 == TREE_PERMANENT (t), 234);
4766 DECL_MAIN_VARIANT (t) = t;
4767 if (current_lang_name == lang_name_cplusplus)
4768 DECL_LANGUAGE (t) = lang_cplusplus;
4769 else if (current_lang_name == lang_name_c)
4770 DECL_LANGUAGE (t) = lang_c;
4771 else if (current_lang_name == lang_name_java)
4772 DECL_LANGUAGE (t) = lang_java;
4773 else my_friendly_abort (64);
4775 #if 0 /* not yet, should get fixed properly later */
4776 if (code == TYPE_DECL)
4779 id = get_identifier (build_overload_name (type, 1, 1));
4780 DECL_ASSEMBLER_NAME (t) = id;
4784 #ifdef GATHER_STATISTICS
4785 tree_node_counts[(int)lang_decl] += 1;
4786 tree_node_sizes[(int)lang_decl] += sizeof (struct lang_decl);
4791 build_lang_field_decl (code, name, type)
4792 enum tree_code code;
4796 extern struct obstack *current_obstack, *saveable_obstack;
4797 register tree t = build_decl (code, name, type);
4798 struct obstack *obstack = current_obstack;
4799 register int i = sizeof (struct lang_decl_flags) / sizeof (int);
4801 #if 0 /* not yet, should get fixed properly later */
4803 if (code == TYPE_DECL)
4806 id = get_identifier (build_overload_name (type, 1, 1));
4807 DECL_ASSEMBLER_NAME (t) = id;
4811 if (! TREE_PERMANENT (t))
4812 obstack = saveable_obstack;
4814 my_friendly_assert (obstack == &permanent_obstack, 235);
4816 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl_flags));
4820 DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
4825 copy_lang_decl (node)
4831 if (! DECL_LANG_SPECIFIC (node))
4834 if (TREE_CODE (node) == FIELD_DECL)
4835 size = sizeof (struct lang_decl_flags);
4837 size = sizeof (struct lang_decl);
4838 pi = (int *)obstack_alloc (&permanent_obstack, size);
4839 bcopy ((char *)DECL_LANG_SPECIFIC (node), (char *)pi, size);
4840 DECL_LANG_SPECIFIC (node) = (struct lang_decl *)pi;
4844 make_lang_type (code)
4845 enum tree_code code;
4847 extern struct obstack *current_obstack, *saveable_obstack;
4848 register tree t = make_node (code);
4850 /* Set up some flags that give proper default behavior. */
4851 if (IS_AGGR_TYPE_CODE (code))
4853 struct obstack *obstack = current_obstack;
4854 struct lang_type *pi;
4856 SET_IS_AGGR_TYPE (t, 1);
4858 if (! TREE_PERMANENT (t))
4859 obstack = saveable_obstack;
4861 my_friendly_assert (obstack == &permanent_obstack, 236);
4863 pi = (struct lang_type *) obstack_alloc (obstack, sizeof (struct lang_type));
4864 bzero ((char *) pi, (int) sizeof (struct lang_type));
4866 TYPE_LANG_SPECIFIC (t) = pi;
4867 SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, interface_unknown);
4868 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
4870 /* Make sure this is laid out, for ease of use later. In the
4871 presence of parse errors, the normal was of assuring this
4872 might not ever get executed, so we lay it out *immediately*. */
4873 build_pointer_type (t);
4875 #ifdef GATHER_STATISTICS
4876 tree_node_counts[(int)lang_type] += 1;
4877 tree_node_sizes[(int)lang_type] += sizeof (struct lang_type);
4881 /* We use TYPE_ALIAS_SET for the CLASSTYPE_MARKED bits. But,
4882 TYPE_ALIAS_SET is initialized to -1 by default, so we must
4884 TYPE_ALIAS_SET (t) = 0;
4886 /* We need to allocate a TYPE_BINFO even for TEMPALTE_TYPE_PARMs
4887 since they can be virtual base types, and we then need a
4888 canonical binfo for them. Ideally, this would be done lazily for
4890 if (IS_AGGR_TYPE_CODE (code) || code == TEMPLATE_TYPE_PARM)
4891 TYPE_BINFO (t) = make_binfo (integer_zero_node, t, NULL_TREE, NULL_TREE);
4897 dump_time_statistics ()
4899 register tree prev = 0, decl, next;
4900 int this_time = my_get_run_time ();
4901 TREE_INT_CST_LOW (TIME_IDENTIFIER_TIME (this_filename_time))
4902 += this_time - body_time;
4904 fprintf (stderr, "\n******\n");
4905 print_time ("header files (total)", header_time);
4906 print_time ("main file (total)", this_time - body_time);
4907 fprintf (stderr, "ratio = %g : 1\n",
4908 (double)header_time / (double)(this_time - body_time));
4909 fprintf (stderr, "\n******\n");
4911 for (decl = filename_times; decl; decl = next)
4913 next = IDENTIFIER_GLOBAL_VALUE (decl);
4914 SET_IDENTIFIER_GLOBAL_VALUE (decl, prev);
4918 for (decl = prev; decl; decl = IDENTIFIER_GLOBAL_VALUE (decl))
4919 print_time (IDENTIFIER_POINTER (decl),
4920 TREE_INT_CST_LOW (TIME_IDENTIFIER_TIME (decl)));
4924 compiler_error VPROTO ((const char *msg, ...))
4926 #ifndef ANSI_PROTOTYPES
4934 #ifndef ANSI_PROTOTYPES
4935 msg = va_arg (ap, const char *);
4938 vsprintf (buf, msg, ap);
4939 error_with_file_and_line (input_filename, lineno, "%s (compiler error)", buf);
4942 /* Return the type-qualifier corresponding to the identifier given by
4946 cp_type_qual_from_rid (rid)
4949 if (rid == ridpointers[(int) RID_CONST])
4950 return TYPE_QUAL_CONST;
4951 else if (rid == ridpointers[(int) RID_VOLATILE])
4952 return TYPE_QUAL_VOLATILE;
4953 else if (rid == ridpointers[(int) RID_RESTRICT])
4954 return TYPE_QUAL_RESTRICT;
4956 my_friendly_abort (0);
4957 return TYPE_UNQUALIFIED;