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_expand ();
529 bcopy (cplus_tree_code_type,
530 tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
531 (int)LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE);
532 bcopy ((char *)cplus_tree_code_length,
533 (char *)(tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE),
534 (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
535 bcopy ((char *)cplus_tree_code_name,
536 (char *)(tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
537 (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
539 opname_tab = (const char **)oballoc ((int)LAST_CPLUS_TREE_CODE * sizeof (char *));
540 bzero ((char *)opname_tab, (int)LAST_CPLUS_TREE_CODE * sizeof (char *));
541 assignop_tab = (const char **)oballoc ((int)LAST_CPLUS_TREE_CODE * sizeof (char *));
542 bzero ((char *)assignop_tab, (int)LAST_CPLUS_TREE_CODE * sizeof (char *));
544 ansi_opname[0] = get_identifier ("<invalid operator>");
545 for (i = 0; i < (int) LAST_CPLUS_TREE_CODE; i++)
547 ansi_opname[i] = ansi_opname[0];
548 ansi_assopname[i] = ansi_opname[0];
551 ansi_opname[(int) MULT_EXPR] = get_identifier ("__ml");
552 IDENTIFIER_OPNAME_P (ansi_opname[(int) MULT_EXPR]) = 1;
553 ansi_opname[(int) INDIRECT_REF] = ansi_opname[(int) MULT_EXPR];
554 ansi_assopname[(int) MULT_EXPR] = get_identifier ("__aml");
555 IDENTIFIER_OPNAME_P (ansi_assopname[(int) MULT_EXPR]) = 1;
556 ansi_assopname[(int) INDIRECT_REF] = ansi_assopname[(int) MULT_EXPR];
557 ansi_opname[(int) TRUNC_MOD_EXPR] = get_identifier ("__md");
558 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUNC_MOD_EXPR]) = 1;
559 ansi_assopname[(int) TRUNC_MOD_EXPR] = get_identifier ("__amd");
560 IDENTIFIER_OPNAME_P (ansi_assopname[(int) TRUNC_MOD_EXPR]) = 1;
561 ansi_opname[(int) CEIL_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
562 ansi_opname[(int) FLOOR_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
563 ansi_opname[(int) ROUND_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
564 ansi_opname[(int) MINUS_EXPR] = get_identifier ("__mi");
565 IDENTIFIER_OPNAME_P (ansi_opname[(int) MINUS_EXPR]) = 1;
566 ansi_opname[(int) NEGATE_EXPR] = ansi_opname[(int) MINUS_EXPR];
567 ansi_assopname[(int) MINUS_EXPR] = get_identifier ("__ami");
568 IDENTIFIER_OPNAME_P (ansi_assopname[(int) MINUS_EXPR]) = 1;
569 ansi_assopname[(int) NEGATE_EXPR] = ansi_assopname[(int) MINUS_EXPR];
570 ansi_opname[(int) RSHIFT_EXPR] = get_identifier ("__rs");
571 IDENTIFIER_OPNAME_P (ansi_opname[(int) RSHIFT_EXPR]) = 1;
572 ansi_assopname[(int) RSHIFT_EXPR] = get_identifier ("__ars");
573 IDENTIFIER_OPNAME_P (ansi_assopname[(int) RSHIFT_EXPR]) = 1;
574 ansi_opname[(int) NE_EXPR] = get_identifier ("__ne");
575 IDENTIFIER_OPNAME_P (ansi_opname[(int) NE_EXPR]) = 1;
576 ansi_opname[(int) GT_EXPR] = get_identifier ("__gt");
577 IDENTIFIER_OPNAME_P (ansi_opname[(int) GT_EXPR]) = 1;
578 ansi_opname[(int) GE_EXPR] = get_identifier ("__ge");
579 IDENTIFIER_OPNAME_P (ansi_opname[(int) GE_EXPR]) = 1;
580 ansi_opname[(int) BIT_IOR_EXPR] = get_identifier ("__or");
581 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_IOR_EXPR]) = 1;
582 ansi_assopname[(int) BIT_IOR_EXPR] = get_identifier ("__aor");
583 IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_IOR_EXPR]) = 1;
584 ansi_opname[(int) TRUTH_ANDIF_EXPR] = get_identifier ("__aa");
585 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_ANDIF_EXPR]) = 1;
586 ansi_opname[(int) TRUTH_NOT_EXPR] = get_identifier ("__nt");
587 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_NOT_EXPR]) = 1;
588 ansi_opname[(int) PREINCREMENT_EXPR] = get_identifier ("__pp");
589 IDENTIFIER_OPNAME_P (ansi_opname[(int) PREINCREMENT_EXPR]) = 1;
590 ansi_opname[(int) POSTINCREMENT_EXPR] = ansi_opname[(int) PREINCREMENT_EXPR];
591 ansi_opname[(int) MODIFY_EXPR] = get_identifier ("__as");
592 IDENTIFIER_OPNAME_P (ansi_opname[(int) MODIFY_EXPR]) = 1;
593 ansi_assopname[(int) NOP_EXPR] = ansi_opname[(int) MODIFY_EXPR];
594 ansi_opname[(int) COMPOUND_EXPR] = get_identifier ("__cm");
595 IDENTIFIER_OPNAME_P (ansi_opname[(int) COMPOUND_EXPR]) = 1;
596 ansi_opname[(int) EXACT_DIV_EXPR] = get_identifier ("__dv");
597 IDENTIFIER_OPNAME_P (ansi_opname[(int) EXACT_DIV_EXPR]) = 1;
598 ansi_assopname[(int) EXACT_DIV_EXPR] = get_identifier ("__adv");
599 IDENTIFIER_OPNAME_P (ansi_assopname[(int) EXACT_DIV_EXPR]) = 1;
600 ansi_opname[(int) TRUNC_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
601 ansi_opname[(int) CEIL_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
602 ansi_opname[(int) FLOOR_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
603 ansi_opname[(int) ROUND_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
604 ansi_opname[(int) PLUS_EXPR] = get_identifier ("__pl");
605 ansi_assopname[(int) TRUNC_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
606 ansi_assopname[(int) CEIL_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
607 ansi_assopname[(int) FLOOR_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
608 ansi_assopname[(int) ROUND_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
609 IDENTIFIER_OPNAME_P (ansi_opname[(int) PLUS_EXPR]) = 1;
610 ansi_assopname[(int) PLUS_EXPR] = get_identifier ("__apl");
611 IDENTIFIER_OPNAME_P (ansi_assopname[(int) PLUS_EXPR]) = 1;
612 ansi_opname[(int) CONVERT_EXPR] = ansi_opname[(int) PLUS_EXPR];
613 ansi_assopname[(int) CONVERT_EXPR] = ansi_assopname[(int) PLUS_EXPR];
614 ansi_opname[(int) LSHIFT_EXPR] = get_identifier ("__ls");
615 IDENTIFIER_OPNAME_P (ansi_opname[(int) LSHIFT_EXPR]) = 1;
616 ansi_assopname[(int) LSHIFT_EXPR] = get_identifier ("__als");
617 IDENTIFIER_OPNAME_P (ansi_assopname[(int) LSHIFT_EXPR]) = 1;
618 ansi_opname[(int) EQ_EXPR] = get_identifier ("__eq");
619 IDENTIFIER_OPNAME_P (ansi_opname[(int) EQ_EXPR]) = 1;
620 ansi_opname[(int) LT_EXPR] = get_identifier ("__lt");
621 IDENTIFIER_OPNAME_P (ansi_opname[(int) LT_EXPR]) = 1;
622 ansi_opname[(int) LE_EXPR] = get_identifier ("__le");
623 IDENTIFIER_OPNAME_P (ansi_opname[(int) LE_EXPR]) = 1;
624 ansi_opname[(int) BIT_AND_EXPR] = get_identifier ("__ad");
625 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_AND_EXPR]) = 1;
626 ansi_assopname[(int) BIT_AND_EXPR] = get_identifier ("__aad");
627 IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_AND_EXPR]) = 1;
628 ansi_opname[(int) ADDR_EXPR] = ansi_opname[(int) BIT_AND_EXPR];
629 ansi_assopname[(int) ADDR_EXPR] = ansi_assopname[(int) BIT_AND_EXPR];
630 ansi_opname[(int) BIT_XOR_EXPR] = get_identifier ("__er");
631 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_XOR_EXPR]) = 1;
632 ansi_assopname[(int) BIT_XOR_EXPR] = get_identifier ("__aer");
633 IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_XOR_EXPR]) = 1;
634 ansi_opname[(int) TRUTH_ORIF_EXPR] = get_identifier ("__oo");
635 IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_ORIF_EXPR]) = 1;
636 ansi_opname[(int) BIT_NOT_EXPR] = get_identifier ("__co");
637 IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_NOT_EXPR]) = 1;
638 ansi_opname[(int) PREDECREMENT_EXPR] = get_identifier ("__mm");
639 IDENTIFIER_OPNAME_P (ansi_opname[(int) PREDECREMENT_EXPR]) = 1;
640 ansi_opname[(int) POSTDECREMENT_EXPR] = ansi_opname[(int) PREDECREMENT_EXPR];
641 ansi_opname[(int) COMPONENT_REF] = get_identifier ("__rf");
642 IDENTIFIER_OPNAME_P (ansi_opname[(int) COMPONENT_REF]) = 1;
643 ansi_opname[(int) MEMBER_REF] = get_identifier ("__rm");
644 IDENTIFIER_OPNAME_P (ansi_opname[(int) MEMBER_REF]) = 1;
645 ansi_opname[(int) CALL_EXPR] = get_identifier ("__cl");
646 IDENTIFIER_OPNAME_P (ansi_opname[(int) CALL_EXPR]) = 1;
647 ansi_opname[(int) ARRAY_REF] = get_identifier ("__vc");
648 IDENTIFIER_OPNAME_P (ansi_opname[(int) ARRAY_REF]) = 1;
649 ansi_opname[(int) NEW_EXPR] = get_identifier ("__nw");
650 IDENTIFIER_OPNAME_P (ansi_opname[(int) NEW_EXPR]) = 1;
651 ansi_opname[(int) DELETE_EXPR] = get_identifier ("__dl");
652 IDENTIFIER_OPNAME_P (ansi_opname[(int) DELETE_EXPR]) = 1;
653 ansi_opname[(int) VEC_NEW_EXPR] = get_identifier ("__vn");
654 IDENTIFIER_OPNAME_P (ansi_opname[(int) VEC_NEW_EXPR]) = 1;
655 ansi_opname[(int) VEC_DELETE_EXPR] = get_identifier ("__vd");
656 IDENTIFIER_OPNAME_P (ansi_opname[(int) VEC_DELETE_EXPR]) = 1;
657 ansi_opname[(int) TYPE_EXPR] = get_identifier (OPERATOR_TYPENAME_FORMAT);
658 IDENTIFIER_OPNAME_P (ansi_opname[(int) TYPE_EXPR]) = 1;
660 /* This is not true: these operators are not defined in ANSI,
661 but we need them anyway. */
662 ansi_opname[(int) MIN_EXPR] = get_identifier ("__mn");
663 IDENTIFIER_OPNAME_P (ansi_opname[(int) MIN_EXPR]) = 1;
664 ansi_opname[(int) MAX_EXPR] = get_identifier ("__mx");
665 IDENTIFIER_OPNAME_P (ansi_opname[(int) MAX_EXPR]) = 1;
666 ansi_opname[(int) COND_EXPR] = get_identifier ("__cn");
667 IDENTIFIER_OPNAME_P (ansi_opname[(int) COND_EXPR]) = 1;
668 ansi_opname[(int) SIZEOF_EXPR] = get_identifier ("__sz");
669 IDENTIFIER_OPNAME_P (ansi_opname[(int) SIZEOF_EXPR]) = 1;
673 gcc_obstack_init (&inline_text_obstack);
674 inline_text_firstobj = (char *) obstack_alloc (&inline_text_obstack, 0);
676 /* Start it at 0, because check_newline is called at the very beginning
677 and will increment it to 1. */
679 input_filename = "<internal>";
680 current_function_decl = NULL;
683 token_buffer = (char *) xmalloc (maxtoken + 2);
685 ridpointers[(int) RID_INT] = get_identifier ("int");
686 ridpointers[(int) RID_BOOL] = get_identifier ("bool");
687 ridpointers[(int) RID_CHAR] = get_identifier ("char");
688 ridpointers[(int) RID_VOID] = get_identifier ("void");
689 ridpointers[(int) RID_FLOAT] = get_identifier ("float");
690 ridpointers[(int) RID_DOUBLE] = get_identifier ("double");
691 ridpointers[(int) RID_SHORT] = get_identifier ("short");
692 ridpointers[(int) RID_LONG] = get_identifier ("long");
693 ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned");
694 ridpointers[(int) RID_SIGNED] = get_identifier ("signed");
695 ridpointers[(int) RID_INLINE] = get_identifier ("inline");
696 ridpointers[(int) RID_CONST] = get_identifier ("const");
697 ridpointers[(int) RID_RESTRICT] = get_identifier ("__restrict");
698 ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
699 ridpointers[(int) RID_AUTO] = get_identifier ("auto");
700 ridpointers[(int) RID_STATIC] = get_identifier ("static");
701 ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
702 ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
703 ridpointers[(int) RID_REGISTER] = get_identifier ("register");
704 ridpointers[(int) RID_COMPLEX] = get_identifier ("__complex");
706 /* C++ extensions. These are probably not correctly named. */
707 ridpointers[(int) RID_WCHAR] = get_identifier ("__wchar_t");
708 class_type_node = build_int_2 (class_type, 0);
709 TREE_TYPE (class_type_node) = class_type_node;
710 ridpointers[(int) RID_CLASS] = class_type_node;
712 record_type_node = build_int_2 (record_type, 0);
713 TREE_TYPE (record_type_node) = record_type_node;
714 ridpointers[(int) RID_RECORD] = record_type_node;
716 union_type_node = build_int_2 (union_type, 0);
717 TREE_TYPE (union_type_node) = union_type_node;
718 ridpointers[(int) RID_UNION] = union_type_node;
720 enum_type_node = build_int_2 (enum_type, 0);
721 TREE_TYPE (enum_type_node) = enum_type_node;
722 ridpointers[(int) RID_ENUM] = enum_type_node;
724 ridpointers[(int) RID_VIRTUAL] = get_identifier ("virtual");
725 ridpointers[(int) RID_EXPLICIT] = get_identifier ("explicit");
726 ridpointers[(int) RID_EXPORT] = get_identifier ("export");
727 ridpointers[(int) RID_FRIEND] = get_identifier ("friend");
729 ridpointers[(int) RID_PUBLIC] = get_identifier ("public");
730 ridpointers[(int) RID_PRIVATE] = get_identifier ("private");
731 ridpointers[(int) RID_PROTECTED] = get_identifier ("protected");
732 ridpointers[(int) RID_TEMPLATE] = get_identifier ("template");
733 /* This is for ANSI C++. */
734 ridpointers[(int) RID_MUTABLE] = get_identifier ("mutable");
736 /* Signature handling extensions. */
737 signature_type_node = build_int_2 (signature_type, 0);
738 TREE_TYPE (signature_type_node) = signature_type_node;
739 ridpointers[(int) RID_SIGNATURE] = signature_type_node;
741 /* Create the built-in __null node. Note that we can't yet call for
742 type_for_size here because integer_type_node and so forth are not
743 set up. Therefore, we don't set the type of these nodes until
744 init_decl_processing. */
745 null_node = build_int_2 (0, 0);
746 ridpointers[RID_NULL] = null_node;
748 opname_tab[(int) COMPONENT_REF] = "->";
749 opname_tab[(int) MEMBER_REF] = "->*";
750 opname_tab[(int) INDIRECT_REF] = "*";
751 opname_tab[(int) ARRAY_REF] = "[]";
752 opname_tab[(int) MODIFY_EXPR] = "=";
753 opname_tab[(int) NEW_EXPR] = "new";
754 opname_tab[(int) DELETE_EXPR] = "delete";
755 opname_tab[(int) VEC_NEW_EXPR] = "new []";
756 opname_tab[(int) VEC_DELETE_EXPR] = "delete []";
757 opname_tab[(int) COND_EXPR] = "?:";
758 opname_tab[(int) CALL_EXPR] = "()";
759 opname_tab[(int) PLUS_EXPR] = "+";
760 opname_tab[(int) MINUS_EXPR] = "-";
761 opname_tab[(int) MULT_EXPR] = "*";
762 opname_tab[(int) TRUNC_DIV_EXPR] = "/";
763 opname_tab[(int) CEIL_DIV_EXPR] = "(ceiling /)";
764 opname_tab[(int) FLOOR_DIV_EXPR] = "(floor /)";
765 opname_tab[(int) ROUND_DIV_EXPR] = "(round /)";
766 opname_tab[(int) TRUNC_MOD_EXPR] = "%";
767 opname_tab[(int) CEIL_MOD_EXPR] = "(ceiling %)";
768 opname_tab[(int) FLOOR_MOD_EXPR] = "(floor %)";
769 opname_tab[(int) ROUND_MOD_EXPR] = "(round %)";
770 opname_tab[(int) EXACT_DIV_EXPR] = "/";
771 opname_tab[(int) NEGATE_EXPR] = "-";
772 opname_tab[(int) MIN_EXPR] = "<?";
773 opname_tab[(int) MAX_EXPR] = ">?";
774 opname_tab[(int) ABS_EXPR] = "abs";
775 opname_tab[(int) FFS_EXPR] = "ffs";
776 opname_tab[(int) LSHIFT_EXPR] = "<<";
777 opname_tab[(int) RSHIFT_EXPR] = ">>";
778 opname_tab[(int) BIT_IOR_EXPR] = "|";
779 opname_tab[(int) BIT_XOR_EXPR] = "^";
780 opname_tab[(int) BIT_AND_EXPR] = "&";
781 opname_tab[(int) BIT_ANDTC_EXPR] = "&~";
782 opname_tab[(int) BIT_NOT_EXPR] = "~";
783 opname_tab[(int) TRUTH_ANDIF_EXPR] = "&&";
784 opname_tab[(int) TRUTH_ORIF_EXPR] = "||";
785 opname_tab[(int) TRUTH_AND_EXPR] = "strict &&";
786 opname_tab[(int) TRUTH_OR_EXPR] = "strict ||";
787 opname_tab[(int) TRUTH_NOT_EXPR] = "!";
788 opname_tab[(int) LT_EXPR] = "<";
789 opname_tab[(int) LE_EXPR] = "<=";
790 opname_tab[(int) GT_EXPR] = ">";
791 opname_tab[(int) GE_EXPR] = ">=";
792 opname_tab[(int) EQ_EXPR] = "==";
793 opname_tab[(int) NE_EXPR] = "!=";
794 opname_tab[(int) IN_EXPR] = "in";
795 opname_tab[(int) RANGE_EXPR] = "...";
796 opname_tab[(int) CONVERT_EXPR] = "+";
797 opname_tab[(int) ADDR_EXPR] = "&";
798 opname_tab[(int) PREDECREMENT_EXPR] = "--";
799 opname_tab[(int) PREINCREMENT_EXPR] = "++";
800 opname_tab[(int) POSTDECREMENT_EXPR] = "--";
801 opname_tab[(int) POSTINCREMENT_EXPR] = "++";
802 opname_tab[(int) COMPOUND_EXPR] = ",";
804 assignop_tab[(int) NOP_EXPR] = "=";
805 assignop_tab[(int) PLUS_EXPR] = "+=";
806 assignop_tab[(int) CONVERT_EXPR] = "+=";
807 assignop_tab[(int) MINUS_EXPR] = "-=";
808 assignop_tab[(int) NEGATE_EXPR] = "-=";
809 assignop_tab[(int) MULT_EXPR] = "*=";
810 assignop_tab[(int) INDIRECT_REF] = "*=";
811 assignop_tab[(int) TRUNC_DIV_EXPR] = "/=";
812 assignop_tab[(int) EXACT_DIV_EXPR] = "(exact /=)";
813 assignop_tab[(int) CEIL_DIV_EXPR] = "(ceiling /=)";
814 assignop_tab[(int) FLOOR_DIV_EXPR] = "(floor /=)";
815 assignop_tab[(int) ROUND_DIV_EXPR] = "(round /=)";
816 assignop_tab[(int) TRUNC_MOD_EXPR] = "%=";
817 assignop_tab[(int) CEIL_MOD_EXPR] = "(ceiling %=)";
818 assignop_tab[(int) FLOOR_MOD_EXPR] = "(floor %=)";
819 assignop_tab[(int) ROUND_MOD_EXPR] = "(round %=)";
820 assignop_tab[(int) MIN_EXPR] = "<?=";
821 assignop_tab[(int) MAX_EXPR] = ">?=";
822 assignop_tab[(int) LSHIFT_EXPR] = "<<=";
823 assignop_tab[(int) RSHIFT_EXPR] = ">>=";
824 assignop_tab[(int) BIT_IOR_EXPR] = "|=";
825 assignop_tab[(int) BIT_XOR_EXPR] = "^=";
826 assignop_tab[(int) BIT_AND_EXPR] = "&=";
827 assignop_tab[(int) ADDR_EXPR] = "&=";
829 init_filename_times ();
831 /* Some options inhibit certain reserved words.
832 Clear those words out of the hash table so they won't be recognized. */
833 #define UNSET_RESERVED_WORD(STRING) \
834 do { struct resword *s = is_reserved_word (STRING, sizeof (STRING) - 1); \
835 if (s) s->name = ""; } while (0)
838 /* let's parse things, and if they use it, then give them an error. */
839 if (!flag_exceptions)
841 UNSET_RESERVED_WORD ("throw");
842 UNSET_RESERVED_WORD ("try");
843 UNSET_RESERVED_WORD ("catch");
847 if (!flag_rtti || flag_no_gnu_keywords)
849 UNSET_RESERVED_WORD ("classof");
850 UNSET_RESERVED_WORD ("headof");
853 if (! flag_handle_signatures || flag_no_gnu_keywords)
855 /* Easiest way to not recognize signature
856 handling extensions... */
857 UNSET_RESERVED_WORD ("signature");
858 UNSET_RESERVED_WORD ("sigof");
860 if (flag_no_asm || flag_no_gnu_keywords)
861 UNSET_RESERVED_WORD ("typeof");
862 if (! flag_operator_names)
864 /* These are new ANSI keywords that may break code. */
865 UNSET_RESERVED_WORD ("and");
866 UNSET_RESERVED_WORD ("and_eq");
867 UNSET_RESERVED_WORD ("bitand");
868 UNSET_RESERVED_WORD ("bitor");
869 UNSET_RESERVED_WORD ("compl");
870 UNSET_RESERVED_WORD ("not");
871 UNSET_RESERVED_WORD ("not_eq");
872 UNSET_RESERVED_WORD ("or");
873 UNSET_RESERVED_WORD ("or_eq");
874 UNSET_RESERVED_WORD ("xor");
875 UNSET_RESERVED_WORD ("xor_eq");
878 token_count = init_cpp_parse ();
879 interface_unknown = 1;
888 cpp_finish (&parse_in);
889 errorcount += parse_in.errors;
896 reinit_parse_for_function ()
898 current_base_init_list = NULL_TREE;
899 current_member_init_list = NULL_TREE;
906 yyprint (file, yychar, yylval)
919 case IDENTIFIER_DEFN:
923 case PRE_PARSED_CLASS_DECL:
925 if (TREE_CODE (t) == TYPE_DECL || TREE_CODE (t) == TEMPLATE_DECL)
927 fprintf (file, " `%s'", IDENTIFIER_POINTER (DECL_NAME (t)));
930 my_friendly_assert (TREE_CODE (t) == IDENTIFIER_NODE, 224);
931 if (IDENTIFIER_POINTER (t))
932 fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
936 if (yylval.ttype == class_type_node)
937 fprintf (file, " `class'");
938 else if (yylval.ttype == record_type_node)
939 fprintf (file, " `struct'");
940 else if (yylval.ttype == union_type_node)
941 fprintf (file, " `union'");
942 else if (yylval.ttype == enum_type_node)
943 fprintf (file, " `enum'");
944 else if (yylval.ttype == signature_type_node)
945 fprintf (file, " `signature'");
947 my_friendly_abort (80);
952 if (TREE_CODE (t) == INTEGER_CST)
954 #if HOST_BITS_PER_WIDE_INT == 64
955 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
958 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
965 #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
971 TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t));
976 #if defined(GATHER_STATISTICS) && defined(REDUCE_LENGTH)
977 static int *reduce_count;
983 #define REDUCE_LENGTH (sizeof (yyr2) / sizeof (yyr2[0]))
984 #define TOKEN_LENGTH (256 + sizeof (yytname) / sizeof (yytname[0]))
987 #ifdef GATHER_STATISTICS
993 reduce_count[yyn] += 1;
1000 return reduce_count[*q] - reduce_count[*p];
1007 return token_count[*q] - token_count[*p];
1013 print_parse_statistics ()
1015 #ifdef GATHER_STATISTICS
1016 #ifdef REDUCE_LENGTH
1019 int maxlen = REDUCE_LENGTH;
1022 if (reduce_count[-1] == 0)
1025 if (TOKEN_LENGTH > REDUCE_LENGTH)
1026 maxlen = TOKEN_LENGTH;
1027 sorted = (unsigned *) alloca (sizeof (int) * maxlen);
1029 for (i = 0; i < TOKEN_LENGTH; i++)
1031 qsort (sorted, TOKEN_LENGTH, sizeof (int), token_cmp);
1032 for (i = 0; i < TOKEN_LENGTH; i++)
1034 int idx = sorted[i];
1035 if (token_count[idx] == 0)
1037 if (token_count[idx] < token_count[-1])
1039 fprintf (stderr, "token %d, `%s', count = %d\n",
1040 idx, yytname[YYTRANSLATE (idx)], token_count[idx]);
1042 fprintf (stderr, "\n");
1043 for (i = 0; i < REDUCE_LENGTH; i++)
1045 qsort (sorted, REDUCE_LENGTH, sizeof (int), reduce_cmp);
1046 for (i = 0; i < REDUCE_LENGTH; i++)
1048 int idx = sorted[i];
1049 if (reduce_count[idx] == 0)
1051 if (reduce_count[idx] < reduce_count[-1])
1053 fprintf (stderr, "rule %d, line %d, count = %d\n",
1054 idx, yyrline[idx], reduce_count[idx]);
1056 fprintf (stderr, "\n");
1062 /* Sets the value of the 'yydebug' variable to VALUE.
1063 This is a function so we don't have to have YYDEBUG defined
1064 in order to build the compiler. */
1074 warning ("YYDEBUG not defined.");
1079 /* Functions and data structures for #pragma interface.
1081 `#pragma implementation' means that the main file being compiled
1082 is considered to implement (provide) the classes that appear in
1083 its main body. I.e., if this is file "foo.cc", and class `bar'
1084 is defined in "foo.cc", then we say that "foo.cc implements bar".
1086 All main input files "implement" themselves automagically.
1088 `#pragma interface' means that unless this file (of the form "foo.h"
1089 is not presently being included by file "foo.cc", the
1090 CLASSTYPE_INTERFACE_ONLY bit gets set. The effect is that none
1091 of the vtables nor any of the inline functions defined in foo.h
1092 will ever be output.
1094 There are cases when we want to link files such as "defs.h" and
1095 "main.cc". In this case, we give "defs.h" a `#pragma interface',
1096 and "main.cc" has `#pragma implementation "defs.h"'. */
1101 struct impl_files *next;
1104 static struct impl_files *impl_file_chain;
1106 /* Helper function to load global variables with interface
1110 extract_interface_info ()
1114 if (flag_alt_external_templates)
1116 struct tinst_level *til = tinst_for_decl ();
1119 fileinfo = get_time_identifier (til->file);
1122 fileinfo = get_time_identifier (input_filename);
1123 fileinfo = TIME_IDENTIFIER_FILEINFO (fileinfo);
1124 interface_only = TREE_INT_CST_LOW (fileinfo);
1125 interface_unknown = TREE_INT_CST_HIGH (fileinfo);
1128 /* Return nonzero if S is not considered part of an
1129 INTERFACE/IMPLEMENTATION pair. Otherwise, return 0. */
1132 interface_strcmp (s)
1135 /* Set the interface/implementation bits for this scope. */
1136 struct impl_files *ifiles;
1139 for (ifiles = impl_file_chain; ifiles; ifiles = ifiles->next)
1141 const char *t1 = ifiles->filename;
1144 if (*s1 != *t1 || *s1 == 0)
1147 while (*s1 == *t1 && *s1 != 0)
1154 /* Don't get faked out by xxx.yyy.cc vs xxx.zzz.cc. */
1155 if (index (s1, '.') || index (t1, '.'))
1158 if (*s1 == '\0' || s1[-1] != '.' || t1[-1] != '.')
1170 cp_pragma_interface (main_filename)
1171 char *main_filename;
1174 = TIME_IDENTIFIER_FILEINFO (get_time_identifier (input_filename));
1176 if (impl_file_chain == 0)
1178 /* If this is zero at this point, then we are
1179 auto-implementing. */
1180 if (main_input_filename == 0)
1181 main_input_filename = input_filename;
1183 #ifdef AUTO_IMPLEMENT
1184 filename = file_name_nondirectory (main_input_filename);
1185 fi = get_time_identifier (filename);
1186 fi = TIME_IDENTIFIER_FILEINFO (fi);
1187 TREE_INT_CST_LOW (fi) = 0;
1188 TREE_INT_CST_HIGH (fi) = 1;
1190 impl_file_chain = (struct impl_files *)permalloc (sizeof (struct impl_files));
1191 impl_file_chain->filename = filename;
1192 impl_file_chain->next = 0;
1196 interface_only = interface_strcmp (main_filename);
1197 #ifdef MULTIPLE_SYMBOL_SPACES
1198 if (! interface_only)
1199 interface_unknown = 0;
1200 #else /* MULTIPLE_SYMBOL_SPACES */
1201 interface_unknown = 0;
1202 #endif /* MULTIPLE_SYMBOL_SPACES */
1203 TREE_INT_CST_LOW (fileinfo) = interface_only;
1204 TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
1208 cp_pragma_implementation (main_filename)
1209 char *main_filename;
1212 = TIME_IDENTIFIER_FILEINFO (get_time_identifier (input_filename));
1214 if (impl_file_chain)
1216 struct impl_files *ifiles = impl_file_chain;
1219 if (! strcmp (ifiles->filename, main_filename))
1221 ifiles = ifiles->next;
1225 ifiles = (struct impl_files*) permalloc (sizeof (struct impl_files));
1226 ifiles->filename = main_filename;
1227 ifiles->next = impl_file_chain;
1228 impl_file_chain = ifiles;
1231 else if ((main_input_filename != 0
1232 && ! strcmp (main_input_filename, input_filename))
1233 || ! strcmp (main_filename, input_filename))
1235 impl_file_chain = (struct impl_files*) permalloc (sizeof (struct impl_files));
1236 impl_file_chain->filename = main_filename;
1237 impl_file_chain->next = 0;
1240 error ("`#pragma implementation' can only appear at top-level");
1243 /* We make this non-zero so that we infer decl linkage
1244 in the impl file only for variables first declared
1245 in the interface file. */
1246 interface_unknown = 1;
1248 /* We make this zero so that templates in the impl
1249 file will be emitted properly. */
1250 interface_unknown = 0;
1252 TREE_INT_CST_LOW (fileinfo) = interface_only;
1253 TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
1256 /* Set up the state required to correctly handle the definition of the
1257 inline function whose preparsed state has been saved in PI. */
1260 begin_definition_of_inclass_inline (pi)
1261 struct pending_inline* pi;
1268 /* If this is an inline function in a local class, we must make sure
1269 that we save all pertinent information about the function
1270 surrounding the local class. */
1271 context = hack_decl_function_context (pi->fndecl);
1273 push_cp_function_context (context);
1275 feed_input (pi->buf, pi->len, pi->filename, pi->lineno);
1276 yychar = PRE_PARSED_FUNCTION_DECL;
1277 yylval.ttype = build_tree_list ((tree) pi, pi->fndecl);
1278 /* Pass back a handle to the rest of the inline functions, so that they
1279 can be processed later. */
1280 DECL_PENDING_INLINE_INFO (pi->fndecl) = 0;
1281 interface_unknown = pi->interface == 1;
1282 interface_only = pi->interface == 0;
1285 /* Called from the top level: if there are any pending inlines to
1286 do, set up to process them now. This function sets up the first function
1287 to be parsed; after it has been, the rule for fndef in parse.y will
1288 call process_next_inline to start working on the next one. */
1291 do_pending_inlines ()
1293 struct pending_inline *t;
1295 /* Oops, we're still dealing with the last batch. */
1296 if (yychar == PRE_PARSED_FUNCTION_DECL)
1299 /* Reverse the pending inline functions, since
1300 they were cons'd instead of appended. */
1302 struct pending_inline *prev = 0, *tail;
1303 t = pending_inlines;
1304 pending_inlines = 0;
1319 /* Now start processing the first inline function. */
1320 begin_definition_of_inclass_inline (t);
1323 /* Called from the fndecl rule in the parser when the function just parsed
1324 was declared using a PRE_PARSED_FUNCTION_DECL (i.e. came from
1325 do_pending_inlines). */
1328 process_next_inline (t)
1332 struct pending_inline *i = (struct pending_inline *) TREE_PURPOSE (t);
1333 context = hack_decl_function_context (i->fndecl);
1335 pop_cp_function_context (context);
1337 if (yychar == YYEMPTY)
1339 if (yychar != END_OF_SAVED_INPUT)
1341 error ("parse error at end of saved function text");
1343 /* restore_pending_input will abort unless yychar is either
1344 END_OF_SAVED_INPUT or YYEMPTY; since we already know we're
1345 hosed, feed back YYEMPTY. */
1350 begin_definition_of_inclass_inline (i);
1352 extract_interface_info ();
1355 /* Since inline methods can refer to text which has not yet been seen,
1356 we store the text of the method in a structure which is placed in the
1357 DECL_PENDING_INLINE_INFO field of the FUNCTION_DECL.
1358 After parsing the body of the class definition, the FUNCTION_DECL's are
1359 scanned to see which ones have this field set. Those are then digested
1362 This function's FUNCTION_DECL will have a bit set in its common so
1363 that we know to watch out for it. */
1366 consume_string (this_obstack, matching_char)
1367 register struct obstack *this_obstack;
1371 int starting_lineno;
1374 if (cpp_token == CPP_STRING)
1376 /* The C preprocessor will warn about newlines in strings. */
1377 obstack_grow (this_obstack, yy_cur, (yy_lim - yy_cur));
1379 lineno = parse_in.lineno;
1384 starting_lineno = lineno;
1390 int save_lineno = lineno;
1391 lineno = starting_lineno;
1392 if (matching_char == '"')
1393 error ("end of file encountered inside string constant");
1395 error ("end of file encountered inside character constant");
1396 lineno = save_lineno;
1401 obstack_1grow (this_obstack, c);
1403 obstack_1grow (this_obstack, c);
1405 /* Make sure we continue the loop */
1412 pedwarn ("ANSI C++ forbids newline in string constant");
1415 obstack_1grow (this_obstack, c);
1417 while (c != matching_char);
1420 struct pending_input {
1423 struct obstack token_obstack;
1427 struct pending_input *
1428 save_pending_input ()
1430 struct pending_input *p;
1431 p = (struct pending_input *) xmalloc (sizeof (struct pending_input));
1434 p->eof = end_of_file;
1436 p->first_token = first_token;
1437 p->token_obstack = token_obstack;
1440 gcc_obstack_init (&token_obstack);
1446 restore_pending_input (p)
1447 struct pending_input *p;
1449 my_friendly_assert (yychar == YYEMPTY || yychar == END_OF_SAVED_INPUT, 230);
1452 first_token = p->first_token;
1453 obstack_free (&token_obstack, (char *) 0);
1454 token_obstack = p->token_obstack;
1455 end_of_file = p->eof;
1459 /* Unget character CH from the input stream.
1460 If RESCAN is non-zero, then we want to `see' this
1461 character as the next input token. */
1464 yyungetc (ch, rescan)
1468 /* Unget a character from the input stream. */
1469 if (yychar == YYEMPTY || rescan == 0)
1471 /* If we're putting back a brace, undo the change in indent_level
1472 from the first time we saw it. */
1487 clear_inline_text_obstack ()
1489 obstack_free (&inline_text_obstack, inline_text_firstobj);
1492 /* This function stores away the text for an inline function that should
1493 be processed later. It decides how much later, and may need to move
1494 the info between obstacks; therefore, the caller should not refer to
1495 the T parameter after calling this function. */
1498 store_pending_inline (decl, t)
1500 struct pending_inline *t;
1503 DECL_PENDING_INLINE_INFO (decl) = t;
1505 /* Because we use obstacks, we must process these in precise order. */
1506 t->next = pending_inlines;
1507 pending_inlines = t;
1511 reinit_parse_for_method (yychar, decl)
1516 int starting_lineno = lineno;
1517 char *starting_filename = input_filename;
1519 reinit_parse_for_block (yychar, &inline_text_obstack);
1521 len = obstack_object_size (&inline_text_obstack);
1522 current_base_init_list = NULL_TREE;
1523 current_member_init_list = NULL_TREE;
1524 if (decl == void_type_node
1525 || (current_class_type && TYPE_REDEFINED (current_class_type)))
1527 /* Happens when we get two declarations of the same
1528 function in the same scope. */
1529 char *buf = obstack_finish (&inline_text_obstack);
1530 obstack_free (&inline_text_obstack, buf);
1535 struct pending_inline *t;
1536 char *buf = obstack_finish (&inline_text_obstack);
1538 t = (struct pending_inline *) obstack_alloc (&inline_text_obstack,
1539 sizeof (struct pending_inline));
1540 t->lineno = starting_lineno;
1541 t->filename = starting_filename;
1548 if (interface_unknown && processing_template_defn && flag_external_templates && ! DECL_IN_SYSTEM_HEADER (decl))
1549 warn_if_unknown_interface (decl);
1551 t->interface = (interface_unknown ? 1 : (interface_only ? 0 : 2));
1552 store_pending_inline (decl, t);
1556 /* Consume a block -- actually, a method beginning
1557 with `:' or `{' -- and save it away on the specified obstack. */
1560 reinit_parse_for_block (pyychar, obstackp)
1562 struct obstack *obstackp;
1566 int starting_lineno = lineno;
1567 char *starting_filename = input_filename;
1569 int look_for_semicolon = 0;
1570 int look_for_lbrac = 0;
1574 obstack_1grow (obstackp, '{');
1575 /* We incremented indent_level in yylex; undo that. */
1578 else if (pyychar == '=')
1579 look_for_semicolon = 1;
1580 else if (pyychar == ':')
1582 obstack_1grow (obstackp, pyychar);
1583 /* Add a space so we don't get confused by ': ::A(20)'. */
1584 obstack_1grow (obstackp, ' ');
1588 else if (pyychar == RETURN_KEYWORD)
1590 obstack_grow (obstackp, "return", 6);
1594 else if (pyychar == TRY)
1596 obstack_grow (obstackp, "try", 3);
1602 yyerror ("parse error in method specification");
1603 obstack_1grow (obstackp, '{');
1610 int this_lineno = lineno;
1612 c = skip_white_space (c);
1614 /* Don't lose our cool if there are lots of comments. */
1615 if (lineno == this_lineno + 1)
1616 obstack_1grow (obstackp, '\n');
1617 else if (lineno == this_lineno)
1619 else if (lineno - this_lineno < 10)
1622 for (i = lineno - this_lineno; i > 0; i--)
1623 obstack_1grow (obstackp, '\n');
1628 sprintf (buf, "\n# %d \"", lineno);
1630 obstack_grow (obstackp, buf, len);
1632 len = strlen (input_filename);
1633 obstack_grow (obstackp, input_filename, len);
1634 obstack_1grow (obstackp, '\"');
1635 obstack_1grow (obstackp, '\n');
1638 while (c > ' ') /* ASCII dependent... */
1640 obstack_1grow (obstackp, c);
1649 if (blev == 0 && !look_for_semicolon)
1653 if (peekyylex () == CATCH)
1656 obstack_grow (obstackp, " catch ", 7);
1673 /* Don't act on the next character...e.g, doing an escaped
1678 error_with_file_and_line (starting_filename,
1680 "end of file read inside definition");
1683 obstack_1grow (obstackp, c);
1686 consume_string (obstackp, c);
1688 consume_string (obstackp, c);
1693 error ("function body for constructor missing");
1694 obstack_1grow (obstackp, '{');
1695 obstack_1grow (obstackp, '}');
1699 else if (look_for_semicolon && blev == 0)
1707 error_with_file_and_line (starting_filename,
1709 "end of file read inside definition");
1714 obstack_1grow (obstackp, c);
1719 obstack_1grow (obstackp, '\0');
1722 /* Consume a no-commas expression -- actually, a default argument -- and
1723 save it away on the specified obstack. */
1726 reinit_parse_for_expr (obstackp)
1727 struct obstack *obstackp;
1730 int starting_lineno = lineno;
1731 char *starting_filename = input_filename;
1739 int this_lineno = lineno;
1741 c = skip_white_space (c);
1743 /* Don't lose our cool if there are lots of comments. */
1744 if (lineno == this_lineno + 1)
1745 obstack_1grow (obstackp, '\n');
1746 else if (lineno == this_lineno)
1748 else if (lineno - this_lineno < 10)
1751 for (i = lineno - this_lineno; i > 0; --i)
1752 obstack_1grow (obstackp, '\n');
1757 sprintf (buf, "\n# %d \"", lineno);
1759 obstack_grow (obstackp, buf, len);
1761 len = strlen (input_filename);
1762 obstack_grow (obstackp, input_filename, len);
1763 obstack_1grow (obstackp, '\"');
1764 obstack_1grow (obstackp, '\n');
1767 while (c > ' ') /* ASCII dependent... */
1769 if (plev <= 0 && (c == ')' || c == ','))
1774 obstack_1grow (obstackp, c);
1775 if (c == '(' || c == '[')
1777 else if (c == ']' || c == ')')
1781 /* Don't act on the next character...e.g, doing an escaped
1786 error_with_file_and_line (starting_filename,
1788 "end of file read inside definition");
1791 obstack_1grow (obstackp, c);
1794 consume_string (obstackp, c);
1796 consume_string (obstackp, c);
1802 error_with_file_and_line (starting_filename,
1804 "end of file read inside definition");
1809 obstack_1grow (obstackp, c);
1814 obstack_1grow (obstackp, '\0');
1817 int do_snarf_defarg;
1819 /* Decide whether the default argument we are about to see should be
1820 gobbled up as text for later parsing. */
1823 maybe_snarf_defarg ()
1825 if (current_class_type && TYPE_BEING_DEFINED (current_class_type))
1826 do_snarf_defarg = 1;
1829 /* When we see a default argument in a method declaration, we snarf it as
1830 text using snarf_defarg. When we get up to namespace scope, we then go
1831 through and parse all of them using do_pending_defargs. Since yacc
1832 parsers are not reentrant, we retain defargs state in these two
1833 variables so that subsequent calls to do_pending_defargs can resume
1834 where the previous call left off. */
1846 reinit_parse_for_expr (&inline_text_obstack);
1847 len = obstack_object_size (&inline_text_obstack);
1848 buf = obstack_finish (&inline_text_obstack);
1850 push_obstacks (&inline_text_obstack, &inline_text_obstack);
1851 arg = make_node (DEFAULT_ARG);
1852 DEFARG_LENGTH (arg) = len - 1;
1853 DEFARG_POINTER (arg) = buf;
1859 /* Called from grokfndecl to note a function decl with unparsed default
1860 arguments for later processing. Also called from grokdeclarator
1861 for function types with unparsed defargs; the call from grokfndecl
1862 will always come second, so we can overwrite the entry from the type. */
1865 add_defarg_fn (decl)
1868 if (TREE_CODE (decl) == FUNCTION_DECL)
1869 TREE_VALUE (defarg_fns) = decl;
1872 push_obstacks (&inline_text_obstack, &inline_text_obstack);
1873 defarg_fns = tree_cons (current_class_type, decl, defarg_fns);
1878 /* Helper for do_pending_defargs. Starts the parsing of a default arg. */
1884 tree d = TREE_PURPOSE (p);
1887 if (TREE_CODE (f) == FUNCTION_DECL)
1889 line = DECL_SOURCE_LINE (f);
1890 file = DECL_SOURCE_FILE (f);
1895 file = input_filename;
1898 feed_input (DEFARG_POINTER (d), DEFARG_LENGTH (d), file, line);
1899 yychar = DEFARG_MARKER;
1903 /* Helper for do_pending_defargs. Ends the parsing of a default arg. */
1908 if (yychar == YYEMPTY)
1910 if (yychar != END_OF_SAVED_INPUT)
1912 error ("parse error at end of saved function text");
1914 /* restore_pending_input will abort unless yychar is either
1915 END_OF_SAVED_INPUT or YYEMPTY; since we already know we're
1916 hosed, feed back YYEMPTY. */
1922 /* Main function for deferred parsing of default arguments. Called from
1926 do_pending_defargs ()
1931 for (; defarg_fns; defarg_fns = TREE_CHAIN (defarg_fns))
1933 tree defarg_fn = TREE_VALUE (defarg_fns);
1934 if (defarg_parm == NULL_TREE)
1936 push_nested_class (TREE_PURPOSE (defarg_fns), 1);
1938 if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
1939 maybe_begin_member_template_processing (defarg_fn);
1941 if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
1945 for (p = DECL_ARGUMENTS (defarg_fn); p; p = TREE_CHAIN (p))
1946 pushdecl (copy_node (p));
1948 defarg_parm = TYPE_ARG_TYPES (TREE_TYPE (defarg_fn));
1951 defarg_parm = TYPE_ARG_TYPES (defarg_fn);
1954 defarg_parm = TREE_CHAIN (defarg_parm);
1956 for (; defarg_parm; defarg_parm = TREE_CHAIN (defarg_parm))
1957 if (TREE_PURPOSE (defarg_parm)
1958 && TREE_CODE (TREE_PURPOSE (defarg_parm)) == DEFAULT_ARG)
1960 feed_defarg (defarg_fn, defarg_parm);
1962 /* Return to the parser, which will process this defarg
1963 and call us again. */
1967 if (TREE_CODE (defarg_fn) == FUNCTION_DECL)
1969 maybe_end_member_template_processing ();
1970 check_default_args (defarg_fn);
1974 pop_nested_class ();
1978 /* Build a default function named NAME for type TYPE.
1979 KIND says what to build.
1981 When KIND == 0, build default destructor.
1982 When KIND == 1, build virtual destructor.
1983 When KIND == 2, build default constructor.
1984 When KIND == 3, build default X(const X&) constructor.
1985 When KIND == 4, build default X(X&) constructor.
1986 When KIND == 5, build default operator = (const X&).
1987 When KIND == 6, build default operator = (X&). */
1990 cons_up_default_function (type, full_name, kind)
1991 tree type, full_name;
1994 tree declspecs = NULL_TREE;
1995 tree fn, args = NULL_TREE;
1998 tree name = constructor_name (full_name);
2004 declspecs = build_decl_list (NULL_TREE, ridpointers [(int) RID_VIRTUAL]);
2005 /* Fall through... */
2007 name = build_parse_node (BIT_NOT_EXPR, name);
2008 args = void_list_node;
2012 /* Default constructor. */
2013 args = void_list_node;
2017 type = build_qualified_type (type, TYPE_QUAL_CONST);
2018 /* Fall through... */
2020 /* According to ARM $12.8, the default copy ctor will be declared, but
2021 not defined, unless it's needed. */
2022 argtype = build_reference_type (type);
2023 args = tree_cons (NULL_TREE,
2024 build_tree_list (hash_tree_chain (argtype, NULL_TREE),
2025 get_identifier ("_ctor_arg")),
2032 declspecs = build_decl_list (NULL_TREE, type);
2035 type = build_qualified_type (type, TYPE_QUAL_CONST);
2037 name = ansi_opname [(int) MODIFY_EXPR];
2039 argtype = build_reference_type (type);
2040 args = tree_cons (NULL_TREE,
2041 build_tree_list (hash_tree_chain (argtype, NULL_TREE),
2042 get_identifier ("_ctor_arg")),
2047 my_friendly_abort (59);
2050 declspecs = decl_tree_cons (NULL_TREE, ridpointers [(int) RID_INLINE],
2053 TREE_PARMLIST (args) = 1;
2056 tree declarator = make_call_declarator (name, args, NULL_TREE, NULL_TREE);
2058 declarator = build_parse_node (ADDR_EXPR, declarator);
2060 fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE, NULL_TREE);
2063 if (fn == void_type_node)
2067 SET_DECL_ARTIFICIAL (TREE_CHAIN (DECL_ARGUMENTS (fn)));
2070 if (processing_template_defn)
2072 SET_DECL_IMPLICIT_INSTANTIATION (fn);
2073 repo_template_used (fn);
2078 if (CLASSTYPE_INTERFACE_KNOWN (type))
2080 DECL_INTERFACE_KNOWN (fn) = 1;
2081 DECL_NOT_REALLY_EXTERN (fn) = (!CLASSTYPE_INTERFACE_ONLY (type)
2082 && flag_implement_inlines);
2086 DECL_NOT_REALLY_EXTERN (fn) = 1;
2088 mark_inline_for_output (fn);
2090 #ifdef DEBUG_DEFAULT_FUNCTIONS
2091 { char *fn_type = NULL;
2095 case 0: fn_type = "default destructor"; break;
2096 case 1: fn_type = "virtual destructor"; break;
2097 case 2: fn_type = "default constructor"; break;
2098 case 3: fn_type = "default X(const X&)"; break;
2099 case 4: fn_type = "default X(X&)"; break;
2103 if (TREE_CODE (name) == BIT_NOT_EXPR)
2104 t = TREE_OPERAND (name, 0);
2105 fprintf (stderr, "[[[[ %s for %s:\n%s]]]]\n", fn_type,
2106 IDENTIFIER_POINTER (t), func_buf);
2109 #endif /* DEBUG_DEFAULT_FUNCTIONS */
2111 /* Show that this function was generated by the compiler. */
2112 SET_DECL_ARTIFICIAL (fn);
2117 /* Heuristic to tell whether the user is missing a semicolon
2118 after a struct or enum declaration. Emit an error message
2119 if we know the user has blown it. */
2122 check_for_missing_semicolon (type)
2130 && yychar != IDENTIFIER
2131 && yychar != TYPENAME
2132 && yychar != CV_QUALIFIER
2133 && yychar != SELFNAME)
2136 if (ANON_AGGRNAME_P (TYPE_IDENTIFIER (type)))
2137 error ("semicolon missing after %s declaration",
2138 TREE_CODE (type) == ENUMERAL_TYPE ? "enum" : "struct");
2140 cp_error ("semicolon missing after declaration of `%T'", type);
2141 shadow_tag (build_tree_list (0, type));
2143 /* Could probably also hack cases where class { ... } f (); appears. */
2148 note_got_semicolon (type)
2151 if (TREE_CODE_CLASS (TREE_CODE (type)) != 't')
2152 my_friendly_abort (60);
2153 if (CLASS_TYPE_P (type))
2154 CLASSTYPE_GOT_SEMICOLON (type) = 1;
2158 note_list_got_semicolon (declspecs)
2163 for (link = declspecs; link; link = TREE_CHAIN (link))
2165 tree type = TREE_VALUE (link);
2166 if (TREE_CODE_CLASS (TREE_CODE (type)) == 't')
2167 note_got_semicolon (type);
2172 /* Iff C is a carriage return, warn about it - if appropriate -
2173 and return nonzero. */
2178 static int newline_warning = 0;
2182 /* ANSI C says the effects of a carriage return in a source file
2184 if (pedantic && !newline_warning)
2186 warning ("carriage return in source file");
2187 warning ("(we only warn about the first carriage return)");
2188 newline_warning = 1;
2195 /* If C is not whitespace, return C.
2196 Otherwise skip whitespace and return first nonwhite char read. */
2199 skip_white_space (c)
2206 /* We don't recognize comments here, because
2207 cpp output can include / and * consecutively as operators.
2208 Also, there's no need, since cpp removes all comments. */
2216 c = check_newline ();
2225 /* While processing a # directive we don't get CPP_HSPACE
2226 tokens, so we also need to handle whitespace the normal way. */
2227 if (cpp_token == CPP_HSPACE)
2228 c = yy_get_token ();
2244 error ("stray '\\' in program");
2254 /* Make the token buffer longer, preserving the data in it.
2255 P should point to just beyond the last valid character in the old buffer.
2256 The value we return is a pointer to the new buffer
2257 at a place corresponding to P. */
2260 extend_token_buffer_to (size)
2264 maxtoken = maxtoken * 2 + 10;
2265 while (maxtoken < size);
2266 token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2);
2270 extend_token_buffer (p)
2273 int offset = p - token_buffer;
2274 extend_token_buffer_to (offset);
2275 return token_buffer + offset;
2278 #if defined HANDLE_PRAGMA
2279 /* Local versions of these macros, that can be passed as function pointers. */
2295 read_line_number (num)
2298 register int token = real_yylex ();
2300 if (token == CONSTANT
2301 && TREE_CODE (yylval.ttype) == INTEGER_CST)
2303 *num = TREE_INT_CST_LOW (yylval.ttype);
2308 if (token != END_OF_LINE)
2309 error ("invalid #-line");
2314 /* At the beginning of a line, increment the line number
2315 and process any #-directive on this line.
2316 If the line is a #-directive, read the entire line and return a newline.
2317 Otherwise, return the line's first non-whitespace character.
2319 Note that in the case of USE_CPPLIB, we get the whole line as one
2320 CPP_DIRECTIVE token. */
2328 enum { act_none, act_push, act_pop } action;
2329 int old_lineno, action_number, l;
2330 int entering_c_header;
2333 /* Read first nonwhite char on the line. Do this before incrementing the
2334 line number, in case we're at the end of saved text. */
2338 /* In some cases where we're leaving an include file, we can get multiple
2339 CPP_HSPACE tokens in a row, so we need to loop. */
2340 while (cpp_token == CPP_HSPACE)
2341 c = yy_get_token ();
2345 while (c == ' ' || c == '\t');
2352 /* Sequences of multiple newlines are very common; optimize them. */
2356 /* If not #, return it so caller will use it. */
2360 /* Don't read beyond this line. */
2365 if (cpp_token == CPP_VSPACE)
2367 /* Format is "<space> <line number> <filename> <newline>".
2368 Only the line number is interesting, and even that
2369 we can get more efficiently than scanning the line. */
2370 yy_cur = yy_lim - 1;
2371 lineno = parse_in.lineno - 1;
2376 token = real_yylex ();
2378 if (token == IDENTIFIER)
2380 /* If a letter follows, then if the word here is `line', skip
2381 it and ignore it; otherwise, ignore the line, with an error
2382 if the word isn't `pragma'. */
2384 const char *name = IDENTIFIER_POINTER (yylval.ttype);
2386 if (!strcmp (name, "pragma"))
2388 token = real_yylex ();
2389 if (token != IDENTIFIER
2390 || TREE_CODE (yylval.ttype) != IDENTIFIER_NODE)
2393 /* If this is 1, we handled it; if it's -1, it was one we
2394 wanted but had something wrong with it. Only if it's
2395 0 was it not handled. */
2396 if (handle_cp_pragma (IDENTIFIER_POINTER (yylval.ttype)))
2399 #ifdef HANDLE_PRAGMA
2400 /* We invoke HANDLE_PRAGMA before HANDLE_GENERIC_PRAGMAS
2401 (if both are defined), in order to give the back
2402 end a chance to override the interpretation of
2403 SYSV style pragmas. */
2404 if (HANDLE_PRAGMA (pragma_getc, pragma_ungetc,
2405 IDENTIFIER_POINTER (yylval.ttype)))
2407 #endif /* HANDLE_PRAGMA */
2409 #ifdef HANDLE_GENERIC_PRAGMAS
2410 if (handle_generic_pragma (token))
2412 #endif /* HANDLE_GENERIC_PRAGMAS */
2414 /* Issue a warning message if we have been asked to do so.
2415 Ignoring unknown pragmas in system header file unless
2416 an explcit -Wunknown-pragmas has been given. */
2417 if (warn_unknown_pragmas > 1
2418 || (warn_unknown_pragmas && ! in_system_header))
2419 warning ("ignoring pragma: %s", token_buffer);
2423 else if (!strcmp (name, "define"))
2425 debug_define (lineno, GET_DIRECTIVE_LINE ());
2428 else if (!strcmp (name, "undef"))
2430 debug_undef (lineno, GET_DIRECTIVE_LINE ());
2433 else if (!strcmp (name, "line"))
2436 token = real_yylex ();
2439 else if (!strcmp (name, "ident"))
2441 /* #ident. The pedantic warning is now in cccp.c. */
2443 /* Here we have just seen `#ident '.
2444 A string constant should follow. */
2446 token = real_yylex ();
2447 if (token == END_OF_LINE)
2450 || TREE_CODE (yylval.ttype) != STRING_CST)
2452 error ("invalid #ident");
2456 if (! flag_no_ident)
2458 #ifdef ASM_OUTPUT_IDENT
2459 ASM_OUTPUT_IDENT (asm_out_file,
2460 TREE_STRING_POINTER (yylval.ttype));
2464 /* Skip the rest of this line. */
2468 error ("undefined or invalid # directive `%s'", name);
2472 /* If the # is the only nonwhite char on the line,
2473 just ignore it. Check the new newline. */
2474 if (token == END_OF_LINE)
2478 /* Here we have either `#line' or `# <nonletter>'.
2479 In either case, it should be a line number; a digit should follow. */
2481 if (token != CONSTANT
2482 || TREE_CODE (yylval.ttype) != INTEGER_CST)
2484 error ("invalid #-line");
2488 /* subtract one, because it is the following line that
2489 gets the specified number */
2491 l = TREE_INT_CST_LOW (yylval.ttype) - 1;
2493 /* More follows: it must be a string constant (filename).
2494 It would be neat to use cpplib to quickly process the string, but
2495 (1) we don't have a handy tokenization of the string, and
2496 (2) I don't know how well that would work in the presense
2497 of filenames that contain wide characters. */
2501 /* Don't treat \ as special if we are processing #line 1 "...".
2502 If you want it to be treated specially, use # 1 "...". */
2503 ignore_escape_flag = 1;
2506 /* Read the string constant. */
2507 token = real_yylex ();
2509 ignore_escape_flag = 0;
2511 if (token == END_OF_LINE)
2513 /* No more: store the line number and check following line. */
2518 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
2520 error ("invalid #line");
2524 /* Changing files again. This means currently collected time
2525 is charged against header time, and body time starts back at 0. */
2526 if (flag_detailed_statistics)
2528 int this_time = my_get_run_time ();
2529 tree time_identifier = get_time_identifier (TREE_STRING_POINTER (yylval.ttype));
2530 header_time += this_time - body_time;
2531 TREE_INT_CST_LOW (TIME_IDENTIFIER_TIME (this_filename_time))
2532 += this_time - body_time;
2533 this_filename_time = time_identifier;
2534 body_time = this_time;
2537 if (!TREE_PERMANENT (yylval.ttype))
2540 = (char *) permalloc (TREE_STRING_LENGTH (yylval.ttype) + 1);
2541 strcpy (input_filename, TREE_STRING_POINTER (yylval.ttype));
2544 input_filename = TREE_STRING_POINTER (yylval.ttype);
2546 GNU_xref_file (input_filename);
2548 if (main_input_filename == 0)
2550 struct impl_files *ifiles = impl_file_chain;
2554 while (ifiles->next)
2555 ifiles = ifiles->next;
2556 ifiles->filename = file_name_nondirectory (input_filename);
2559 main_input_filename = input_filename;
2562 extract_interface_info ();
2564 old_lineno = lineno;
2569 /* Each change of file name
2570 reinitializes whether we are now in a system header. */
2571 in_system_header = 0;
2572 entering_c_header = 0;
2574 if (!read_line_number (&action_number))
2576 /* Update the name in the top element of input_file_stack. */
2577 if (input_file_stack)
2578 input_file_stack->name = input_filename;
2581 /* `1' after file name means entering new file.
2582 `2' after file name means just left a file. */
2584 if (action_number == 1)
2587 read_line_number (&action_number);
2589 else if (action_number == 2)
2592 read_line_number (&action_number);
2594 if (action_number == 3)
2596 /* `3' after file name means this is a system header file. */
2597 in_system_header = 1;
2598 read_line_number (&action_number);
2600 if (action_number == 4)
2602 /* `4' after file name means this is a C header file. */
2603 entering_c_header = 1;
2604 read_line_number (&action_number);
2607 /* Do the actions implied by the preceding numbers. */
2609 if (action == act_push)
2611 /* Pushing to a new file. */
2612 struct file_stack *p
2613 = (struct file_stack *) xmalloc (sizeof (struct file_stack));
2614 input_file_stack->line = old_lineno;
2615 p->next = input_file_stack;
2616 p->name = input_filename;
2617 p->indent_level = indent_level;
2618 input_file_stack = p;
2619 input_file_stack_tick++;
2620 debug_start_source_file (input_filename);
2623 else if (entering_c_header)
2626 ++pending_lang_change;
2629 else if (action == act_pop)
2631 /* Popping out of a file. */
2632 if (input_file_stack->next)
2634 struct file_stack *p = input_file_stack;
2636 if (c_header_level && --c_header_level == 0)
2638 if (entering_c_header)
2639 warning ("badly nested C headers from preprocessor");
2640 --pending_lang_change;
2643 if (indent_level != p->indent_level)
2645 warning_with_file_and_line
2646 (p->name, old_lineno,
2647 "This file contains more `%c's than `%c's.",
2648 indent_level > p->indent_level ? '{' : '}',
2649 indent_level > p->indent_level ? '}' : '{');
2651 input_file_stack = p->next;
2653 input_file_stack_tick++;
2654 debug_end_source_file (input_file_stack->line);
2657 error ("#-lines for entering and leaving files don't match");
2660 /* Now that we've pushed or popped the input stack,
2661 update the name in the top element. */
2662 if (input_file_stack)
2663 input_file_stack->name = input_filename;
2665 /* skip the rest of this line. */
2672 while (c != '\n' && c != EOF);
2676 #ifdef HANDLE_GENERIC_PRAGMAS
2678 /* Handle a #pragma directive.
2679 TOKEN is the token we read after `#pragma'. Processes the entire input
2680 line and return non-zero iff the pragma has been successfully parsed. */
2682 /* This function has to be in this file, in order to get at
2686 handle_generic_pragma (token)
2697 handle_pragma_token (token_buffer, yylval.ttype);
2701 handle_pragma_token ("(", NULL_TREE);
2702 handle_pragma_token (")", NULL_TREE);
2706 return handle_pragma_token (NULL_PTR, NULL_TREE);
2709 handle_pragma_token (token_buffer, NULL_TREE);
2712 token = real_yylex ();
2715 #endif /* HANDLE_GENERIC_PRAGMAS */
2718 handle_cp_pragma (pname)
2723 if (! strcmp (pname, "vtable"))
2725 extern tree pending_vtables;
2727 /* More follows: it must be a string constant (class name). */
2728 token = real_yylex ();
2729 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
2731 error ("invalid #pragma vtable");
2736 = perm_tree_cons (NULL_TREE,
2737 get_identifier (TREE_STRING_POINTER (yylval.ttype)),
2739 token = real_yylex ();
2740 if (token != END_OF_LINE)
2741 warning ("trailing characters ignored");
2744 else if (! strcmp (pname, "unit"))
2746 /* More follows: it must be a string constant (unit name). */
2747 token = real_yylex ();
2748 if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
2750 error ("invalid #pragma unit");
2753 token = real_yylex ();
2754 if (token != END_OF_LINE)
2755 warning ("trailing characters ignored");
2758 else if (! strcmp (pname, "interface"))
2760 char *main_filename = input_filename;
2762 main_filename = file_name_nondirectory (main_filename);
2764 token = real_yylex ();
2766 if (token != END_OF_LINE)
2769 || TREE_CODE (yylval.ttype) != STRING_CST)
2771 error ("invalid `#pragma interface'");
2774 main_filename = TREE_STRING_POINTER (yylval.ttype);
2775 token = real_yylex ();
2778 if (token != END_OF_LINE)
2779 warning ("garbage after `#pragma interface' ignored");
2781 cp_pragma_interface (main_filename);
2785 else if (! strcmp (pname, "implementation"))
2787 char *main_filename = main_input_filename ? main_input_filename : input_filename;
2789 main_filename = file_name_nondirectory (main_filename);
2791 token = real_yylex ();
2793 if (token != END_OF_LINE)
2796 || TREE_CODE (yylval.ttype) != STRING_CST)
2798 error ("invalid `#pragma implementation'");
2801 main_filename = TREE_STRING_POINTER (yylval.ttype);
2802 token = real_yylex ();
2805 if (token != END_OF_LINE)
2806 warning ("garbage after `#pragma implementation' ignored");
2808 cp_pragma_implementation (main_filename);
2817 do_pending_lang_change ()
2819 for (; pending_lang_change > 0; --pending_lang_change)
2820 push_lang_context (lang_name_c);
2821 for (; pending_lang_change < 0; ++pending_lang_change)
2822 pop_lang_context ();
2825 #define ENDFILE -1 /* token that represents end-of-file */
2827 /* Read an escape sequence, returning its equivalent as a character,
2828 or store 1 in *ignore_ptr if it is backslash-newline. */
2831 readescape (ignore_ptr)
2834 register int c = getch ();
2836 register unsigned count;
2837 unsigned firstdig = 0;
2855 if (c >= 'a' && c <= 'f')
2856 code += c - 'a' + 10;
2857 if (c >= 'A' && c <= 'F')
2858 code += c - 'A' + 10;
2859 if (c >= '0' && c <= '9')
2861 if (code != 0 || count != 0)
2870 error ("\\x used with no following hex digits");
2871 else if (count == 0)
2872 /* Digits are all 0's. Ok. */
2874 else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node)
2877 << (TYPE_PRECISION (integer_type_node)
2880 pedwarn ("hex escape out of range");
2883 case '0': case '1': case '2': case '3': case '4':
2884 case '5': case '6': case '7':
2887 while ((c <= '7') && (c >= '0') && (count++ < 3))
2889 code = (code * 8) + (c - '0');
2895 case '\\': case '\'': case '"':
2904 return TARGET_NEWLINE;
2927 pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c);
2933 /* `\(', etc, are used at beginning of line to avoid confusing Emacs. */
2937 /* `\%' is used to prevent SCCS from getting confused. */
2940 pedwarn ("unknown escape sequence `\\%c'", c);
2944 pedwarn ("unknown escape sequence `\\%c'", c);
2946 pedwarn ("unknown escape sequence: `\\' followed by char code 0x%x", c);
2954 extern int end_of_file;
2957 strcpy (buf, string);
2959 /* We can't print string and character constants well
2960 because the token_buffer contains the result of processing escapes. */
2962 strcat (buf, input_redirected ()
2963 ? " at end of saved text"
2964 : " at end of input");
2965 else if (token_buffer[0] == 0)
2966 strcat (buf, " at null character");
2967 else if (token_buffer[0] == '"')
2968 strcat (buf, " before string constant");
2969 else if (token_buffer[0] == '\'')
2970 strcat (buf, " before character constant");
2971 else if (!ISGRAPH ((unsigned char)token_buffer[0]))
2972 sprintf (buf + strlen (buf), " before character 0%o",
2973 (unsigned char) token_buffer[0]);
2975 strcat (buf, " before `%s'");
2977 error (buf, token_buffer);
2980 /* Value is 1 (or 2) if we should try to make the next identifier look like
2981 a typename (when it may be a local variable or a class variable).
2982 Value is 0 if we treat this name in a default fashion. */
2983 int looking_for_typename;
2989 identifier_type (decl)
2993 if (TREE_CODE (decl) == TEMPLATE_DECL)
2995 if (TREE_CODE (DECL_RESULT (decl)) == TYPE_DECL)
2997 else if (looking_for_template)
3000 if (looking_for_template && really_overloaded_fn (decl))
3002 /* See through a baselink. */
3003 if (TREE_CODE (decl) == TREE_LIST)
3004 decl = TREE_VALUE (decl);
3006 for (t = decl; t != NULL_TREE; t = OVL_CHAIN (t))
3007 if (DECL_FUNCTION_TEMPLATE_P (OVL_FUNCTION (t)))
3010 if (TREE_CODE (decl) == NAMESPACE_DECL)
3012 if (TREE_CODE (decl) != TYPE_DECL)
3014 if (DECL_ARTIFICIAL (decl) && TREE_TYPE (decl) == current_class_type)
3017 /* A constructor declarator for a template type will get here as an
3018 implicit typename, a TYPENAME_TYPE with a type. */
3020 if (t && TREE_CODE (t) == TYPENAME_TYPE)
3022 decl = TREE_TYPE (decl);
3023 if (TREE_CODE (decl) == TYPENAME_TYPE)
3024 decl = TREE_TYPE (decl);
3034 /* Only types expected, not even namespaces. */
3035 looking_for_typename = 2;
3037 if ((yychar = yylex ()) < 0) yychar = 0;
3038 looking_for_typename = 0;
3039 if (yychar == IDENTIFIER)
3041 lastiddecl = lookup_name (yylval.ttype, -2);
3042 if (lastiddecl == 0)
3045 lastiddecl = IDENTIFIER_LABEL_VALUE (yylval.ttype);
3048 yychar = identifier_type (lastiddecl);
3052 /* Return true if d is in a global scope. */
3059 switch (TREE_CODE (d))
3064 case OVERLOAD: d = OVL_FUNCTION (d); continue;
3065 case TREE_LIST: d = TREE_VALUE (d); continue;
3067 my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (d)) == 'd', 980629);
3069 /* A template parameter is not really global, even though it
3070 has no enclosing scope. */
3071 if (DECL_TEMPLATE_PARM_P (d))
3074 d = CP_DECL_CONTEXT (d);
3075 return TREE_CODE (d) == NAMESPACE_DECL;
3080 do_identifier (token, parsing, args)
3081 register tree token;
3086 int lexing = (parsing == 1);
3087 int in_call = (parsing == 2);
3089 if (! lexing || IDENTIFIER_OPNAME_P (token))
3090 id = lookup_name (token, 0);
3094 /* Scope class declarations before global
3096 if ((!id || is_global (id))
3097 && current_class_type != 0
3098 && TYPE_SIZE (current_class_type) == 0)
3100 /* Could be from one of the base classes. */
3101 tree field = lookup_field (current_class_type, token, 1, 0);
3104 else if (field == error_mark_node)
3105 /* We have already generated the error message.
3106 But we still want to return this value. */
3107 id = lookup_field (current_class_type, token, 0, 0);
3108 else if (TREE_CODE (field) == VAR_DECL
3109 || TREE_CODE (field) == CONST_DECL
3110 || TREE_CODE (field) == TEMPLATE_DECL)
3112 else if (TREE_CODE (field) != FIELD_DECL)
3113 my_friendly_abort (61);
3116 cp_error ("invalid use of member `%D'", field);
3117 id = error_mark_node;
3122 /* Do Koenig lookup if appropriate (inside templates we build lookup
3123 expressions instead). */
3124 if (args && !current_template_parms && (!id || is_global (id)))
3125 /* If we have arguments and we only found global names, do Koenig
3127 id = lookup_arg_dependent (token, id, args);
3129 /* Remember that this name has been used in the class definition, as per
3132 /* Avoid breaking if we get called for a default argument that
3133 refers to an overloaded method. Eventually this will not be
3134 necessary, since default arguments shouldn't be parsed until
3135 after the class is complete. (jason 3/12/97) */
3136 && TREE_CODE (id) != OVERLOAD)
3137 maybe_note_name_used_in_class (token, id);
3139 if (id == error_mark_node)
3141 /* lookup_name quietly returns error_mark_node if we're parsing,
3142 as we don't want to complain about an identifier that ends up
3143 being used as a declarator. So we call it again to get the error
3145 id = lookup_name (token, 0);
3146 return error_mark_node;
3151 if (current_template_parms)
3152 return build_min_nt (LOOKUP_EXPR, token);
3153 else if (IDENTIFIER_OPNAME_P (token))
3155 if (token != ansi_opname[ERROR_MARK])
3156 cp_error ("`%D' not defined", token);
3157 id = error_mark_node;
3159 else if (in_call && ! flag_strict_prototype)
3161 id = implicitly_declare (token);
3163 else if (current_function_decl == 0)
3165 cp_error ("`%D' was not declared in this scope", token);
3166 id = error_mark_node;
3170 if (IDENTIFIER_NAMESPACE_VALUE (token) != error_mark_node
3171 || IDENTIFIER_ERROR_LOCUS (token) != current_function_decl)
3173 static int undeclared_variable_notice;
3175 cp_error ("`%D' undeclared (first use this function)", token);
3177 if (! undeclared_variable_notice)
3179 error ("(Each undeclared identifier is reported only once");
3180 error ("for each function it appears in.)");
3181 undeclared_variable_notice = 1;
3184 id = error_mark_node;
3185 /* Prevent repeated error messages. */
3186 SET_IDENTIFIER_NAMESPACE_VALUE (token, error_mark_node);
3187 SET_IDENTIFIER_ERROR_LOCUS (token, current_function_decl);
3191 if (TREE_CODE (id) == VAR_DECL && DECL_DEAD_FOR_LOCAL (id))
3193 tree shadowed = DECL_SHADOWED_FOR_VAR (id);
3194 while (shadowed != NULL_TREE && TREE_CODE (shadowed) == VAR_DECL
3195 && DECL_DEAD_FOR_LOCAL (shadowed))
3196 shadowed = DECL_SHADOWED_FOR_VAR (shadowed);
3198 shadowed = IDENTIFIER_NAMESPACE_VALUE (DECL_NAME (id));
3201 if (!DECL_ERROR_REPORTED (id))
3203 warning ("name lookup of `%s' changed",
3204 IDENTIFIER_POINTER (token));
3205 cp_warning_at (" matches this `%D' under current ANSI rules",
3207 cp_warning_at (" matches this `%D' under old rules", id);
3208 DECL_ERROR_REPORTED (id) = 1;
3212 else if (!DECL_ERROR_REPORTED (id))
3215 = "name lookup of `%s' changed for new ANSI `for' scoping";
3216 DECL_ERROR_REPORTED (id) = 1;
3217 if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (id)))
3219 error (msg, IDENTIFIER_POINTER (token));
3220 cp_error_at (" cannot use obsolete binding at `%D' because it has a destructor", id);
3221 id = error_mark_node;
3225 pedwarn (msg, IDENTIFIER_POINTER (token));
3226 cp_pedwarn_at (" using obsolete binding at `%D'", id);
3230 /* TREE_USED is set in `hack_identifier'. */
3231 if (TREE_CODE (id) == CONST_DECL)
3234 if (IDENTIFIER_CLASS_VALUE (token) == id)
3235 enforce_access (DECL_REAL_CONTEXT(id), id);
3236 if (!processing_template_decl || DECL_TEMPLATE_PARM_P (id))
3237 id = DECL_INITIAL (id);
3240 id = hack_identifier (id, token);
3242 /* We must look up dependent names when the template is
3243 instantiated, not while parsing it. For now, we don't
3244 distinguish between dependent and independent names. So, for
3245 example, we look up all overloaded functions at
3246 instantiation-time, even though in some cases we should just use
3247 the DECL we have here. We also use LOOKUP_EXPRs to find things
3248 like local variables, rather than creating TEMPLATE_DECLs for the
3249 local variables and then finding matching instantiations. */
3250 if (current_template_parms
3251 && (is_overloaded_fn (id)
3252 /* If it's not going to be around at instantiation time, we
3253 look it up then. This is a hack, and should go when we
3254 really get dependent/independent name lookup right. */
3255 || !TREE_PERMANENT (id)
3256 /* Some local VAR_DECLs (such as those for local variables
3257 in member functions of local classes) are built on the
3258 permanent obstack. */
3259 || (TREE_CODE (id) == VAR_DECL
3260 && CP_DECL_CONTEXT (id)
3261 && TREE_CODE (CP_DECL_CONTEXT (id)) == FUNCTION_DECL)
3262 || TREE_CODE (id) == PARM_DECL
3263 || TREE_CODE (id) == RESULT_DECL
3264 || TREE_CODE (id) == USING_DECL))
3265 id = build_min_nt (LOOKUP_EXPR, token);
3271 do_scoped_id (token, parsing)
3276 /* during parsing, this is ::name. Otherwise, it is black magic. */
3279 struct tree_binding _b;
3280 id = binding_init (&_b);
3281 if (!qualified_lookup_using_namespace (token, global_namespace, id, 0))
3284 id = BINDING_VALUE (id);
3287 id = IDENTIFIER_GLOBAL_VALUE (token);
3288 if (parsing && yychar == YYEMPTY)
3292 if (processing_template_decl)
3294 id = build_min_nt (LOOKUP_EXPR, token);
3295 LOOKUP_EXPR_GLOBAL (id) = 1;
3298 if (parsing && (yychar == '(' || yychar == LEFT_RIGHT)
3299 && ! flag_strict_prototype)
3300 id = implicitly_declare (token);
3303 if (IDENTIFIER_NAMESPACE_VALUE (token) != error_mark_node)
3304 cp_error ("`::%D' undeclared (first use here)", token);
3305 id = error_mark_node;
3306 /* Prevent repeated error messages. */
3307 SET_IDENTIFIER_NAMESPACE_VALUE (token, error_mark_node);
3312 if (TREE_CODE (id) == ADDR_EXPR)
3313 mark_used (TREE_OPERAND (id, 0));
3314 else if (TREE_CODE (id) != OVERLOAD)
3317 if (TREE_CODE (id) == CONST_DECL && ! processing_template_decl)
3319 /* XXX CHS - should we set TREE_USED of the constant? */
3320 id = DECL_INITIAL (id);
3321 /* This is to prevent an enum whose value is 0
3322 from being considered a null pointer constant. */
3323 id = build1 (NOP_EXPR, TREE_TYPE (id), id);
3324 TREE_CONSTANT (id) = 1;
3327 if (processing_template_decl)
3329 if (is_overloaded_fn (id))
3331 id = build_min_nt (LOOKUP_EXPR, token);
3332 LOOKUP_EXPR_GLOBAL (id) = 1;
3335 /* else just use the decl */
3337 return convert_from_reference (id);
3341 identifier_typedecl_value (node)
3345 type = IDENTIFIER_TYPE_VALUE (node);
3346 if (type == NULL_TREE)
3349 if (IDENTIFIER_BINDING (node))
3351 t = IDENTIFIER_VALUE (node);
3352 if (t && TREE_CODE (t) == TYPE_DECL && TREE_TYPE (t) == type)
3355 if (IDENTIFIER_NAMESPACE_VALUE (node))
3357 t = IDENTIFIER_NAMESPACE_VALUE (node);
3358 if (t && TREE_CODE (t) == TYPE_DECL && TREE_TYPE (t) == type)
3362 /* Will this one ever happen? */
3363 if (TYPE_MAIN_DECL (type))
3364 return TYPE_MAIN_DECL (type);
3366 /* We used to do an internal error of 62 here, but instead we will
3367 handle the return of a null appropriately in the callers. */
3381 int conversion_errno;
3382 REAL_VALUE_TYPE value;
3389 struct pf_args * args = (struct pf_args *) data;
3390 int fflag = 0, lflag = 0;
3391 /* Copy token_buffer now, while it has just the number
3392 and not the suffixes; once we add `f' or `i',
3393 REAL_VALUE_ATOF may not work any more. */
3394 char *copy = (char *) alloca (args->p - token_buffer + 1);
3395 bcopy (token_buffer, copy, args->p - token_buffer + 1);
3397 args->conversion_errno = 0;
3398 args->type = double_type_node;
3404 /* Read the suffixes to choose a data type. */
3409 error ("more than one `f' in numeric constant");
3415 error ("more than one `l' in numeric constant");
3421 error ("more than one `i' or `j' in numeric constant");
3423 pedwarn ("ANSI C++ forbids imaginary numeric constants");
3434 if (args->p >= token_buffer + maxtoken - 3)
3435 args->p = extend_token_buffer (args->p);
3436 *(args->p++) = args->c;
3441 /* The second argument, machine_mode, of REAL_VALUE_ATOF
3442 tells the desired precision of the binary result
3443 of decimal-to-binary conversion. */
3448 error ("both `f' and `l' in floating constant");
3450 args->type = float_type_node;
3452 if (args->base == 16)
3453 args->value = REAL_VALUE_HTOF (copy, TYPE_MODE (args->type));
3455 args->value = REAL_VALUE_ATOF (copy, TYPE_MODE (args->type));
3456 args->conversion_errno = errno;
3457 /* A diagnostic is required here by some ANSI C testsuites.
3458 This is not pedwarn, because some people don't want
3459 an error for this. */
3460 if (REAL_VALUE_ISINF (args->value) && pedantic)
3461 warning ("floating point number exceeds range of `float'");
3465 args->type = long_double_type_node;
3467 if (args->base == 16)
3468 args->value = REAL_VALUE_HTOF (copy, TYPE_MODE (args->type));
3470 args->value = REAL_VALUE_ATOF (copy, TYPE_MODE (args->type));
3471 args->conversion_errno = errno;
3472 if (REAL_VALUE_ISINF (args->value) && pedantic)
3473 warning ("floating point number exceeds range of `long double'");
3478 if (args->base == 16)
3479 args->value = REAL_VALUE_HTOF (copy, TYPE_MODE (args->type));
3481 args->value = REAL_VALUE_ATOF (copy, TYPE_MODE (args->type));
3482 args->conversion_errno = errno;
3483 if (REAL_VALUE_ISINF (args->value) && pedantic)
3484 warning ("floating point number exceeds range of `double'");
3488 /* Get the next character, staying within the current token if possible.
3489 If we're lexing a token, we don't want to look beyond the end of the
3490 token cpplib has prepared for us; otherwise, we end up reading in the
3491 next token, which screws up feed_input. So just return a null
3498 if (yy_cur == yy_lim)
3515 /* Read a single token from the input stream, and assign it lexical
3518 Note: We used to do token pasting here, to produce compound tokens like
3519 LEFT_RIGHT and EXTERN_LANG_STRING. That's now handled in spew.c, along
3520 with symbol table interaction and other context-sensitivity. */
3532 /* Effectively do c = skip_white_space (c)
3533 but do it faster in the usual cases. */
3543 if (cpp_token == CPP_HSPACE)
3544 c = yy_get_token ();
3551 /* Call skip_white_space so we can warn if appropriate. */
3556 c = skip_white_space (c);
3558 goto found_nonwhite;
3562 token_buffer[0] = c;
3563 token_buffer[1] = 0;
3565 /* yylloc.first_line = lineno; */
3571 token_buffer[0] = 0;
3573 value = END_OF_LINE;
3574 else if (input_redirected ())
3575 value = END_OF_SAVED_INPUT;
3582 if (cpp_token == CPP_NAME)
3585 /* Capital L may start a wide-string or wide-character constant. */
3587 register int c = token_getch ();
3596 goto string_constant;
3601 case 'A': case 'B': case 'C': case 'D': case 'E':
3602 case 'F': case 'G': case 'H': case 'I': case 'J':
3603 case 'K': case 'M': case 'N': case 'O':
3604 case 'P': case 'Q': case 'R': case 'S': case 'T':
3605 case 'U': case 'V': case 'W': case 'X': case 'Y':
3607 case 'a': case 'b': case 'c': case 'd': case 'e':
3608 case 'f': case 'g': case 'h': case 'i': case 'j':
3609 case 'k': case 'l': case 'm': case 'n': case 'o':
3610 case 'p': case 'q': case 'r': case 's': case 't':
3611 case 'u': case 'v': case 'w': case 'x': case 'y':
3617 if (cpp_token == CPP_NAME)
3619 /* Note that one character has already been read from
3620 yy_cur into token_buffer. Also, cpplib complains about
3621 $ in identifiers, so we don't have to. */
3623 int len = yy_lim - yy_cur + 1;
3624 if (len >= maxtoken)
3625 extend_token_buffer_to (len + 1);
3626 memcpy (token_buffer + 1, yy_cur, len);
3627 p = token_buffer + len;
3634 while (ISALNUM (c) || (c == '_') || c == '$')
3636 /* Make sure this char really belongs in an identifier. */
3639 if (! dollars_in_ident)
3640 error ("`$' in identifier");
3642 pedwarn ("`$' in identifier");
3645 if (p >= token_buffer + maxtoken)
3646 p = extend_token_buffer (p);
3659 /* Try to recognize a keyword. Uses minimum-perfect hash function */
3662 register struct resword *ptr;
3664 if ((ptr = is_reserved_word (token_buffer, p - token_buffer)))
3668 if (ptr->token == VISSPEC)
3673 yylval.ttype = access_public_node;
3676 yylval.ttype = access_private_node;
3679 yylval.ttype = access_protected_node;
3682 my_friendly_abort (63);
3686 yylval.ttype = ridpointers[(int) ptr->rid];
3688 else switch (ptr->token)
3691 yylval.code = NE_EXPR;
3692 token_buffer[0] = '!';
3693 token_buffer[1] = '=';
3694 token_buffer[2] = 0;
3698 if (strcmp ("and_eq", token_buffer) == 0)
3700 yylval.code = BIT_AND_EXPR;
3701 token_buffer[0] = '&';
3703 else if (strcmp ("or_eq", token_buffer) == 0)
3705 yylval.code = BIT_IOR_EXPR;
3706 token_buffer[0] = '|';
3708 else if (strcmp ("xor_eq", token_buffer) == 0)
3710 yylval.code = BIT_XOR_EXPR;
3711 token_buffer[0] = '^';
3713 token_buffer[1] = '=';
3714 token_buffer[2] = 0;
3718 yylval.code = BIT_AND_EXPR;
3719 token_buffer[0] = '&';
3720 token_buffer[1] = 0;
3724 yylval.code = BIT_IOR_EXPR;
3725 token_buffer[0] = '|';
3726 token_buffer[1] = 0;
3730 yylval.code = BIT_XOR_EXPR;
3731 token_buffer[0] = '^';
3732 token_buffer[1] = 0;
3736 value = (int) ptr->token;
3740 /* If we did not find a keyword, look for an identifier
3743 if (value == IDENTIFIER || value == TYPESPEC)
3744 GNU_xref_ref (current_function_decl, token_buffer);
3746 if (value == IDENTIFIER)
3748 register tree tmp = get_identifier (token_buffer);
3750 #if !defined(VMS) && defined(JOINER)
3751 /* Make sure that user does not collide with our internal
3754 && (THIS_NAME_P (tmp)
3755 || VPTR_NAME_P (tmp)
3756 || DESTRUCTOR_NAME_P (tmp)
3757 || VTABLE_NAME_P (tmp)
3758 || TEMP_NAME_P (tmp)
3759 || ANON_AGGRNAME_P (tmp)
3760 || ANON_PARMNAME_P (tmp)))
3761 warning ("identifier name `%s' conflicts with GNU C++ internal naming strategy",
3767 if (value == NEW && ! global_bindings_p ())
3776 if (yy_cur < yy_lim)
3779 /* It's hard to preserve tokenization on '.' because
3780 it could be a symbol by itself, or it could be the
3781 start of a floating point number and cpp won't tell us. */
3782 register int c1 = token_getch ();
3783 token_buffer[1] = c1;
3787 token_buffer[2] = 0;
3792 c1 = token_getch ();
3795 token_buffer[2] = c1;
3796 token_buffer[3] = 0;
3800 error ("parse error at `..'");
3804 token_put_back (c1);
3807 token_put_back (c1);
3810 token_buffer[1] = 0;
3814 /* Optimize for most frequent case. */
3819 cond = (yy_cur == yy_lim);
3821 register int c1 = token_getch ();
3822 token_put_back (c1);
3823 cond = (! ISALNUM (c1) && c1 != '.');
3827 yylval.ttype = (c == '0') ? integer_zero_node : integer_one_node;
3833 case '2': case '3': case '4':
3834 case '5': case '6': case '7': case '8': case '9':
3839 int largest_digit = 0;
3843 /* We actually store only HOST_BITS_PER_CHAR bits in each part.
3844 The code below which fills the parts array assumes that a host
3845 int is at least twice as wide as a host char, and that
3846 HOST_BITS_PER_WIDE_INT is an even multiple of HOST_BITS_PER_CHAR.
3847 Two HOST_WIDE_INTs is the largest int literal we can store.
3848 In order to detect overflow below, the number of parts (TOTAL_PARTS)
3849 must be exactly the number of parts needed to hold the bits
3850 of two HOST_WIDE_INTs. */
3851 #define TOTAL_PARTS ((HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2)
3852 unsigned int parts[TOTAL_PARTS];
3854 enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS, AFTER_EXPON }
3855 floatflag = NOT_FLOAT;
3857 for (count = 0; count < TOTAL_PARTS; count++)
3865 *p++ = (c = token_getch ());
3866 if ((c == 'x') || (c == 'X'))
3869 *p++ = (c = token_getch ());
3871 /* Leading 0 forces octal unless the 0 is the only digit. */
3872 else if (c >= '0' && c <= '9')
3881 /* Read all the digits-and-decimal-points. */
3884 || (ISALNUM (c) && c != 'l' && c != 'L'
3885 && c != 'u' && c != 'U'
3886 && c != 'i' && c != 'I' && c != 'j' && c != 'J'
3887 && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
3891 if (base == 16 && pedantic)
3892 pedwarn ("floating constant may not be in radix 16");
3893 if (floatflag == TOO_MANY_POINTS)
3894 /* We have already emitted an error. Don't need another. */
3896 else if (floatflag == AFTER_POINT || floatflag == AFTER_EXPON)
3898 error ("malformed floating constant");
3899 floatflag = TOO_MANY_POINTS;
3900 /* Avoid another error from atof by forcing all characters
3901 from here on to be ignored. */
3905 floatflag = AFTER_POINT;
3909 *p++ = c = token_getch ();
3910 /* Accept '.' as the start of a floating-point number
3911 only when it is followed by a digit. */
3912 if (p == token_buffer + 2 && !ISDIGIT (c))
3913 my_friendly_abort (990710);
3917 /* It is not a decimal point.
3918 It should be a digit (perhaps a hex digit). */
3924 else if (base <= 10)
3926 if (c == 'e' || c == 'E')
3929 floatflag = AFTER_EXPON;
3930 break; /* start of exponent */
3932 error ("nondigits in number and not hexadecimal");
3935 else if (base == 16 && (c == 'p' || c == 'P'))
3937 floatflag = AFTER_EXPON;
3938 break; /* start of exponent */
3948 if (c >= largest_digit)
3952 for (count = 0; count < TOTAL_PARTS; count++)
3954 parts[count] *= base;
3958 += (parts[count-1] >> HOST_BITS_PER_CHAR);
3960 &= (1 << HOST_BITS_PER_CHAR) - 1;
3966 /* If the highest-order part overflows (gets larger than
3967 a host char will hold) then the whole number has
3968 overflowed. Record this and truncate the highest-order
3970 if (parts[TOTAL_PARTS - 1] >> HOST_BITS_PER_CHAR)
3973 parts[TOTAL_PARTS - 1] &= (1 << HOST_BITS_PER_CHAR) - 1;
3976 if (p >= token_buffer + maxtoken - 3)
3977 p = extend_token_buffer (p);
3978 *p++ = (c = token_getch ());
3982 /* This can happen on input like `int i = 0x;' */
3984 error ("numeric constant with no digits");
3986 if (largest_digit >= base)
3987 error ("numeric constant contains digits beyond the radix");
3989 /* Remove terminating char from the token buffer and delimit the
3993 if (floatflag != NOT_FLOAT)
3996 int imag, conversion_errno;
3997 REAL_VALUE_TYPE value;
3998 struct pf_args args;
4000 /* Read explicit exponent if any, and put it in tokenbuf. */
4002 if ((base == 10 && ((c == 'e') || (c == 'E')))
4003 || (base == 16 && (c == 'p' || c == 'P')))
4005 if (p >= token_buffer + maxtoken - 3)
4006 p = extend_token_buffer (p);
4009 if ((c == '+') || (c == '-'))
4014 /* Exponent is decimal, even if string is a hex float. */
4016 error ("floating constant exponent has no digits");
4019 if (p >= token_buffer + maxtoken - 3)
4020 p = extend_token_buffer (p);
4025 if (base == 16 && floatflag != AFTER_EXPON)
4026 error ("hexadecimal floating constant has no exponent");
4030 /* Setup input for parse_float() */
4035 /* Convert string to a double, checking for overflow. */
4036 if (do_float_handler (parse_float, (PTR) &args))
4038 /* Receive output from parse_float() */
4043 /* We got an exception from parse_float() */
4044 error ("floating constant out of range");
4048 /* Receive output from parse_float() */
4052 conversion_errno = args.conversion_errno;
4055 /* ERANGE is also reported for underflow,
4056 so test the value to distinguish overflow from that. */
4057 if (conversion_errno == ERANGE && pedantic
4058 && (REAL_VALUES_LESS (dconst1, value)
4059 || REAL_VALUES_LESS (value, dconstm1)))
4060 warning ("floating point number exceeds range of `double'");
4063 /* If the result is not a number, assume it must have been
4064 due to some error message above, so silently convert
4066 if (REAL_VALUE_ISNAN (value))
4069 /* Create a node with determined type and value. */
4071 yylval.ttype = build_complex (NULL_TREE,
4072 convert (type, integer_zero_node),
4073 build_real (type, value));
4075 yylval.ttype = build_real (type, value);
4080 HOST_WIDE_INT high, low;
4081 int spec_unsigned = 0;
4083 int spec_long_long = 0;
4090 if (c == 'u' || c == 'U')
4093 error ("two `u's in integer constant");
4096 else if (c == 'l' || c == 'L')
4101 error ("three `l's in integer constant");
4102 else if (pedantic && ! in_system_header && warn_long_long)
4103 pedwarn ("ANSI C++ forbids long long integer constants");
4108 else if (c == 'i' || c == 'j' || c == 'I' || c == 'J')
4111 error ("more than one `i' or `j' in numeric constant");
4113 pedwarn ("ANSI C++ forbids imaginary numeric constants");
4118 if (p >= token_buffer + maxtoken - 3)
4119 p = extend_token_buffer (p);
4124 /* If the literal overflowed, pedwarn about it now. */
4128 pedwarn ("integer constant is too large for this configuration of the compiler - truncated to %d bits", HOST_BITS_PER_WIDE_INT * 2);
4131 /* This is simplified by the fact that our constant
4132 is always positive. */
4136 for (i = 0; i < HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR; i++)
4138 high |= ((HOST_WIDE_INT) parts[i + (HOST_BITS_PER_WIDE_INT
4139 / HOST_BITS_PER_CHAR)]
4140 << (i * HOST_BITS_PER_CHAR));
4141 low |= (HOST_WIDE_INT) parts[i] << (i * HOST_BITS_PER_CHAR);
4144 yylval.ttype = build_int_2 (low, high);
4145 TREE_TYPE (yylval.ttype) = long_long_unsigned_type_node;
4147 /* Calculate the ANSI type. */
4148 if (! spec_long && ! spec_unsigned
4149 && int_fits_type_p (yylval.ttype, integer_type_node))
4150 type = integer_type_node;
4151 else if (! spec_long && (base != 10 || spec_unsigned)
4152 && int_fits_type_p (yylval.ttype, unsigned_type_node))
4153 type = unsigned_type_node;
4154 else if (! spec_unsigned && !spec_long_long
4155 && int_fits_type_p (yylval.ttype, long_integer_type_node))
4156 type = long_integer_type_node;
4157 else if (! spec_long_long
4158 && int_fits_type_p (yylval.ttype,
4159 long_unsigned_type_node))
4160 type = long_unsigned_type_node;
4161 else if (! spec_unsigned
4162 && int_fits_type_p (yylval.ttype,
4163 long_long_integer_type_node))
4164 type = long_long_integer_type_node;
4165 else if (int_fits_type_p (yylval.ttype,
4166 long_long_unsigned_type_node))
4167 type = long_long_unsigned_type_node;
4168 else if (! spec_unsigned
4169 && int_fits_type_p (yylval.ttype,
4170 widest_integer_literal_type_node))
4171 type = widest_integer_literal_type_node;
4173 type = widest_unsigned_literal_type_node;
4175 if (pedantic && !spec_long_long && !warn
4176 && (TYPE_PRECISION (long_integer_type_node)
4177 < TYPE_PRECISION (type)))
4180 pedwarn ("integer constant larger than the maximum value of an unsigned long int");
4183 if (base == 10 && ! spec_unsigned && TREE_UNSIGNED (type))
4184 warning ("decimal constant is so large that it is unsigned");
4188 if (TYPE_PRECISION (type)
4189 <= TYPE_PRECISION (integer_type_node))
4191 = build_complex (NULL_TREE, integer_zero_node,
4192 convert (integer_type_node,
4195 error ("complex integer constant is too wide for `__complex int'");
4198 TREE_TYPE (yylval.ttype) = type;
4201 /* If it's still an integer (not a complex), and it doesn't
4202 fit in the type we choose for it, then pedwarn. */
4205 && TREE_CODE (TREE_TYPE (yylval.ttype)) == INTEGER_TYPE
4206 && ! int_fits_type_p (yylval.ttype, TREE_TYPE (yylval.ttype)))
4207 pedwarn ("integer constant is larger than the maximum value for its type");
4213 if (ISALNUM (c) || c == '.' || c == '_' || c == '$'
4214 || ((c == '-' || c == '+')
4215 && (p[-1] == 'e' || p[-1] == 'E')))
4216 error ("missing white space after number `%s'", token_buffer);
4218 value = CONSTANT; break;
4224 register int result = 0;
4225 register int num_chars = 0;
4227 unsigned width = TYPE_PRECISION (char_type_node);
4229 #ifdef MULTIBYTE_CHARS
4230 int longest_char = local_mb_cur_max ();
4231 local_mbtowc (NULL_PTR, NULL_PTR, 0);
4234 max_chars = TYPE_PRECISION (integer_type_node) / width;
4236 width = WCHAR_TYPE_SIZE;
4243 if (c == '\'' || c == EOF)
4250 c = readescape (&ignore);
4253 if (width < HOST_BITS_PER_INT
4254 && (unsigned) c >= ((unsigned)1 << width))
4255 pedwarn ("escape sequence out of range for character");
4256 #ifdef MAP_CHARACTER
4258 c = MAP_CHARACTER (c);
4264 pedwarn ("ANSI C forbids newline in character constant");
4269 #ifdef MULTIBYTE_CHARS
4273 for (i = 1; i <= longest_char; ++i)
4275 if (i > maxtoken - 4)
4276 extend_token_buffer (token_buffer);
4278 token_buffer[i] = c;
4279 char_len = local_mbtowc (& wc,
4288 /* mbtowc sometimes needs an extra char before accepting */
4293 /* Merge character into result; ignore excess chars. */
4294 for (i = 1; i <= char_len; ++i)
4298 if (width < HOST_BITS_PER_INT)
4299 result = (result << width)
4301 & ((1 << width) - 1));
4303 result = token_buffer[i];
4305 num_chars += char_len;
4314 warning ("Ignoring invalid multibyte character");
4315 /* Replace all but the first byte. */
4316 for (--i; i > 1; --i)
4317 token_put_back (token_buffer[i]);
4318 wc = token_buffer[1];
4320 #ifdef MAP_CHARACTER
4321 c = MAP_CHARACTER (wc);
4326 #else /* ! MULTIBYTE_CHARS */
4327 #ifdef MAP_CHARACTER
4328 c = MAP_CHARACTER (c);
4330 #endif /* ! MULTIBYTE_CHARS */
4335 if (chars_seen == 1) /* only keep the first one */
4340 /* Merge character into result; ignore excess chars. */
4341 num_chars += (width / TYPE_PRECISION (char_type_node));
4342 if (num_chars < max_chars + 1)
4344 if (width < HOST_BITS_PER_INT)
4345 result = (result << width) | (c & ((1 << width) - 1));
4352 error ("malformatted character constant");
4353 else if (chars_seen == 0)
4354 error ("empty character constant");
4355 else if (num_chars > max_chars)
4357 num_chars = max_chars;
4358 error ("character constant too long");
4360 else if (chars_seen != 1 && warn_multichar)
4361 warning ("multi-character character constant");
4363 /* If char type is signed, sign-extend the constant. */
4366 int num_bits = num_chars * width;
4368 /* We already got an error; avoid invalid shift. */
4369 yylval.ttype = build_int_2 (0, 0);
4370 else if (TREE_UNSIGNED (char_type_node)
4371 || ((result >> (num_bits - 1)) & 1) == 0)
4373 = build_int_2 (result & (~(unsigned HOST_WIDE_INT) 0
4374 >> (HOST_BITS_PER_WIDE_INT - num_bits)),
4378 = build_int_2 (result | ~(~(unsigned HOST_WIDE_INT) 0
4379 >> (HOST_BITS_PER_WIDE_INT - num_bits)),
4381 /* In C, a character constant has type 'int'; in C++, 'char'. */
4382 if (chars_seen <= 1)
4383 TREE_TYPE (yylval.ttype) = char_type_node;
4385 TREE_TYPE (yylval.ttype) = integer_type_node;
4389 yylval.ttype = build_int_2 (result, 0);
4390 TREE_TYPE (yylval.ttype) = wchar_type_node;
4400 unsigned width = wide_flag ? WCHAR_TYPE_SIZE
4401 : TYPE_PRECISION (char_type_node);
4402 #ifdef MULTIBYTE_CHARS
4403 int longest_char = local_mb_cur_max ();
4404 local_mbtowc (NULL_PTR, NULL_PTR, 0);
4408 p = token_buffer + 1;
4410 while (c != '"' && c != EOF)
4412 /* ignore_escape_flag is set for reading the filename in #line. */
4413 if (!ignore_escape_flag && c == '\\')
4416 c = readescape (&ignore);
4419 if (width < HOST_BITS_PER_INT
4420 && (unsigned) c >= ((unsigned)1 << width))
4421 pedwarn ("escape sequence out of range for character");
4426 pedwarn ("ANSI C++ forbids newline in string constant");
4431 #ifdef MULTIBYTE_CHARS
4435 for (i = 0; i < longest_char; ++i)
4437 if (p + i >= token_buffer + maxtoken)
4438 p = extend_token_buffer (p);
4441 char_len = local_mbtowc (& wc, p, i + 1);
4448 warning ("Ignoring invalid multibyte character");
4449 /* Replace all except the first byte. */
4451 for (--i; i > 0; --i)
4452 token_put_back (p[i]);
4455 /* mbtowc sometimes needs an extra char before accepting */
4465 #endif /* MULTIBYTE_CHARS */
4468 /* Add this single character into the buffer either as a wchar_t
4469 or as a single byte. */
4472 unsigned width = TYPE_PRECISION (char_type_node);
4473 unsigned bytemask = (1 << width) - 1;
4476 if (p + WCHAR_BYTES > token_buffer + maxtoken)
4477 p = extend_token_buffer (p);
4479 for (byte = 0; byte < WCHAR_BYTES; ++byte)
4482 if (byte >= (int) sizeof (c))
4485 value = (c >> (byte * width)) & bytemask;
4486 if (BYTES_BIG_ENDIAN)
4487 p[WCHAR_BYTES - byte - 1] = value;
4495 if (p >= token_buffer + maxtoken)
4496 p = extend_token_buffer (p);
4504 /* Terminate the string value, either with a single byte zero
4505 or with a wide zero. */
4508 if (p + WCHAR_BYTES > token_buffer + maxtoken)
4509 p = extend_token_buffer (p);
4510 bzero (p, WCHAR_BYTES);
4515 if (p >= token_buffer + maxtoken)
4516 p = extend_token_buffer (p);
4521 error ("Unterminated string constant");
4523 /* We have read the entire constant.
4524 Construct a STRING_CST for the result. */
4526 if (processing_template_decl)
4527 push_obstacks (&permanent_obstack, &permanent_obstack);
4528 yylval.ttype = build_string (p - (token_buffer + 1), token_buffer + 1);
4529 if (processing_template_decl)
4533 TREE_TYPE (yylval.ttype) = wchar_array_type_node;
4535 TREE_TYPE (yylval.ttype) = char_array_type_node;
4537 value = STRING; break;
4561 yylval.code = PLUS_EXPR; break;
4563 yylval.code = MINUS_EXPR; break;
4565 yylval.code = BIT_AND_EXPR; break;
4567 yylval.code = BIT_IOR_EXPR; break;
4569 yylval.code = MULT_EXPR; break;
4571 yylval.code = TRUNC_DIV_EXPR; break;
4573 yylval.code = TRUNC_MOD_EXPR; break;
4575 yylval.code = BIT_XOR_EXPR; break;
4577 yylval.code = LSHIFT_EXPR; break;
4579 yylval.code = RSHIFT_EXPR; break;
4581 yylval.code = LT_EXPR; break;
4583 yylval.code = GT_EXPR; break;
4586 token_buffer[1] = c1 = token_getch ();
4587 token_buffer[2] = 0;
4594 value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done;
4596 value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done;
4598 value = EQCOMPARE; yylval.code = NE_EXPR; goto done;
4600 value = EQCOMPARE; yylval.code = EQ_EXPR; goto done;
4602 value = ASSIGN; goto done;
4608 value = PLUSPLUS; goto done;
4610 value = MINUSMINUS; goto done;
4612 value = ANDAND; goto done;
4614 value = OROR; goto done;
4626 else if (c1 == '?' && (c == '<' || c == '>'))
4628 token_buffer[3] = 0;
4630 c1 = token_getch ();
4631 yylval.code = (c == '<' ? MIN_EXPR : MAX_EXPR);
4634 /* <?= or >?= expression. */
4635 token_buffer[2] = c1;
4641 token_put_back (c1);
4644 pedwarn ("use of `operator %s' is not standard C++",
4654 c1 = token_getch ();
4656 value = POINTSAT_STAR;
4659 token_put_back (c1);
4669 { value = ']'; goto done; }
4673 { value = '{'; indent_level++; goto done; }
4675 { value = '['; goto done; }
4679 { value = '}'; indent_level--; goto done; }
4683 token_put_back (c1);
4684 token_buffer[1] = 0;
4686 /* Here the C frontend changes < and > to ARITHCOMPARE. We don't
4687 do that because of templates. */
4694 /* Don't make yyparse think this is eof. */
4713 /* yylloc.last_line = lineno; */
4714 #ifdef GATHER_STATISTICS
4715 #ifdef REDUCE_LENGTH
4716 token_count[value] += 1;
4727 return !!is_reserved_word (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t));
4730 #ifdef GATHER_STATISTICS
4731 /* The original for tree_node_kind is in the toplevel tree.c; changes there
4732 need to be brought into here, unless this were actually put into a header
4734 /* Statistics-gathering stuff. */
4755 extern int tree_node_counts[];
4756 extern int tree_node_sizes[];
4759 /* Place to save freed lang_decls which were allocated on the
4760 permanent_obstack. @@ Not currently used. */
4761 tree free_lang_decl_chain;
4764 build_lang_decl (code, name, type)
4765 enum tree_code code;
4769 register tree t = build_decl (code, name, type);
4770 retrofit_lang_decl (t);
4774 /* Add DECL_LANG_SPECIFIC info to T. Called from build_lang_decl
4775 and pushdecl (for functions generated by the backend). */
4778 retrofit_lang_decl (t)
4781 struct obstack *obstack = current_obstack;
4782 register int i = sizeof (struct lang_decl) / sizeof (int);
4785 if (! TREE_PERMANENT (t))
4786 obstack = saveable_obstack;
4788 /* Could be that saveable is permanent and current is not. */
4789 obstack = &permanent_obstack;
4791 if (free_lang_decl_chain && obstack == &permanent_obstack)
4793 pi = (int *)free_lang_decl_chain;
4794 free_lang_decl_chain = TREE_CHAIN (free_lang_decl_chain);
4797 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
4802 DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
4803 LANG_DECL_PERMANENT ((struct lang_decl *) pi)
4804 = obstack == &permanent_obstack;
4805 my_friendly_assert (LANG_DECL_PERMANENT ((struct lang_decl *) pi)
4806 == TREE_PERMANENT (t), 234);
4807 DECL_MAIN_VARIANT (t) = t;
4808 if (current_lang_name == lang_name_cplusplus)
4809 DECL_LANGUAGE (t) = lang_cplusplus;
4810 else if (current_lang_name == lang_name_c)
4811 DECL_LANGUAGE (t) = lang_c;
4812 else if (current_lang_name == lang_name_java)
4813 DECL_LANGUAGE (t) = lang_java;
4814 else my_friendly_abort (64);
4816 #if 0 /* not yet, should get fixed properly later */
4817 if (code == TYPE_DECL)
4820 id = get_identifier (build_overload_name (type, 1, 1));
4821 DECL_ASSEMBLER_NAME (t) = id;
4825 #ifdef GATHER_STATISTICS
4826 tree_node_counts[(int)lang_decl] += 1;
4827 tree_node_sizes[(int)lang_decl] += sizeof (struct lang_decl);
4832 build_lang_field_decl (code, name, type)
4833 enum tree_code code;
4837 extern struct obstack *current_obstack, *saveable_obstack;
4838 register tree t = build_decl (code, name, type);
4839 struct obstack *obstack = current_obstack;
4840 register int i = sizeof (struct lang_decl_flags) / sizeof (int);
4842 #if 0 /* not yet, should get fixed properly later */
4844 if (code == TYPE_DECL)
4847 id = get_identifier (build_overload_name (type, 1, 1));
4848 DECL_ASSEMBLER_NAME (t) = id;
4852 if (! TREE_PERMANENT (t))
4853 obstack = saveable_obstack;
4855 my_friendly_assert (obstack == &permanent_obstack, 235);
4857 pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl_flags));
4861 DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
4866 copy_lang_decl (node)
4872 if (! DECL_LANG_SPECIFIC (node))
4875 if (TREE_CODE (node) == FIELD_DECL)
4876 size = sizeof (struct lang_decl_flags);
4878 size = sizeof (struct lang_decl);
4879 pi = (int *)obstack_alloc (&permanent_obstack, size);
4880 bcopy ((char *)DECL_LANG_SPECIFIC (node), (char *)pi, size);
4881 DECL_LANG_SPECIFIC (node) = (struct lang_decl *)pi;
4885 make_lang_type (code)
4886 enum tree_code code;
4888 extern struct obstack *current_obstack, *saveable_obstack;
4889 register tree t = make_node (code);
4891 /* Set up some flags that give proper default behavior. */
4892 if (IS_AGGR_TYPE_CODE (code))
4894 struct obstack *obstack = current_obstack;
4895 struct lang_type *pi;
4897 SET_IS_AGGR_TYPE (t, 1);
4899 if (! TREE_PERMANENT (t))
4900 obstack = saveable_obstack;
4902 my_friendly_assert (obstack == &permanent_obstack, 236);
4904 pi = (struct lang_type *) obstack_alloc (obstack, sizeof (struct lang_type));
4905 bzero ((char *) pi, (int) sizeof (struct lang_type));
4907 TYPE_LANG_SPECIFIC (t) = pi;
4908 SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, interface_unknown);
4909 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
4911 /* Make sure this is laid out, for ease of use later. In the
4912 presence of parse errors, the normal was of assuring this
4913 might not ever get executed, so we lay it out *immediately*. */
4914 build_pointer_type (t);
4916 #ifdef GATHER_STATISTICS
4917 tree_node_counts[(int)lang_type] += 1;
4918 tree_node_sizes[(int)lang_type] += sizeof (struct lang_type);
4922 /* We use TYPE_ALIAS_SET for the CLASSTYPE_MARKED bits. But,
4923 TYPE_ALIAS_SET is initialized to -1 by default, so we must
4925 TYPE_ALIAS_SET (t) = 0;
4927 /* We need to allocate a TYPE_BINFO even for TEMPALTE_TYPE_PARMs
4928 since they can be virtual base types, and we then need a
4929 canonical binfo for them. Ideally, this would be done lazily for
4931 if (IS_AGGR_TYPE_CODE (code) || code == TEMPLATE_TYPE_PARM)
4932 TYPE_BINFO (t) = make_binfo (integer_zero_node, t, NULL_TREE, NULL_TREE);
4938 dump_time_statistics ()
4940 register tree prev = 0, decl, next;
4941 int this_time = my_get_run_time ();
4942 TREE_INT_CST_LOW (TIME_IDENTIFIER_TIME (this_filename_time))
4943 += this_time - body_time;
4945 fprintf (stderr, "\n******\n");
4946 print_time ("header files (total)", header_time);
4947 print_time ("main file (total)", this_time - body_time);
4948 fprintf (stderr, "ratio = %g : 1\n",
4949 (double)header_time / (double)(this_time - body_time));
4950 fprintf (stderr, "\n******\n");
4952 for (decl = filename_times; decl; decl = next)
4954 next = IDENTIFIER_GLOBAL_VALUE (decl);
4955 SET_IDENTIFIER_GLOBAL_VALUE (decl, prev);
4959 for (decl = prev; decl; decl = IDENTIFIER_GLOBAL_VALUE (decl))
4960 print_time (IDENTIFIER_POINTER (decl),
4961 TREE_INT_CST_LOW (TIME_IDENTIFIER_TIME (decl)));
4965 compiler_error VPROTO ((const char *msg, ...))
4967 #ifndef ANSI_PROTOTYPES
4975 #ifndef ANSI_PROTOTYPES
4976 msg = va_arg (ap, const char *);
4979 vsprintf (buf, msg, ap);
4980 error_with_file_and_line (input_filename, lineno, "%s (compiler error)", buf);
4983 /* Return the type-qualifier corresponding to the identifier given by
4987 cp_type_qual_from_rid (rid)
4990 if (rid == ridpointers[(int) RID_CONST])
4991 return TYPE_QUAL_CONST;
4992 else if (rid == ridpointers[(int) RID_VOLATILE])
4993 return TYPE_QUAL_VOLATILE;
4994 else if (rid == ridpointers[(int) RID_RESTRICT])
4995 return TYPE_QUAL_RESTRICT;
4997 my_friendly_abort (0);
4998 return TYPE_UNQUALIFIED;