1 /* Separate lexical analyzer for GNU C++.
2 Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000 Free Software Foundation, Inc.
4 Hacked by Michael Tiemann (tiemann@cygnus.com)
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
24 /* This file is the lexical analyzer for GNU C++. */
26 /* Cause the `yydebug' variable to be defined. */
44 #include "diagnostic.h"
46 #ifdef MULTIBYTE_CHARS
51 #define obstack_chunk_alloc xmalloc
52 #define obstack_chunk_free free
54 extern void yyprint
PARAMS ((FILE *, int, YYSTYPE
));
56 static tree get_time_identifier
PARAMS ((const char *));
57 static int check_newline
PARAMS ((void));
58 static int whitespace_cr
PARAMS ((int));
59 static int skip_white_space
PARAMS ((int));
60 static void finish_defarg
PARAMS ((void));
61 static int interface_strcmp
PARAMS ((const char *));
62 static int readescape
PARAMS ((int *));
63 static char *extend_token_buffer
PARAMS ((const char *));
64 static void consume_string
PARAMS ((struct obstack
*, int));
65 static void feed_defarg
PARAMS ((tree
, tree
));
66 static void store_pending_inline
PARAMS ((tree
, struct pending_inline
*));
67 static void reinit_parse_for_expr
PARAMS ((struct obstack
*));
68 static int *init_cpp_parse
PARAMS ((void));
69 static void cp_pragma_interface
PARAMS ((const char *));
70 static void cp_pragma_implementation
PARAMS ((const char *));
71 static int handle_cp_pragma
PARAMS ((const char *));
72 #ifdef HANDLE_GENERIC_PRAGMAS
73 static int handle_generic_pragma
PARAMS ((int));
75 #ifdef GATHER_STATISTICS
77 static int reduce_cmp
PARAMS ((int *, int *));
78 static int token_cmp
PARAMS ((int *, int *));
81 static void begin_definition_of_inclass_inline
PARAMS ((struct pending_inline
*));
82 static void parse_float
PARAMS ((PTR
));
83 static int is_global
PARAMS ((tree
));
84 static void init_filename_times
PARAMS ((void));
85 static void extend_token_buffer_to
PARAMS ((int));
87 static int pragma_getc
PARAMS ((void));
88 static void pragma_ungetc
PARAMS ((int));
90 static int read_line_number
PARAMS ((int *));
91 static int token_getch
PARAMS ((void));
92 static void token_put_back
PARAMS ((int));
93 static void mark_impl_file_chain
PARAMS ((void *));
94 static int read_ucs
PARAMS ((int));
95 static int is_extended_char
PARAMS ((int));
96 static int is_extended_char_1
PARAMS ((int));
97 static void init_operators
PARAMS ((void));
99 /* Given a file name X, return the nondirectory portion.
100 Keep in mind that X can be computed more than once. */
102 file_name_nondirectory (x
)
105 char *tmp
= (char *) rindex (x
, '/');
106 if (DIR_SEPARATOR
!= '/' && ! tmp
)
107 tmp
= (char *) rindex (x
, DIR_SEPARATOR
);
109 return (char *) (tmp
+ 1);
114 /* This obstack is needed to hold text. It is not safe to use
115 TOKEN_BUFFER because `check_newline' calls `yylex'. */
116 struct obstack inline_text_obstack
;
117 char *inline_text_firstobj
;
119 /* Nonzero if parse output is being saved to an obstack for later parsing. */
120 static int saving_parse_to_obstack
= 0;
124 extern cpp_reader parse_in
;
125 extern cpp_options parse_options
;
126 extern unsigned char *yy_cur
, *yy_lim
;
127 extern enum cpp_token cpp_token
;
135 /* Pending language change.
136 Positive is push count, negative is pop count. */
137 int pending_lang_change
= 0;
139 /* Wrap the current header file in extern "C". */
140 static int c_header_level
= 0;
142 extern int first_token
;
143 extern struct obstack token_obstack
;
145 /* ??? Don't really know where this goes yet. */
149 extern int yychar
; /* the lookahead symbol */
150 extern YYSTYPE yylval
; /* the semantic value of the */
151 /* lookahead symbol */
154 YYLTYPE yylloc
; /* location data for the lookahead */
159 /* the declaration found for the last IDENTIFIER token read in.
160 yylex must look this up to detect typedefs, which get token type TYPENAME,
161 so it is left around in case the identifier is not a typedef but is
162 used in a context which makes it a reference to a variable. */
165 /* The elements of `ridpointers' are identifier nodes
166 for the reserved type names and storage classes.
167 It is indexed by a RID_... value. */
168 tree ridpointers
[(int) RID_MAX
];
170 /* We may keep statistics about how long which files took to compile. */
171 static int header_time
, body_time
;
172 static tree filename_times
;
173 static tree this_filename_time
;
175 /* Array for holding counts of the numbers of tokens seen. */
176 extern int *token_count
;
178 /* When we see a default argument in a method declaration, we snarf it as
179 text using snarf_defarg. When we get up to namespace scope, we then go
180 through and parse all of them using do_pending_defargs. Since yacc
181 parsers are not reentrant, we retain defargs state in these two
182 variables so that subsequent calls to do_pending_defargs can resume
183 where the previous call left off. */
185 static tree defarg_fns
;
186 static tree defarg_parm
;
188 /* Functions and data structures for #pragma interface.
190 `#pragma implementation' means that the main file being compiled
191 is considered to implement (provide) the classes that appear in
192 its main body. I.e., if this is file "foo.cc", and class `bar'
193 is defined in "foo.cc", then we say that "foo.cc implements bar".
195 All main input files "implement" themselves automagically.
197 `#pragma interface' means that unless this file (of the form "foo.h"
198 is not presently being included by file "foo.cc", the
199 CLASSTYPE_INTERFACE_ONLY bit gets set. The effect is that none
200 of the vtables nor any of the inline functions defined in foo.h
203 There are cases when we want to link files such as "defs.h" and
204 "main.cc". In this case, we give "defs.h" a `#pragma interface',
205 and "main.cc" has `#pragma implementation "defs.h"'. */
210 struct impl_files
*next
;
213 static struct impl_files
*impl_file_chain
;
215 /* The string used to represent the filename of internally generated
216 tree nodes. The variable, which is dynamically allocated, should
217 be used; the macro is only used to initialize it. */
218 static char *internal_filename
;
219 #define INTERNAL_FILENAME ("<internal>")
221 /* Return something to represent absolute declarators containing a *.
222 TARGET is the absolute declarator that the * contains.
223 CV_QUALIFIERS is a list of modifiers such as const or volatile
224 to apply to the pointer type, represented as identifiers.
226 We return an INDIRECT_REF whose "contents" are TARGET
227 and whose type is the modifier list. */
230 make_pointer_declarator (cv_qualifiers
, target
)
231 tree cv_qualifiers
, target
;
233 if (target
&& TREE_CODE (target
) == IDENTIFIER_NODE
234 && ANON_AGGRNAME_P (target
))
235 error ("type name expected before `*'");
236 target
= build_parse_node (INDIRECT_REF
, target
);
237 TREE_TYPE (target
) = cv_qualifiers
;
241 /* Return something to represent absolute declarators containing a &.
242 TARGET is the absolute declarator that the & contains.
243 CV_QUALIFIERS is a list of modifiers such as const or volatile
244 to apply to the reference type, represented as identifiers.
246 We return an ADDR_EXPR whose "contents" are TARGET
247 and whose type is the modifier list. */
250 make_reference_declarator (cv_qualifiers
, target
)
251 tree cv_qualifiers
, target
;
255 if (TREE_CODE (target
) == ADDR_EXPR
)
257 error ("cannot declare references to references");
260 if (TREE_CODE (target
) == INDIRECT_REF
)
262 error ("cannot declare pointers to references");
265 if (TREE_CODE (target
) == IDENTIFIER_NODE
&& ANON_AGGRNAME_P (target
))
266 error ("type name expected before `&'");
268 target
= build_parse_node (ADDR_EXPR
, target
);
269 TREE_TYPE (target
) = cv_qualifiers
;
274 make_call_declarator (target
, parms
, cv_qualifiers
, exception_specification
)
275 tree target
, parms
, cv_qualifiers
, exception_specification
;
277 target
= build_parse_node (CALL_EXPR
, target
,
278 /* Both build_parse_node and
279 decl_tree_cons build on the
280 temp_decl_obstack. */
281 decl_tree_cons (parms
, cv_qualifiers
, NULL_TREE
),
282 /* The third operand is really RTL. We
283 shouldn't put anything there. */
285 CALL_DECLARATOR_EXCEPTION_SPEC (target
) = exception_specification
;
290 set_quals_and_spec (call_declarator
, cv_qualifiers
, exception_specification
)
291 tree call_declarator
, cv_qualifiers
, exception_specification
;
293 CALL_DECLARATOR_QUALS (call_declarator
) = cv_qualifiers
;
294 CALL_DECLARATOR_EXCEPTION_SPEC (call_declarator
) = exception_specification
;
297 int interface_only
; /* whether or not current file is only for
298 interface definitions. */
299 int interface_unknown
; /* whether or not we know this class
300 to behave according to #pragma interface. */
302 /* lexical analyzer */
304 #undef WCHAR_TYPE_SIZE
305 #define WCHAR_TYPE_SIZE TYPE_PRECISION (wchar_type_node)
307 /* Number of bytes in a wide character. */
308 #define WCHAR_BYTES (WCHAR_TYPE_SIZE / BITS_PER_UNIT)
310 static int maxtoken
; /* Current nominal length of token buffer. */
311 char *token_buffer
; /* Pointer to token buffer.
312 Actual allocated length is maxtoken + 2. */
314 static int indent_level
; /* Number of { minus number of }. */
319 /* Nonzero tells yylex to ignore \ in string constants. */
320 static int ignore_escape_flag
;
323 get_time_identifier (name
)
326 tree time_identifier
;
327 int len
= strlen (name
);
328 char *buf
= (char *) alloca (len
+ 6);
329 strcpy (buf
, "file ");
330 bcopy (name
, buf
+5, len
);
332 time_identifier
= get_identifier (buf
);
333 if (TIME_IDENTIFIER_TIME (time_identifier
) == NULL_TREE
)
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
;
341 return time_identifier
;
344 /* Table indexed by tree code giving a string containing a character
345 classifying the tree code. Possibilities are
346 t, d, s, c, r, <, 1 and 2. See cp/cp-tree.def for details. */
348 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
350 static char cplus_tree_code_type
[] = {
352 #include "cp-tree.def"
356 /* Table indexed by tree code giving number of expression
357 operands beyond the fixed part of the node structure.
358 Not used for types or decls. */
360 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
362 static int cplus_tree_code_length
[] = {
364 #include "cp-tree.def"
368 /* Names of tree components.
369 Used for printing out the tree and error messages. */
370 #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
372 static const char *cplus_tree_code_name
[] = {
374 #include "cp-tree.def"
378 /* toplev.c needs to call these. */
384 cpp_reader_init (&parse_in
);
385 parse_in
.opts
= &parse_options
;
386 cpp_options_init (&parse_options
);
387 parse_options
.cplusplus
= 1;
390 /* Default exceptions on. */
392 /* Mark as "unspecified". */
393 flag_bounds_check
= -1;
394 /* By default wrap lines at 72 characters. */
395 diagnostic_message_length_per_line
= 72;
396 /* By default, emit location information once for every
397 diagnostic message. */
398 set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE
);
404 /* If still "unspecified", make it match -fbounded-pointers. */
405 if (flag_bounds_check
< 0)
406 flag_bounds_check
= flag_bounded_pointers
;
408 /* the beginning of the file is a new line; check for # */
409 /* With luck, we discover the real source file's name from that
410 and put it in input_filename. */
411 put_back (check_newline ());
412 if (flag_gnu_xref
) GNU_xref_begin (input_filename
);
413 init_repo (input_filename
);
419 if (flag_gnu_xref
) GNU_xref_end (errorcount
+sorrycount
);
429 init_filename_times ()
431 this_filename_time
= get_time_identifier ("<top level>");
432 if (flag_detailed_statistics
)
435 body_time
= get_run_time ();
436 TREE_INT_CST_LOW (TIME_IDENTIFIER_TIME (this_filename_time
))
444 #ifdef GATHER_STATISTICS
446 reduce_count
= (int *) xcalloc (sizeof (int), (REDUCE_LENGTH
+ 1));
448 token_count
= (int *) xcalloc (sizeof (int), (TOKEN_LENGTH
+ 1));
455 /* A mapping from tree codes to operator name information. */
456 operator_name_info_t operator_name_info
[(int) LAST_CPLUS_TREE_CODE
];
457 /* Similar, but for assignment operators. */
458 operator_name_info_t assignment_operator_name_info
[(int) LAST_CPLUS_TREE_CODE
];
460 /* Initialize data structures that keep track of operator names. */
467 struct operator_name_info_t
*oni
;
469 #define DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, ASSN_P) \
470 my_friendly_assert ((strlen ("operator ") + strlen (NAME) + 1 \
473 sprintf (buffer, "operator %s", NAME); \
474 identifier = get_identifier (buffer); \
475 IDENTIFIER_OPNAME_P (identifier) = 1; \
478 ? &assignment_operator_name_info[(int) CODE] \
479 : &operator_name_info[(int) CODE]); \
480 oni->identifier = identifier; \
482 oni->mangled_name = MANGLING;
484 #include "operators.def"
487 operator_name_info
[(int) ERROR_MARK
].identifier
488 = get_identifier ("<invalid operator>");
490 /* Handle some special cases. These operators are not defined in
491 the language, but can be produced internally. We may need them
492 for error-reporting. (Eventually, we should ensure that this
493 does not happen. Error messages involving these operators will
494 be confusing to users.) */
496 operator_name_info
[(int) INIT_EXPR
].name
497 = operator_name_info
[(int) MODIFY_EXPR
].name
;
498 operator_name_info
[(int) EXACT_DIV_EXPR
].name
= "(ceiling /)";
499 operator_name_info
[(int) CEIL_DIV_EXPR
].name
= "(ceiling /)";
500 operator_name_info
[(int) FLOOR_DIV_EXPR
].name
= "(floor /)";
501 operator_name_info
[(int) ROUND_DIV_EXPR
].name
= "(round /)";
502 operator_name_info
[(int) CEIL_MOD_EXPR
].name
= "(ceiling %)";
503 operator_name_info
[(int) FLOOR_MOD_EXPR
].name
= "(floor %)";
504 operator_name_info
[(int) ROUND_MOD_EXPR
].name
= "(round %)";
505 operator_name_info
[(int) ABS_EXPR
].name
= "abs";
506 operator_name_info
[(int) FFS_EXPR
].name
= "ffs";
507 operator_name_info
[(int) BIT_ANDTC_EXPR
].name
= "&~";
508 operator_name_info
[(int) TRUTH_AND_EXPR
].name
= "strict &&";
509 operator_name_info
[(int) TRUTH_OR_EXPR
].name
= "strict ||";
510 operator_name_info
[(int) IN_EXPR
].name
= "in";
511 operator_name_info
[(int) RANGE_EXPR
].name
= "...";
512 operator_name_info
[(int) CONVERT_EXPR
].name
= "+";
514 assignment_operator_name_info
[(int) EXACT_DIV_EXPR
].name
516 assignment_operator_name_info
[(int) CEIL_DIV_EXPR
].name
518 assignment_operator_name_info
[(int) FLOOR_DIV_EXPR
].name
520 assignment_operator_name_info
[(int) ROUND_DIV_EXPR
].name
522 assignment_operator_name_info
[(int) CEIL_MOD_EXPR
].name
524 assignment_operator_name_info
[(int) FLOOR_MOD_EXPR
].name
526 assignment_operator_name_info
[(int) ROUND_MOD_EXPR
].name
531 init_parse (filename
)
532 const char *filename
;
534 extern int flag_no_gnu_keywords
;
535 extern int flag_operator_names
;
537 #ifdef MULTIBYTE_CHARS
538 /* Change to the native locale for multibyte conversions. */
539 setlocale (LC_CTYPE
, "");
540 literal_codeset
= getenv ("LANG");
544 /* Open input file. */
545 if (filename
== 0 || !strcmp (filename
, "-"))
551 finput
= fopen (filename
, "r");
553 pfatal_with_name (filename
);
555 #ifdef IO_BUFFER_SIZE
556 setvbuf (finput
, (char *) xmalloc (IO_BUFFER_SIZE
), _IOFBF
, IO_BUFFER_SIZE
);
558 #else /* !USE_CPPLIB */
559 parse_in
.show_column
= 1;
560 if (! cpp_start_read (&parse_in
, filename
))
563 if (filename
== 0 || !strcmp (filename
, "-"))
566 /* cpp_start_read always puts at least one line directive into the
567 token buffer. We must arrange to read it out here. */
568 yy_cur
= parse_in
.token_buffer
;
569 yy_lim
= CPP_PWRITTEN (&parse_in
);
570 cpp_token
= CPP_DIRECTIVE
;
572 #endif /* !USE_CPPLIB */
574 /* Initialize the lookahead machinery. */
577 /* Make identifier nodes long enough for the language-specific slots. */
578 set_identifier_size (sizeof (struct lang_identifier
));
579 decl_printable_name
= lang_printable_name
;
582 init_cplus_expand ();
584 memcpy (tree_code_type
+ (int) LAST_AND_UNUSED_TREE_CODE
,
585 cplus_tree_code_type
,
586 (int)LAST_CPLUS_TREE_CODE
- (int)LAST_AND_UNUSED_TREE_CODE
);
587 memcpy (tree_code_length
+ (int) LAST_AND_UNUSED_TREE_CODE
,
588 cplus_tree_code_length
,
589 (LAST_CPLUS_TREE_CODE
- (int)LAST_AND_UNUSED_TREE_CODE
) * sizeof (int));
590 memcpy (tree_code_name
+ (int) LAST_AND_UNUSED_TREE_CODE
,
591 cplus_tree_code_name
,
592 (LAST_CPLUS_TREE_CODE
- (int)LAST_AND_UNUSED_TREE_CODE
) * sizeof (char *));
597 gcc_obstack_init (&inline_text_obstack
);
598 inline_text_firstobj
= (char *) obstack_alloc (&inline_text_obstack
, 0);
600 internal_filename
= ggc_alloc_string (INTERNAL_FILENAME
,
601 sizeof (INTERNAL_FILENAME
));
603 /* Start it at 0, because check_newline is called at the very beginning
604 and will increment it to 1. */
606 input_filename
= internal_filename
;
607 current_function_decl
= NULL
;
610 token_buffer
= (char *) xmalloc (maxtoken
+ 2);
612 ridpointers
[(int) RID_INT
] = get_identifier ("int");
613 ridpointers
[(int) RID_BOOL
] = get_identifier ("bool");
614 ridpointers
[(int) RID_CHAR
] = get_identifier ("char");
615 ridpointers
[(int) RID_VOID
] = get_identifier ("void");
616 ridpointers
[(int) RID_FLOAT
] = get_identifier ("float");
617 ridpointers
[(int) RID_DOUBLE
] = get_identifier ("double");
618 ridpointers
[(int) RID_SHORT
] = get_identifier ("short");
619 ridpointers
[(int) RID_LONG
] = get_identifier ("long");
620 ridpointers
[(int) RID_UNSIGNED
] = get_identifier ("unsigned");
621 ridpointers
[(int) RID_SIGNED
] = get_identifier ("signed");
622 ridpointers
[(int) RID_INLINE
] = get_identifier ("inline");
623 ridpointers
[(int) RID_CONST
] = get_identifier ("const");
624 ridpointers
[(int) RID_RESTRICT
] = get_identifier ("__restrict");
625 ridpointers
[(int) RID_VOLATILE
] = get_identifier ("volatile");
626 ridpointers
[(int) RID_AUTO
] = get_identifier ("auto");
627 ridpointers
[(int) RID_STATIC
] = get_identifier ("static");
628 ridpointers
[(int) RID_EXTERN
] = get_identifier ("extern");
629 ridpointers
[(int) RID_TYPEDEF
] = get_identifier ("typedef");
630 ridpointers
[(int) RID_REGISTER
] = get_identifier ("register");
631 ridpointers
[(int) RID_COMPLEX
] = get_identifier ("__complex");
633 /* C++ extensions. These are probably not correctly named. */
634 ridpointers
[(int) RID_WCHAR
] = get_identifier ("__wchar_t");
635 class_type_node
= build_int_2 (class_type
, 0);
636 TREE_TYPE (class_type_node
) = class_type_node
;
637 ridpointers
[(int) RID_CLASS
] = class_type_node
;
639 record_type_node
= build_int_2 (record_type
, 0);
640 TREE_TYPE (record_type_node
) = record_type_node
;
641 ridpointers
[(int) RID_RECORD
] = record_type_node
;
643 union_type_node
= build_int_2 (union_type
, 0);
644 TREE_TYPE (union_type_node
) = union_type_node
;
645 ridpointers
[(int) RID_UNION
] = union_type_node
;
647 enum_type_node
= build_int_2 (enum_type
, 0);
648 TREE_TYPE (enum_type_node
) = enum_type_node
;
649 ridpointers
[(int) RID_ENUM
] = enum_type_node
;
651 ridpointers
[(int) RID_VIRTUAL
] = get_identifier ("virtual");
652 ridpointers
[(int) RID_EXPLICIT
] = get_identifier ("explicit");
653 ridpointers
[(int) RID_EXPORT
] = get_identifier ("export");
654 ridpointers
[(int) RID_FRIEND
] = get_identifier ("friend");
656 ridpointers
[(int) RID_PUBLIC
] = get_identifier ("public");
657 ridpointers
[(int) RID_PRIVATE
] = get_identifier ("private");
658 ridpointers
[(int) RID_PROTECTED
] = get_identifier ("protected");
659 ridpointers
[(int) RID_TEMPLATE
] = get_identifier ("template");
660 /* This is for ANSI C++. */
661 ridpointers
[(int) RID_MUTABLE
] = get_identifier ("mutable");
663 /* Create the built-in __null node. Note that we can't yet call for
664 type_for_size here because integer_type_node and so forth are not
665 set up. Therefore, we don't set the type of these nodes until
666 init_decl_processing. */
667 null_node
= build_int_2 (0, 0);
668 ridpointers
[RID_NULL
] = null_node
;
670 init_filename_times ();
672 /* Some options inhibit certain reserved words.
673 Clear those words out of the hash table so they won't be recognized. */
674 #define UNSET_RESERVED_WORD(STRING) \
675 do { struct resword *s = is_reserved_word (STRING, sizeof (STRING) - 1); \
676 if (s) s->name = ""; } while (0)
679 /* let's parse things, and if they use it, then give them an error. */
680 if (!flag_exceptions
)
682 UNSET_RESERVED_WORD ("throw");
683 UNSET_RESERVED_WORD ("try");
684 UNSET_RESERVED_WORD ("catch");
688 if (flag_no_asm
|| flag_no_gnu_keywords
)
689 UNSET_RESERVED_WORD ("typeof");
690 if (! flag_operator_names
)
692 /* These are new ANSI keywords that may break code. */
693 UNSET_RESERVED_WORD ("and");
694 UNSET_RESERVED_WORD ("and_eq");
695 UNSET_RESERVED_WORD ("bitand");
696 UNSET_RESERVED_WORD ("bitor");
697 UNSET_RESERVED_WORD ("compl");
698 UNSET_RESERVED_WORD ("not");
699 UNSET_RESERVED_WORD ("not_eq");
700 UNSET_RESERVED_WORD ("or");
701 UNSET_RESERVED_WORD ("or_eq");
702 UNSET_RESERVED_WORD ("xor");
703 UNSET_RESERVED_WORD ("xor_eq");
706 token_count
= init_cpp_parse ();
707 interface_unknown
= 1;
709 ggc_add_string_root (&internal_filename
, 1);
710 ggc_add_tree_root (ridpointers
, RID_MAX
);
711 ggc_add_tree_root (&defarg_fns
, 1);
712 ggc_add_tree_root (&defarg_parm
, 1);
713 ggc_add_tree_root (&this_filename_time
, 1);
714 ggc_add_tree_root (&filename_times
, 1);
715 ggc_add_root (&impl_file_chain
, 1, sizeof (impl_file_chain
),
716 mark_impl_file_chain
);
724 cpp_finish (&parse_in
);
725 errorcount
+= parse_in
.errors
;
732 reinit_parse_for_function ()
734 current_base_init_list
= NULL_TREE
;
735 current_member_init_list
= NULL_TREE
;
739 yyprint (file
, yychar
, yylval
)
752 case IDENTIFIER_DEFN
:
756 case PRE_PARSED_CLASS_DECL
:
758 if (TREE_CODE (t
) == TYPE_DECL
|| TREE_CODE (t
) == TEMPLATE_DECL
)
760 fprintf (file
, " `%s'", IDENTIFIER_POINTER (DECL_NAME (t
)));
763 my_friendly_assert (TREE_CODE (t
) == IDENTIFIER_NODE
, 224);
764 if (IDENTIFIER_POINTER (t
))
765 fprintf (file
, " `%s'", IDENTIFIER_POINTER (t
));
769 if (yylval
.ttype
== class_type_node
)
770 fprintf (file
, " `class'");
771 else if (yylval
.ttype
== record_type_node
)
772 fprintf (file
, " `struct'");
773 else if (yylval
.ttype
== union_type_node
)
774 fprintf (file
, " `union'");
775 else if (yylval
.ttype
== enum_type_node
)
776 fprintf (file
, " `enum'");
778 my_friendly_abort (80);
783 if (TREE_CODE (t
) == INTEGER_CST
)
785 #if HOST_BITS_PER_WIDE_INT == 64
786 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
789 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
796 #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT
802 TREE_INT_CST_HIGH (t
), TREE_INT_CST_LOW (t
));
807 #if defined(GATHER_STATISTICS) && defined(REDUCE_LENGTH)
808 static int *reduce_count
;
814 #define REDUCE_LENGTH (sizeof (yyr2) / sizeof (yyr2[0]))
815 #define TOKEN_LENGTH (256 + sizeof (yytname) / sizeof (yytname[0]))
818 #ifdef GATHER_STATISTICS
824 reduce_count
[yyn
] += 1;
831 return reduce_count
[*q
] - reduce_count
[*p
];
838 return token_count
[*q
] - token_count
[*p
];
844 print_parse_statistics ()
846 #ifdef GATHER_STATISTICS
850 int maxlen
= REDUCE_LENGTH
;
853 if (reduce_count
[-1] == 0)
856 if (TOKEN_LENGTH
> REDUCE_LENGTH
)
857 maxlen
= TOKEN_LENGTH
;
858 sorted
= (unsigned *) alloca (sizeof (int) * maxlen
);
860 for (i
= 0; i
< TOKEN_LENGTH
; i
++)
862 qsort (sorted
, TOKEN_LENGTH
, sizeof (int), token_cmp
);
863 for (i
= 0; i
< TOKEN_LENGTH
; i
++)
866 if (token_count
[idx
] == 0)
868 if (token_count
[idx
] < token_count
[-1])
870 fprintf (stderr
, "token %d, `%s', count = %d\n",
871 idx
, yytname
[YYTRANSLATE (idx
)], token_count
[idx
]);
873 fprintf (stderr
, "\n");
874 for (i
= 0; i
< REDUCE_LENGTH
; i
++)
876 qsort (sorted
, REDUCE_LENGTH
, sizeof (int), reduce_cmp
);
877 for (i
= 0; i
< REDUCE_LENGTH
; i
++)
880 if (reduce_count
[idx
] == 0)
882 if (reduce_count
[idx
] < reduce_count
[-1])
884 fprintf (stderr
, "rule %d, line %d, count = %d\n",
885 idx
, yyrline
[idx
], reduce_count
[idx
]);
887 fprintf (stderr
, "\n");
893 /* Sets the value of the 'yydebug' variable to VALUE.
894 This is a function so we don't have to have YYDEBUG defined
895 in order to build the compiler. */
905 warning ("YYDEBUG not defined.");
910 /* Mark ARG (which is really a struct impl_files **) for GC. */
913 mark_impl_file_chain (arg
)
916 struct impl_files
*ifs
;
918 ifs
= *(struct impl_files
**) arg
;
921 ggc_mark_string (ifs
->filename
);
926 /* Helper function to load global variables with interface
930 extract_interface_info ()
934 if (flag_alt_external_templates
)
936 tree til
= tinst_for_decl ();
939 fileinfo
= get_time_identifier (TINST_FILE (til
));
942 fileinfo
= get_time_identifier (input_filename
);
943 fileinfo
= TIME_IDENTIFIER_FILEINFO (fileinfo
);
944 interface_only
= TREE_INT_CST_LOW (fileinfo
);
945 interface_unknown
= TREE_INT_CST_HIGH (fileinfo
);
948 /* Return nonzero if S is not considered part of an
949 INTERFACE/IMPLEMENTATION pair. Otherwise, return 0. */
955 /* Set the interface/implementation bits for this scope. */
956 struct impl_files
*ifiles
;
959 for (ifiles
= impl_file_chain
; ifiles
; ifiles
= ifiles
->next
)
961 const char *t1
= ifiles
->filename
;
964 if (*s1
!= *t1
|| *s1
== 0)
967 while (*s1
== *t1
&& *s1
!= 0)
974 /* Don't get faked out by xxx.yyy.cc vs xxx.zzz.cc. */
975 if (index (s1
, '.') || index (t1
, '.'))
978 if (*s1
== '\0' || s1
[-1] != '.' || t1
[-1] != '.')
990 cp_pragma_interface (main_filename
)
991 const char *main_filename
;
994 = TIME_IDENTIFIER_FILEINFO (get_time_identifier (input_filename
));
996 if (impl_file_chain
== 0)
998 /* If this is zero at this point, then we are
999 auto-implementing. */
1000 if (main_input_filename
== 0)
1001 main_input_filename
= input_filename
;
1003 #ifdef AUTO_IMPLEMENT
1004 filename
= file_name_nondirectory (main_input_filename
);
1005 fi
= get_time_identifier (filename
);
1006 fi
= TIME_IDENTIFIER_FILEINFO (fi
);
1007 TREE_INT_CST_LOW (fi
) = 0;
1008 TREE_INT_CST_HIGH (fi
) = 1;
1011 = (struct impl_files
*) xmalloc (sizeof (struct impl_files
));
1012 impl_file_chain
->filename
= ggc_alloc_string (filename
, -1);
1013 impl_file_chain
->next
= 0;
1017 interface_only
= interface_strcmp (main_filename
);
1018 #ifdef MULTIPLE_SYMBOL_SPACES
1019 if (! interface_only
)
1020 interface_unknown
= 0;
1021 #else /* MULTIPLE_SYMBOL_SPACES */
1022 interface_unknown
= 0;
1023 #endif /* MULTIPLE_SYMBOL_SPACES */
1024 TREE_INT_CST_LOW (fileinfo
) = interface_only
;
1025 TREE_INT_CST_HIGH (fileinfo
) = interface_unknown
;
1028 /* Note that we have seen a #pragma implementation for the key MAIN_FILENAME.
1029 We used to only allow this at toplevel, but that restriction was buggy
1030 in older compilers and it seems reasonable to allow it in the headers
1031 themselves, too. It only needs to precede the matching #p interface.
1033 We don't touch interface_only or interface_unknown; the user must specify
1034 a matching #p interface for this to have any effect. */
1037 cp_pragma_implementation (main_filename
)
1038 const char *main_filename
;
1040 struct impl_files
*ifiles
= impl_file_chain
;
1041 for (; ifiles
; ifiles
= ifiles
->next
)
1043 if (! strcmp (ifiles
->filename
, main_filename
))
1048 ifiles
= (struct impl_files
*) xmalloc (sizeof (struct impl_files
));
1049 ifiles
->filename
= ggc_alloc_string (main_filename
, -1);
1050 ifiles
->next
= impl_file_chain
;
1051 impl_file_chain
= ifiles
;
1055 /* Set up the state required to correctly handle the definition of the
1056 inline function whose preparsed state has been saved in PI. */
1059 begin_definition_of_inclass_inline (pi
)
1060 struct pending_inline
* pi
;
1067 /* If this is an inline function in a local class, we must make sure
1068 that we save all pertinent information about the function
1069 surrounding the local class. */
1070 context
= decl_function_context (pi
->fndecl
);
1072 push_function_context_to (context
);
1074 feed_input (pi
->buf
, pi
->len
, pi
->filename
, pi
->lineno
);
1075 yychar
= PRE_PARSED_FUNCTION_DECL
;
1077 /* Pass back a handle to the rest of the inline functions, so that they
1078 can be processed later. */
1079 DECL_PENDING_INLINE_INFO (pi
->fndecl
) = 0;
1080 DECL_PENDING_INLINE_P (pi
->fndecl
) = 0;
1081 interface_unknown
= pi
->interface
== 1;
1082 interface_only
= pi
->interface
== 0;
1085 /* Called from the top level: if there are any pending inlines to
1086 do, set up to process them now. This function sets up the first function
1087 to be parsed; after it has been, the rule for fndef in parse.y will
1088 call process_next_inline to start working on the next one. */
1091 do_pending_inlines ()
1093 struct pending_inline
*t
;
1095 /* Oops, we're still dealing with the last batch. */
1096 if (yychar
== PRE_PARSED_FUNCTION_DECL
)
1099 /* Reverse the pending inline functions, since
1100 they were cons'd instead of appended. */
1102 struct pending_inline
*prev
= 0, *tail
;
1103 t
= pending_inlines
;
1104 pending_inlines
= 0;
1119 /* Now start processing the first inline function. */
1120 begin_definition_of_inclass_inline (t
);
1123 /* Called from the fndecl rule in the parser when the function just parsed
1124 was declared using a PRE_PARSED_FUNCTION_DECL (i.e. came from
1125 do_pending_inlines). */
1128 process_next_inline (i
)
1129 struct pending_inline
*i
;
1132 context
= decl_function_context (i
->fndecl
);
1134 pop_function_context_from (context
);
1136 if (yychar
== YYEMPTY
)
1138 if (yychar
!= END_OF_SAVED_INPUT
)
1140 error ("parse error at end of saved function text");
1142 /* restore_pending_input will abort unless yychar is either
1143 END_OF_SAVED_INPUT or YYEMPTY; since we already know we're
1144 hosed, feed back YYEMPTY. */
1149 begin_definition_of_inclass_inline (i
);
1151 extract_interface_info ();
1154 /* Since inline methods can refer to text which has not yet been seen,
1155 we store the text of the method in a structure which is placed in the
1156 DECL_PENDING_INLINE_INFO field of the FUNCTION_DECL.
1157 After parsing the body of the class definition, the FUNCTION_DECL's are
1158 scanned to see which ones have this field set. Those are then digested
1161 This function's FUNCTION_DECL will have a bit set in its common so
1162 that we know to watch out for it. */
1165 consume_string (this_obstack
, matching_char
)
1166 register struct obstack
*this_obstack
;
1170 int starting_lineno
;
1173 if (cpp_token
== CPP_STRING
)
1175 /* The C preprocessor will warn about newlines in strings. */
1176 obstack_grow (this_obstack
, yy_cur
, (yy_lim
- yy_cur
));
1178 lineno
= parse_in
.lineno
;
1183 starting_lineno
= lineno
;
1189 int save_lineno
= lineno
;
1190 lineno
= starting_lineno
;
1191 if (matching_char
== '"')
1192 error ("end of file encountered inside string constant");
1194 error ("end of file encountered inside character constant");
1195 lineno
= save_lineno
;
1200 obstack_1grow (this_obstack
, c
);
1202 obstack_1grow (this_obstack
, c
);
1204 /* Make sure we continue the loop */
1211 pedwarn ("ISO C++ forbids newline in string constant");
1214 obstack_1grow (this_obstack
, c
);
1216 while (c
!= matching_char
);
1219 struct pending_input
{
1222 struct obstack token_obstack
;
1226 struct pending_input
*
1227 save_pending_input ()
1229 struct pending_input
*p
;
1230 p
= (struct pending_input
*) xmalloc (sizeof (struct pending_input
));
1233 p
->eof
= end_of_file
;
1235 p
->first_token
= first_token
;
1236 p
->token_obstack
= token_obstack
;
1239 gcc_obstack_init (&token_obstack
);
1245 restore_pending_input (p
)
1246 struct pending_input
*p
;
1248 my_friendly_assert (yychar
== YYEMPTY
|| yychar
== END_OF_SAVED_INPUT
, 230);
1251 first_token
= p
->first_token
;
1252 obstack_free (&token_obstack
, (char *) 0);
1253 token_obstack
= p
->token_obstack
;
1254 end_of_file
= p
->eof
;
1258 /* Unget character CH from the input stream.
1259 If RESCAN is non-zero, then we want to `see' this
1260 character as the next input token. */
1263 yyungetc (ch
, rescan
)
1267 /* Unget a character from the input stream. */
1268 if (yychar
== YYEMPTY
|| rescan
== 0)
1270 /* If we're putting back a brace, undo the change in indent_level
1271 from the first time we saw it. */
1286 clear_inline_text_obstack ()
1288 obstack_free (&inline_text_obstack
, inline_text_firstobj
);
1291 /* This function stores away the text for an inline function that should
1292 be processed later. It decides how much later, and may need to move
1293 the info between obstacks; therefore, the caller should not refer to
1294 the T parameter after calling this function. */
1297 store_pending_inline (decl
, t
)
1299 struct pending_inline
*t
;
1302 DECL_PENDING_INLINE_INFO (decl
) = t
;
1303 DECL_PENDING_INLINE_P (decl
) = 1;
1305 /* Because we use obstacks, we must process these in precise order. */
1306 t
->next
= pending_inlines
;
1307 pending_inlines
= t
;
1311 reinit_parse_for_method (yychar
, decl
)
1316 int starting_lineno
= lineno
;
1317 const char *starting_filename
= input_filename
;
1319 reinit_parse_for_block (yychar
, &inline_text_obstack
);
1321 len
= obstack_object_size (&inline_text_obstack
);
1322 if (decl
== void_type_node
1323 || (current_class_type
&& TYPE_REDEFINED (current_class_type
)))
1325 /* Happens when we get two declarations of the same
1326 function in the same scope. */
1327 char *buf
= obstack_finish (&inline_text_obstack
);
1328 obstack_free (&inline_text_obstack
, buf
);
1333 struct pending_inline
*t
;
1334 char *buf
= obstack_finish (&inline_text_obstack
);
1336 t
= (struct pending_inline
*) obstack_alloc (&inline_text_obstack
,
1337 sizeof (struct pending_inline
));
1338 t
->lineno
= starting_lineno
;
1339 t
->filename
= starting_filename
;
1346 if (interface_unknown
&& processing_template_defn
&& flag_external_templates
&& ! DECL_IN_SYSTEM_HEADER (decl
))
1347 warn_if_unknown_interface (decl
);
1349 t
->interface
= (interface_unknown
? 1 : (interface_only
? 0 : 2));
1350 store_pending_inline (decl
, t
);
1354 /* Consume a block -- actually, a method beginning
1355 with `:' or `{' -- and save it away on the specified obstack. */
1358 reinit_parse_for_block (pyychar
, obstackp
)
1360 struct obstack
*obstackp
;
1364 int starting_lineno
= lineno
;
1365 const char *starting_filename
= input_filename
;
1367 int look_for_semicolon
= 0;
1368 int look_for_lbrac
= 0;
1372 obstack_1grow (obstackp
, '{');
1373 /* We incremented indent_level in yylex; undo that. */
1376 else if (pyychar
== '=')
1377 look_for_semicolon
= 1;
1378 else if (pyychar
== ':')
1380 obstack_1grow (obstackp
, pyychar
);
1381 /* Add a space so we don't get confused by ': ::A(20)'. */
1382 obstack_1grow (obstackp
, ' ');
1386 else if (pyychar
== RETURN_KEYWORD
)
1388 obstack_grow (obstackp
, "return", 6);
1392 else if (pyychar
== TRY
)
1394 obstack_grow (obstackp
, "try", 3);
1400 yyerror ("parse error in method specification");
1401 obstack_1grow (obstackp
, '{');
1408 int this_lineno
= lineno
;
1410 saving_parse_to_obstack
= 1;
1411 c
= skip_white_space (c
);
1412 saving_parse_to_obstack
= 0;
1414 /* Don't lose our cool if there are lots of comments. */
1415 if (lineno
== this_lineno
+ 1)
1416 obstack_1grow (obstackp
, '\n');
1417 else if (lineno
== this_lineno
)
1419 else if (lineno
- this_lineno
< 10)
1422 for (i
= lineno
- this_lineno
; i
> 0; i
--)
1423 obstack_1grow (obstackp
, '\n');
1428 sprintf (buf
, "\n# %d \"", lineno
);
1430 obstack_grow (obstackp
, buf
, len
);
1432 len
= strlen (input_filename
);
1433 obstack_grow (obstackp
, input_filename
, len
);
1434 obstack_1grow (obstackp
, '\"');
1435 obstack_1grow (obstackp
, '\n');
1438 while (c
> ' ') /* ASCII dependent... */
1440 obstack_1grow (obstackp
, c
);
1449 if (blev
== 0 && !look_for_semicolon
)
1453 if (peekyylex () == CATCH
)
1456 obstack_grow (obstackp
, " catch ", 7);
1473 /* Don't act on the next character...e.g, doing an escaped
1478 error_with_file_and_line (starting_filename
,
1480 "end of file read inside definition");
1483 obstack_1grow (obstackp
, c
);
1486 consume_string (obstackp
, c
);
1488 consume_string (obstackp
, c
);
1493 error ("function body for constructor missing");
1494 obstack_1grow (obstackp
, '{');
1495 obstack_1grow (obstackp
, '}');
1499 else if (look_for_semicolon
&& blev
== 0)
1507 error_with_file_and_line (starting_filename
,
1509 "end of file read inside definition");
1514 obstack_1grow (obstackp
, c
);
1519 obstack_1grow (obstackp
, '\0');
1522 /* Consume a no-commas expression -- actually, a default argument -- and
1523 save it away on the specified obstack. */
1526 reinit_parse_for_expr (obstackp
)
1527 struct obstack
*obstackp
;
1530 int starting_lineno
= lineno
;
1531 const char *starting_filename
= input_filename
;
1539 int this_lineno
= lineno
;
1541 saving_parse_to_obstack
= 1;
1542 c
= skip_white_space (c
);
1543 saving_parse_to_obstack
= 0;
1545 /* Don't lose our cool if there are lots of comments. */
1546 if (lineno
== this_lineno
+ 1)
1547 obstack_1grow (obstackp
, '\n');
1548 else if (lineno
== this_lineno
)
1550 else if (lineno
- this_lineno
< 10)
1553 for (i
= lineno
- this_lineno
; i
> 0; --i
)
1554 obstack_1grow (obstackp
, '\n');
1559 sprintf (buf
, "\n# %d \"", lineno
);
1561 obstack_grow (obstackp
, buf
, len
);
1563 len
= strlen (input_filename
);
1564 obstack_grow (obstackp
, input_filename
, len
);
1565 obstack_1grow (obstackp
, '\"');
1566 obstack_1grow (obstackp
, '\n');
1569 while (c
> ' ') /* ASCII dependent... */
1571 if (plev
<= 0 && (c
== ')' || c
== ','))
1576 obstack_1grow (obstackp
, c
);
1577 if (c
== '(' || c
== '[')
1579 else if (c
== ']' || c
== ')')
1583 /* Don't act on the next character...e.g, doing an escaped
1588 error_with_file_and_line (starting_filename
,
1590 "end of file read inside definition");
1593 obstack_1grow (obstackp
, c
);
1596 consume_string (obstackp
, c
);
1598 consume_string (obstackp
, c
);
1604 error_with_file_and_line (starting_filename
,
1606 "end of file read inside definition");
1611 obstack_1grow (obstackp
, c
);
1616 obstack_1grow (obstackp
, '\0');
1619 int do_snarf_defarg
;
1621 /* Decide whether the default argument we are about to see should be
1622 gobbled up as text for later parsing. */
1625 maybe_snarf_defarg ()
1627 if (current_class_type
&& TYPE_BEING_DEFINED (current_class_type
))
1628 do_snarf_defarg
= 1;
1638 reinit_parse_for_expr (&inline_text_obstack
);
1639 len
= obstack_object_size (&inline_text_obstack
);
1640 buf
= obstack_finish (&inline_text_obstack
);
1642 arg
= make_node (DEFAULT_ARG
);
1643 DEFARG_LENGTH (arg
) = len
- 1;
1644 DEFARG_POINTER (arg
) = buf
;
1649 /* Called from grokfndecl to note a function decl with unparsed default
1650 arguments for later processing. Also called from grokdeclarator
1651 for function types with unparsed defargs; the call from grokfndecl
1652 will always come second, so we can overwrite the entry from the type. */
1655 add_defarg_fn (decl
)
1658 if (TREE_CODE (decl
) == FUNCTION_DECL
)
1659 TREE_VALUE (defarg_fns
) = decl
;
1661 defarg_fns
= tree_cons (current_class_type
, decl
, defarg_fns
);
1664 /* Helper for do_pending_defargs. Starts the parsing of a default arg. */
1670 tree d
= TREE_PURPOSE (p
);
1673 if (TREE_CODE (f
) == FUNCTION_DECL
)
1675 line
= DECL_SOURCE_LINE (f
);
1676 file
= DECL_SOURCE_FILE (f
);
1681 file
= input_filename
;
1684 feed_input (DEFARG_POINTER (d
), DEFARG_LENGTH (d
), file
, line
);
1685 yychar
= DEFARG_MARKER
;
1689 /* Helper for do_pending_defargs. Ends the parsing of a default arg. */
1694 if (yychar
== YYEMPTY
)
1696 if (yychar
!= END_OF_SAVED_INPUT
)
1698 error ("parse error at end of saved function text");
1700 /* restore_pending_input will abort unless yychar is either
1701 END_OF_SAVED_INPUT or YYEMPTY; since we already know we're
1702 hosed, feed back YYEMPTY. */
1708 /* Main function for deferred parsing of default arguments. Called from
1712 do_pending_defargs ()
1717 for (; defarg_fns
; defarg_fns
= TREE_CHAIN (defarg_fns
))
1719 tree defarg_fn
= TREE_VALUE (defarg_fns
);
1720 if (defarg_parm
== NULL_TREE
)
1722 push_nested_class (TREE_PURPOSE (defarg_fns
), 1);
1724 if (TREE_CODE (defarg_fn
) == FUNCTION_DECL
)
1725 maybe_begin_member_template_processing (defarg_fn
);
1727 if (TREE_CODE (defarg_fn
) == FUNCTION_DECL
)
1731 for (p
= DECL_ARGUMENTS (defarg_fn
); p
; p
= TREE_CHAIN (p
))
1732 pushdecl (copy_node (p
));
1734 defarg_parm
= TYPE_ARG_TYPES (TREE_TYPE (defarg_fn
));
1737 defarg_parm
= TYPE_ARG_TYPES (defarg_fn
);
1740 defarg_parm
= TREE_CHAIN (defarg_parm
);
1742 for (; defarg_parm
; defarg_parm
= TREE_CHAIN (defarg_parm
))
1743 if (TREE_PURPOSE (defarg_parm
)
1744 && TREE_CODE (TREE_PURPOSE (defarg_parm
)) == DEFAULT_ARG
)
1746 feed_defarg (defarg_fn
, defarg_parm
);
1748 /* Return to the parser, which will process this defarg
1749 and call us again. */
1753 if (TREE_CODE (defarg_fn
) == FUNCTION_DECL
)
1755 maybe_end_member_template_processing ();
1756 check_default_args (defarg_fn
);
1760 pop_nested_class ();
1764 /* Heuristic to tell whether the user is missing a semicolon
1765 after a struct or enum declaration. Emit an error message
1766 if we know the user has blown it. */
1769 check_for_missing_semicolon (type
)
1777 && yychar
!= IDENTIFIER
1778 && yychar
!= TYPENAME
1779 && yychar
!= CV_QUALIFIER
1780 && yychar
!= SELFNAME
)
1783 if (ANON_AGGRNAME_P (TYPE_IDENTIFIER (type
)))
1784 error ("semicolon missing after %s declaration",
1785 TREE_CODE (type
) == ENUMERAL_TYPE
? "enum" : "struct");
1787 cp_error ("semicolon missing after declaration of `%T'", type
);
1788 shadow_tag (build_tree_list (0, type
));
1790 /* Could probably also hack cases where class { ... } f (); appears. */
1795 note_got_semicolon (type
)
1799 my_friendly_abort (60);
1800 if (CLASS_TYPE_P (type
))
1801 CLASSTYPE_GOT_SEMICOLON (type
) = 1;
1805 note_list_got_semicolon (declspecs
)
1810 for (link
= declspecs
; link
; link
= TREE_CHAIN (link
))
1812 tree type
= TREE_VALUE (link
);
1814 note_got_semicolon (type
);
1819 /* Iff C is a carriage return, warn about it - if appropriate -
1820 and return nonzero. */
1825 static int newline_warning
= 0;
1829 /* ANSI C says the effects of a carriage return in a source file
1831 if (pedantic
&& !newline_warning
)
1833 warning ("carriage return in source file (we only warn about the first carriage return)");
1834 newline_warning
= 1;
1841 /* If C is not whitespace, return C.
1842 Otherwise skip whitespace and return first nonwhite char read. */
1845 skip_white_space (c
)
1852 /* We don't recognize comments here, because
1853 cpp output can include / and * consecutively as operators.
1854 Also, there's no need, since cpp removes all comments. */
1862 c
= check_newline ();
1871 /* While processing a # directive we don't get CPP_HSPACE
1872 tokens, so we also need to handle whitespace the normal way. */
1873 if (cpp_token
== CPP_HSPACE
)
1874 c
= yy_get_token ();
1897 error ("stray '\\' in program");
1906 /* Make the token buffer longer, preserving the data in it.
1907 P should point to just beyond the last valid character in the old buffer.
1908 The value we return is a pointer to the new buffer
1909 at a place corresponding to P. */
1912 extend_token_buffer_to (size
)
1916 maxtoken
= maxtoken
* 2 + 10;
1917 while (maxtoken
< size
);
1918 token_buffer
= (char *) xrealloc (token_buffer
, maxtoken
+ 2);
1922 extend_token_buffer (p
)
1925 int offset
= p
- token_buffer
;
1926 extend_token_buffer_to (offset
);
1927 return token_buffer
+ offset
;
1930 #if defined HANDLE_PRAGMA
1931 /* Local versions of these macros, that can be passed as function pointers. */
1947 read_line_number (num
)
1950 register int token
= real_yylex ();
1952 if (token
== CONSTANT
1953 && TREE_CODE (yylval
.ttype
) == INTEGER_CST
)
1955 *num
= TREE_INT_CST_LOW (yylval
.ttype
);
1960 if (token
!= END_OF_LINE
)
1961 error ("invalid #-line");
1966 /* At the beginning of a line, increment the line number
1967 and process any #-directive on this line.
1968 If the line is a #-directive, read the entire line and return a newline.
1969 Otherwise, return the line's first non-whitespace character.
1971 Note that in the case of USE_CPPLIB, we get the whole line as one
1972 CPP_DIRECTIVE token. */
1980 enum { act_none
, act_push
, act_pop
} action
;
1981 int action_number
, l
;
1982 int entering_c_header
;
1986 /* Read first nonwhite char on the line. Do this before incrementing the
1987 line number, in case we're at the end of saved text. */
1991 /* In some cases where we're leaving an include file, we can get multiple
1992 CPP_HSPACE tokens in a row, so we need to loop. */
1993 while (cpp_token
== CPP_HSPACE
)
1994 c
= yy_get_token ();
1998 while (c
== ' ' || c
== '\t');
2005 /* Sequences of multiple newlines are very common; optimize them. */
2009 /* If not #, return it so caller will use it. */
2013 /* Don't read beyond this line. */
2018 if (cpp_token
== CPP_VSPACE
)
2020 /* Format is "<space> <line number> <filename> <newline>".
2021 Only the line number is interesting, and even that
2022 we can get more efficiently than scanning the line. */
2023 yy_cur
= yy_lim
- 1;
2024 lineno
= parse_in
.lineno
- 1;
2029 token
= real_yylex ();
2031 if (token
== IDENTIFIER
)
2033 /* If a letter follows, then if the word here is `line', skip
2034 it and ignore it; otherwise, ignore the line, with an error
2035 if the word isn't `pragma'. */
2037 const char *name
= IDENTIFIER_POINTER (yylval
.ttype
);
2039 if (!strcmp (name
, "pragma"))
2041 token
= real_yylex ();
2042 if (token
!= IDENTIFIER
2043 || TREE_CODE (yylval
.ttype
) != IDENTIFIER_NODE
)
2046 /* If this is 1, we handled it; if it's -1, it was one we
2047 wanted but had something wrong with it. Only if it's
2048 0 was it not handled. */
2049 if (handle_cp_pragma (IDENTIFIER_POINTER (yylval
.ttype
)))
2052 #ifdef HANDLE_PRAGMA
2053 /* We invoke HANDLE_PRAGMA before HANDLE_GENERIC_PRAGMAS
2054 (if both are defined), in order to give the back
2055 end a chance to override the interpretation of
2056 SYSV style pragmas. */
2057 if (HANDLE_PRAGMA (pragma_getc
, pragma_ungetc
,
2058 IDENTIFIER_POINTER (yylval
.ttype
)))
2060 #endif /* HANDLE_PRAGMA */
2062 #ifdef HANDLE_GENERIC_PRAGMAS
2063 if (handle_generic_pragma (token
))
2065 #endif /* HANDLE_GENERIC_PRAGMAS */
2067 /* Issue a warning message if we have been asked to do so.
2068 Ignoring unknown pragmas in system header file unless
2069 an explcit -Wunknown-pragmas has been given. */
2070 if (warn_unknown_pragmas
> 1
2071 || (warn_unknown_pragmas
&& ! in_system_header
))
2072 warning ("ignoring pragma: %s", token_buffer
);
2076 else if (!strcmp (name
, "define"))
2078 debug_define (lineno
, GET_DIRECTIVE_LINE ());
2081 else if (!strcmp (name
, "undef"))
2083 debug_undef (lineno
, GET_DIRECTIVE_LINE ());
2086 else if (!strcmp (name
, "line"))
2089 token
= real_yylex ();
2092 else if (!strcmp (name
, "ident"))
2094 /* #ident. The pedantic warning is now in cpp. */
2096 /* Here we have just seen `#ident '.
2097 A string constant should follow. */
2099 token
= real_yylex ();
2100 if (token
== END_OF_LINE
)
2103 || TREE_CODE (yylval
.ttype
) != STRING_CST
)
2105 error ("invalid #ident");
2109 if (! flag_no_ident
)
2111 #ifdef ASM_OUTPUT_IDENT
2112 ASM_OUTPUT_IDENT (asm_out_file
,
2113 TREE_STRING_POINTER (yylval
.ttype
));
2117 /* Skip the rest of this line. */
2121 error ("undefined or invalid # directive `%s'", name
);
2125 /* If the # is the only nonwhite char on the line,
2126 just ignore it. Check the new newline. */
2127 if (token
== END_OF_LINE
)
2131 /* Here we have either `#line' or `# <nonletter>'.
2132 In either case, it should be a line number; a digit should follow. */
2134 if (token
!= CONSTANT
2135 || TREE_CODE (yylval
.ttype
) != INTEGER_CST
)
2137 error ("invalid #-line");
2141 /* subtract one, because it is the following line that
2142 gets the specified number */
2144 l
= TREE_INT_CST_LOW (yylval
.ttype
) - 1;
2146 /* More follows: it must be a string constant (filename).
2147 It would be neat to use cpplib to quickly process the string, but
2148 (1) we don't have a handy tokenization of the string, and
2149 (2) I don't know how well that would work in the presense
2150 of filenames that contain wide characters. */
2152 if (saw_line
|| saving_parse_to_obstack
)
2154 /* Don't treat \ as special if we are processing #line 1 "...".
2155 If you want it to be treated specially, use # 1 "...". Also
2156 ignore these if saving to an obstack for later parsing. */
2157 ignore_escape_flag
= 1;
2160 /* Read the string constant. */
2161 token
= real_yylex ();
2163 ignore_escape_flag
= 0;
2165 if (token
== END_OF_LINE
)
2167 /* No more: store the line number and check following line. */
2172 if (token
!= STRING
|| TREE_CODE (yylval
.ttype
) != STRING_CST
)
2174 error ("invalid #line");
2178 /* Changing files again. This means currently collected time
2179 is charged against header time, and body time starts back at 0. */
2180 if (flag_detailed_statistics
)
2182 int this_time
= get_run_time ();
2183 tree time_identifier
= get_time_identifier (TREE_STRING_POINTER (yylval
.ttype
));
2184 header_time
+= this_time
- body_time
;
2185 TREE_INT_CST_LOW (TIME_IDENTIFIER_TIME (this_filename_time
))
2186 += this_time
- body_time
;
2187 this_filename_time
= time_identifier
;
2188 body_time
= this_time
;
2191 new_file
= TREE_STRING_POINTER (yylval
.ttype
);
2193 GNU_xref_file (new_file
);
2195 if (main_input_filename
== 0)
2197 struct impl_files
*ifiles
= impl_file_chain
;
2201 while (ifiles
->next
)
2202 ifiles
= ifiles
->next
;
2203 ifiles
->filename
= file_name_nondirectory (new_file
);
2206 main_input_filename
= new_file
;
2212 /* Each change of file name
2213 reinitializes whether we are now in a system header. */
2214 in_system_header
= 0;
2215 entering_c_header
= 0;
2217 if (!read_line_number (&action_number
) && input_file_stack
)
2219 input_file_stack
->name
= input_filename
= new_file
;
2220 input_file_stack
->line
= lineno
= l
;
2223 /* `1' after file name means entering new file.
2224 `2' after file name means just left a file. */
2226 if (action_number
== 1)
2229 read_line_number (&action_number
);
2231 else if (action_number
== 2)
2234 read_line_number (&action_number
);
2236 if (action_number
== 3)
2238 /* `3' after file name means this is a system header file. */
2239 in_system_header
= 1;
2240 read_line_number (&action_number
);
2242 if (action_number
== 4)
2244 /* `4' after file name means this is a C header file. */
2245 entering_c_header
= 1;
2246 read_line_number (&action_number
);
2249 /* Do the actions implied by the preceding numbers. */
2251 if (action
== act_push
)
2253 /* Pushing to a new file. */
2254 push_srcloc (new_file
, l
);
2255 input_file_stack
->indent_level
= indent_level
;
2256 debug_start_source_file (input_filename
);
2259 else if (entering_c_header
)
2262 ++pending_lang_change
;
2265 else if (action
== act_pop
)
2267 /* Popping out of a file. */
2268 if (input_file_stack
->next
)
2270 if (c_header_level
&& --c_header_level
== 0)
2272 if (entering_c_header
)
2273 warning ("badly nested C headers from preprocessor");
2274 --pending_lang_change
;
2277 if (indent_level
!= input_file_stack
->indent_level
)
2279 warning_with_file_and_line
2280 (input_filename
, lineno
,
2281 "This file contains more `%c's than `%c's.",
2282 indent_level
> input_file_stack
->indent_level
? '{' : '}',
2283 indent_level
> input_file_stack
->indent_level
? '}' : '{');
2287 input_file_stack
->name
= new_file
;
2288 debug_end_source_file (input_file_stack
->line
);
2291 error ("#-lines for entering and leaving files don't match");
2294 input_filename
= new_file
;
2297 extract_interface_info ();
2299 /* skip the rest of this line. */
2306 while (c
!= '\n' && c
!= EOF
);
2310 #ifdef HANDLE_GENERIC_PRAGMAS
2312 /* Handle a #pragma directive.
2313 TOKEN is the token we read after `#pragma'. Processes the entire input
2314 line and return non-zero iff the pragma has been successfully parsed. */
2316 /* This function has to be in this file, in order to get at
2320 handle_generic_pragma (token
)
2331 handle_pragma_token (token_buffer
, yylval
.ttype
);
2335 handle_pragma_token ("(", NULL_TREE
);
2336 handle_pragma_token (")", NULL_TREE
);
2340 return handle_pragma_token (NULL_PTR
, NULL_TREE
);
2343 handle_pragma_token (token_buffer
, NULL_TREE
);
2346 token
= real_yylex ();
2349 #endif /* HANDLE_GENERIC_PRAGMAS */
2352 handle_cp_pragma (pname
)
2357 if (! strcmp (pname
, "vtable"))
2359 /* More follows: it must be a string constant (class name). */
2360 token
= real_yylex ();
2361 if (token
!= STRING
|| TREE_CODE (yylval
.ttype
) != STRING_CST
)
2363 error ("invalid #pragma vtable");
2368 = tree_cons (NULL_TREE
,
2369 get_identifier (TREE_STRING_POINTER (yylval
.ttype
)),
2371 token
= real_yylex ();
2372 if (token
!= END_OF_LINE
)
2373 warning ("trailing characters ignored");
2376 else if (! strcmp (pname
, "unit"))
2378 /* More follows: it must be a string constant (unit name). */
2379 token
= real_yylex ();
2380 if (token
!= STRING
|| TREE_CODE (yylval
.ttype
) != STRING_CST
)
2382 error ("invalid #pragma unit");
2385 token
= real_yylex ();
2386 if (token
!= END_OF_LINE
)
2387 warning ("trailing characters ignored");
2390 else if (! strcmp (pname
, "interface"))
2392 const char *main_filename
= input_filename
;
2394 main_filename
= file_name_nondirectory (main_filename
);
2396 token
= real_yylex ();
2398 if (token
!= END_OF_LINE
)
2401 || TREE_CODE (yylval
.ttype
) != STRING_CST
)
2403 error ("invalid `#pragma interface'");
2406 main_filename
= TREE_STRING_POINTER (yylval
.ttype
);
2407 token
= real_yylex ();
2410 if (token
!= END_OF_LINE
)
2411 warning ("garbage after `#pragma interface' ignored");
2413 cp_pragma_interface (main_filename
);
2417 else if (! strcmp (pname
, "implementation"))
2419 const char *main_filename
= main_input_filename
? main_input_filename
: input_filename
;
2421 main_filename
= file_name_nondirectory (main_filename
);
2423 token
= real_yylex ();
2425 if (token
!= END_OF_LINE
)
2428 || TREE_CODE (yylval
.ttype
) != STRING_CST
)
2430 error ("invalid `#pragma implementation'");
2433 main_filename
= TREE_STRING_POINTER (yylval
.ttype
);
2434 token
= real_yylex ();
2437 if (token
!= END_OF_LINE
)
2438 warning ("garbage after `#pragma implementation' ignored");
2440 cp_pragma_implementation (main_filename
);
2449 do_pending_lang_change ()
2451 for (; pending_lang_change
> 0; --pending_lang_change
)
2452 push_lang_context (lang_name_c
);
2453 for (; pending_lang_change
< 0; ++pending_lang_change
)
2454 pop_lang_context ();
2457 /* Parse a '\uNNNN' or '\UNNNNNNNN' sequence.
2459 [lex.charset]: The character designated by the universal-character-name
2460 \UNNNNNNNN is that character whose character short name in ISO/IEC 10646
2461 is NNNNNNNN; the character designated by the universal-character-name
2462 \uNNNN is that character whose character short name in ISO/IEC 10646 is
2463 0000NNNN. If the hexadecimal value for a universal character name is
2464 less than 0x20 or in the range 0x7F-0x9F (inclusive), or if the
2465 universal character name designates a character in the basic source
2466 character set, then the program is ill-formed.
2468 We assume that wchar_t is Unicode, so we don't need to do any
2469 mapping. Is this ever wrong? */
2475 unsigned int code
= 0;
2478 for (; length
; --length
)
2483 error ("non hex digit '%c' in universal-character-name", c
);
2488 if (c
>= 'a' && c
<= 'f')
2489 code
+= c
- 'a' + 10;
2490 if (c
>= 'A' && c
<= 'F')
2491 code
+= c
- 'A' + 10;
2492 if (c
>= '0' && c
<= '9')
2496 #ifdef TARGET_EBCDIC
2497 sorry ("universal-character-name on EBCDIC target");
2501 if (code
> 0x9f && !(code
& 0x80000000))
2502 /* True extended character, OK. */;
2503 else if (code
>= 0x20 && code
< 0x7f)
2505 /* ASCII printable character. The C character set consists of all of
2506 these except $, @ and `. We use hex escapes so that this also
2507 works with EBCDIC hosts. */
2508 if (code
!= 0x24 && code
!= 0x40 && code
!= 0x60)
2509 error ("universal-character-name designates `%c', part of the basic source character set", code
);
2512 error ("invalid universal-character-name");
2516 /* Returns nonzero if C is a universal-character-name. Give an error if it
2517 is not one which may appear in an identifier, as per [extendid]. */
2520 is_extended_char (c
)
2523 #ifdef TARGET_EBCDIC
2530 return is_extended_char_1 (c
);
2535 is_extended_char_1 (c
)
2538 /* None of the valid chars are outside the Basic Multilingual Plane (the
2542 error ("universal-character-name `\\U%08x' not valid in identifier", c
);
2547 if ((c
>= 0x00c0 && c
<= 0x00d6)
2548 || (c
>= 0x00d8 && c
<= 0x00f6)
2549 || (c
>= 0x00f8 && c
<= 0x01f5)
2550 || (c
>= 0x01fa && c
<= 0x0217)
2551 || (c
>= 0x0250 && c
<= 0x02a8)
2552 || (c
>= 0x1e00 && c
<= 0x1e9a)
2553 || (c
>= 0x1ea0 && c
<= 0x1ef9))
2558 || (c
>= 0x0388 && c
<= 0x038a)
2560 || (c
>= 0x038e && c
<= 0x03a1)
2561 || (c
>= 0x03a3 && c
<= 0x03ce)
2562 || (c
>= 0x03d0 && c
<= 0x03d6)
2567 || (c
>= 0x03e2 && c
<= 0x03f3)
2568 || (c
>= 0x1f00 && c
<= 0x1f15)
2569 || (c
>= 0x1f18 && c
<= 0x1f1d)
2570 || (c
>= 0x1f20 && c
<= 0x1f45)
2571 || (c
>= 0x1f48 && c
<= 0x1f4d)
2572 || (c
>= 0x1f50 && c
<= 0x1f57)
2576 || (c
>= 0x1f5f && c
<= 0x1f7d)
2577 || (c
>= 0x1f80 && c
<= 0x1fb4)
2578 || (c
>= 0x1fb6 && c
<= 0x1fbc)
2579 || (c
>= 0x1fc2 && c
<= 0x1fc4)
2580 || (c
>= 0x1fc6 && c
<= 0x1fcc)
2581 || (c
>= 0x1fd0 && c
<= 0x1fd3)
2582 || (c
>= 0x1fd6 && c
<= 0x1fdb)
2583 || (c
>= 0x1fe0 && c
<= 0x1fec)
2584 || (c
>= 0x1ff2 && c
<= 0x1ff4)
2585 || (c
>= 0x1ff6 && c
<= 0x1ffc))
2589 if ((c
>= 0x0401 && c
<= 0x040d)
2590 || (c
>= 0x040f && c
<= 0x044f)
2591 || (c
>= 0x0451 && c
<= 0x045c)
2592 || (c
>= 0x045e && c
<= 0x0481)
2593 || (c
>= 0x0490 && c
<= 0x04c4)
2594 || (c
>= 0x04c7 && c
<= 0x04c8)
2595 || (c
>= 0x04cb && c
<= 0x04cc)
2596 || (c
>= 0x04d0 && c
<= 0x04eb)
2597 || (c
>= 0x04ee && c
<= 0x04f5)
2598 || (c
>= 0x04f8 && c
<= 0x04f9))
2602 if ((c
>= 0x0531 && c
<= 0x0556)
2603 || (c
>= 0x0561 && c
<= 0x0587))
2607 if ((c
>= 0x05d0 && c
<= 0x05ea)
2608 || (c
>= 0x05f0 && c
<= 0x05f4))
2612 if ((c
>= 0x0621 && c
<= 0x063a)
2613 || (c
>= 0x0640 && c
<= 0x0652)
2614 || (c
>= 0x0670 && c
<= 0x06b7)
2615 || (c
>= 0x06ba && c
<= 0x06be)
2616 || (c
>= 0x06c0 && c
<= 0x06ce)
2617 || (c
>= 0x06e5 && c
<= 0x06e7))
2621 if ((c
>= 0x0905 && c
<= 0x0939)
2622 || (c
>= 0x0958 && c
<= 0x0962))
2626 if ((c
>= 0x0985 && c
<= 0x098c)
2627 || (c
>= 0x098f && c
<= 0x0990)
2628 || (c
>= 0x0993 && c
<= 0x09a8)
2629 || (c
>= 0x09aa && c
<= 0x09b0)
2631 || (c
>= 0x09b6 && c
<= 0x09b9)
2632 || (c
>= 0x09dc && c
<= 0x09dd)
2633 || (c
>= 0x09df && c
<= 0x09e1)
2634 || (c
>= 0x09f0 && c
<= 0x09f1))
2638 if ((c
>= 0x0a05 && c
<= 0x0a0a)
2639 || (c
>= 0x0a0f && c
<= 0x0a10)
2640 || (c
>= 0x0a13 && c
<= 0x0a28)
2641 || (c
>= 0x0a2a && c
<= 0x0a30)
2642 || (c
>= 0x0a32 && c
<= 0x0a33)
2643 || (c
>= 0x0a35 && c
<= 0x0a36)
2644 || (c
>= 0x0a38 && c
<= 0x0a39)
2645 || (c
>= 0x0a59 && c
<= 0x0a5c)
2650 if ((c
>= 0x0a85 && c
<= 0x0a8b)
2652 || (c
>= 0x0a8f && c
<= 0x0a91)
2653 || (c
>= 0x0a93 && c
<= 0x0aa8)
2654 || (c
>= 0x0aaa && c
<= 0x0ab0)
2655 || (c
>= 0x0ab2 && c
<= 0x0ab3)
2656 || (c
>= 0x0ab5 && c
<= 0x0ab9)
2661 if ((c
>= 0x0b05 && c
<= 0x0b0c)
2662 || (c
>= 0x0b0f && c
<= 0x0b10)
2663 || (c
>= 0x0b13 && c
<= 0x0b28)
2664 || (c
>= 0x0b2a && c
<= 0x0b30)
2665 || (c
>= 0x0b32 && c
<= 0x0b33)
2666 || (c
>= 0x0b36 && c
<= 0x0b39)
2667 || (c
>= 0x0b5c && c
<= 0x0b5d)
2668 || (c
>= 0x0b5f && c
<= 0x0b61))
2672 if ((c
>= 0x0b85 && c
<= 0x0b8a)
2673 || (c
>= 0x0b8e && c
<= 0x0b90)
2674 || (c
>= 0x0b92 && c
<= 0x0b95)
2675 || (c
>= 0x0b99 && c
<= 0x0b9a)
2677 || (c
>= 0x0b9e && c
<= 0x0b9f)
2678 || (c
>= 0x0ba3 && c
<= 0x0ba4)
2679 || (c
>= 0x0ba8 && c
<= 0x0baa)
2680 || (c
>= 0x0bae && c
<= 0x0bb5)
2681 || (c
>= 0x0bb7 && c
<= 0x0bb9))
2685 if ((c
>= 0x0c05 && c
<= 0x0c0c)
2686 || (c
>= 0x0c0e && c
<= 0x0c10)
2687 || (c
>= 0x0c12 && c
<= 0x0c28)
2688 || (c
>= 0x0c2a && c
<= 0x0c33)
2689 || (c
>= 0x0c35 && c
<= 0x0c39)
2690 || (c
>= 0x0c60 && c
<= 0x0c61))
2694 if ((c
>= 0x0c85 && c
<= 0x0c8c)
2695 || (c
>= 0x0c8e && c
<= 0x0c90)
2696 || (c
>= 0x0c92 && c
<= 0x0ca8)
2697 || (c
>= 0x0caa && c
<= 0x0cb3)
2698 || (c
>= 0x0cb5 && c
<= 0x0cb9)
2699 || (c
>= 0x0ce0 && c
<= 0x0ce1))
2703 if ((c
>= 0x0d05 && c
<= 0x0d0c)
2704 || (c
>= 0x0d0e && c
<= 0x0d10)
2705 || (c
>= 0x0d12 && c
<= 0x0d28)
2706 || (c
>= 0x0d2a && c
<= 0x0d39)
2707 || (c
>= 0x0d60 && c
<= 0x0d61))
2711 if ((c
>= 0x0e01 && c
<= 0x0e30)
2712 || (c
>= 0x0e32 && c
<= 0x0e33)
2713 || (c
>= 0x0e40 && c
<= 0x0e46)
2714 || (c
>= 0x0e4f && c
<= 0x0e5b))
2718 if ((c
>= 0x0e81 && c
<= 0x0e82)
2724 || (c
>= 0x0e94 && c
<= 0x0e97)
2725 || (c
>= 0x0e99 && c
<= 0x0e9f)
2726 || (c
>= 0x0ea1 && c
<= 0x0ea3)
2731 || (c
>= 0x0ead && c
<= 0x0eb0)
2735 || (c
>= 0x0ec0 && c
<= 0x0ec4)
2740 if ((c
>= 0x10a0 && c
<= 0x10c5)
2741 || (c
>= 0x10d0 && c
<= 0x10f6))
2745 if ((c
>= 0x3041 && c
<= 0x3094)
2746 || (c
>= 0x309b && c
<= 0x309e))
2750 if ((c
>= 0x30a1 && c
<= 0x30fe))
2754 if ((c
>= 0x3105 && c
<= 0x312c))
2758 if ((c
>= 0x1100 && c
<= 0x1159)
2759 || (c
>= 0x1161 && c
<= 0x11a2)
2760 || (c
>= 0x11a8 && c
<= 0x11f9))
2763 /* CJK Unified Ideographs */
2764 if ((c
>= 0xf900 && c
<= 0xfa2d)
2765 || (c
>= 0xfb1f && c
<= 0xfb36)
2766 || (c
>= 0xfb38 && c
<= 0xfb3c)
2768 || (c
>= 0xfb40 && c
<= 0xfb41)
2769 || (c
>= 0xfb42 && c
<= 0xfb44)
2770 || (c
>= 0xfb46 && c
<= 0xfbb1)
2771 || (c
>= 0xfbd3 && c
<= 0xfd3f)
2772 || (c
>= 0xfd50 && c
<= 0xfd8f)
2773 || (c
>= 0xfd92 && c
<= 0xfdc7)
2774 || (c
>= 0xfdf0 && c
<= 0xfdfb)
2775 || (c
>= 0xfe70 && c
<= 0xfe72)
2777 || (c
>= 0xfe76 && c
<= 0xfefc)
2778 || (c
>= 0xff21 && c
<= 0xff3a)
2779 || (c
>= 0xff41 && c
<= 0xff5a)
2780 || (c
>= 0xff66 && c
<= 0xffbe)
2781 || (c
>= 0xffc2 && c
<= 0xffc7)
2782 || (c
>= 0xffca && c
<= 0xffcf)
2783 || (c
>= 0xffd2 && c
<= 0xffd7)
2784 || (c
>= 0xffda && c
<= 0xffdc)
2785 || (c
>= 0x4e00 && c
<= 0x9fa5))
2788 error ("universal-character-name `\\u%04x' not valid in identifier", c
);
2793 /* Add the UTF-8 representation of C to the token_buffer. */
2796 utf8_extend_token (c
)
2801 if (c
<= 0x0000007f)
2806 else if (c
<= 0x000007ff)
2807 shift
= 6, mask
= 0xc0;
2808 else if (c
<= 0x0000ffff)
2809 shift
= 12, mask
= 0xe0;
2810 else if (c
<= 0x001fffff)
2811 shift
= 18, mask
= 0xf0;
2812 else if (c
<= 0x03ffffff)
2813 shift
= 24, mask
= 0xf8;
2815 shift
= 30, mask
= 0xfc;
2817 extend_token (mask
| (c
>> shift
));
2821 extend_token ((unsigned char) (0x80 | (c
>> shift
)));
2827 #define ENDFILE -1 /* token that represents end-of-file */
2829 /* Read an escape sequence, returning its equivalent as a character,
2830 or store 1 in *ignore_ptr if it is backslash-newline. */
2833 readescape (ignore_ptr
)
2836 register int c
= getch ();
2838 register unsigned count
;
2839 unsigned firstdig
= 0;
2857 if (c
>= 'a' && c
<= 'f')
2858 code
+= c
- 'a' + 10;
2859 if (c
>= 'A' && c
<= 'F')
2860 code
+= c
- 'A' + 10;
2861 if (c
>= '0' && c
<= '9')
2863 if (code
!= 0 || count
!= 0)
2872 error ("\\x used with no following hex digits");
2873 else if (count
== 0)
2874 /* Digits are all 0's. Ok. */
2876 else if ((count
- 1) * 4 >= TYPE_PRECISION (integer_type_node
)
2879 << (TYPE_PRECISION (integer_type_node
)
2882 pedwarn ("hex escape out of range");
2885 case '0': case '1': case '2': case '3': case '4':
2886 case '5': case '6': case '7':
2889 while ((c
<= '7') && (c
>= '0') && (count
++ < 3))
2891 code
= (code
* 8) + (c
- '0');
2898 return read_ucs (8);
2900 return read_ucs (4);
2902 case '\\': case '\'': case '"':
2911 return TARGET_NEWLINE
;
2934 pedwarn ("non-ISO-standard escape sequence, `\\%c'", c
);
2940 /* `\(', etc, are used at beginning of line to avoid confusing Emacs. */
2944 /* `\%' is used to prevent SCCS from getting confused. */
2947 pedwarn ("unknown escape sequence `\\%c'", c
);
2951 pedwarn ("unknown escape sequence `\\%c'", c
);
2953 pedwarn ("unknown escape sequence: `\\' followed by char code 0x%x", c
);
2961 extern int end_of_file
;
2963 /* We can't print string and character constants well
2964 because the token_buffer contains the result of processing escapes. */
2967 if (input_redirected ())
2968 error ("%s at end of saved text", string
);
2970 error ("%s at end of input", string
);
2972 else if (token_buffer
[0] == 0)
2973 error ("%s at null character", string
);
2974 else if (token_buffer
[0] == '"')
2975 error ("%s before string constant", string
);
2976 else if (token_buffer
[0] == '\'')
2977 error ("%s before character constant", string
);
2978 else if (!ISGRAPH ((unsigned char)token_buffer
[0]))
2979 error ("%s before character 0%o", string
, (unsigned char) token_buffer
[0]);
2981 error ("%s before `%s'", string
, token_buffer
);
2984 /* Value is 1 (or 2) if we should try to make the next identifier look like
2985 a typename (when it may be a local variable or a class variable).
2986 Value is 0 if we treat this name in a default fashion. */
2987 int looking_for_typename
;
2990 identifier_type (decl
)
2995 if (TREE_CODE (decl
) == TEMPLATE_DECL
)
2997 if (TREE_CODE (DECL_TEMPLATE_RESULT (decl
)) == TYPE_DECL
)
2999 else if (looking_for_template
)
3002 if (looking_for_template
&& really_overloaded_fn (decl
))
3004 /* See through a baselink. */
3005 if (TREE_CODE (decl
) == TREE_LIST
)
3006 decl
= TREE_VALUE (decl
);
3008 for (t
= decl
; t
!= NULL_TREE
; t
= OVL_CHAIN (t
))
3009 if (DECL_FUNCTION_TEMPLATE_P (OVL_FUNCTION (t
)))
3012 if (TREE_CODE (decl
) == NAMESPACE_DECL
)
3014 if (TREE_CODE (decl
) != TYPE_DECL
)
3016 if (DECL_ARTIFICIAL (decl
) && TREE_TYPE (decl
) == current_class_type
)
3019 /* A constructor declarator for a template type will get here as an
3020 implicit typename, a TYPENAME_TYPE with a type. */
3022 if (t
&& TREE_CODE (t
) == TYPENAME_TYPE
)
3024 decl
= TREE_TYPE (decl
);
3025 if (TREE_CODE (decl
) == TYPENAME_TYPE
)
3026 decl
= TREE_TYPE (decl
);
3036 /* Only types expected, not even namespaces. */
3037 looking_for_typename
= 2;
3039 if ((yychar
= yylex ()) < 0) yychar
= 0;
3040 looking_for_typename
= 0;
3041 if (yychar
== IDENTIFIER
)
3043 lastiddecl
= lookup_name (yylval
.ttype
, -2);
3044 if (lastiddecl
== 0)
3047 lastiddecl
= IDENTIFIER_LABEL_VALUE (yylval
.ttype
);
3050 yychar
= identifier_type (lastiddecl
);
3054 /* Return true if d is in a global scope. */
3061 switch (TREE_CODE (d
))
3066 case OVERLOAD
: d
= OVL_FUNCTION (d
); continue;
3067 case TREE_LIST
: d
= TREE_VALUE (d
); continue;
3069 my_friendly_assert (DECL_P (d
), 980629);
3071 return DECL_NAMESPACE_SCOPE_P (d
);
3076 do_identifier (token
, parsing
, args
)
3077 register tree token
;
3082 int lexing
= (parsing
== 1);
3083 int in_call
= (parsing
== 2);
3085 if (! lexing
|| IDENTIFIER_OPNAME_P (token
))
3086 id
= lookup_name (token
, 0);
3090 /* Do Koenig lookup if appropriate (inside templates we build lookup
3091 expressions instead).
3093 [basic.lookup.koenig]: If the ordinary unqualified lookup of the name
3094 finds the declaration of a class member function, the associated
3095 namespaces and classes are not considered. */
3097 if (args
&& !current_template_parms
&& (!id
|| is_global (id
)))
3098 id
= lookup_arg_dependent (token
, id
, args
);
3100 /* Remember that this name has been used in the class definition, as per
3103 maybe_note_name_used_in_class (token
, id
);
3105 if (id
== error_mark_node
)
3107 /* lookup_name quietly returns error_mark_node if we're parsing,
3108 as we don't want to complain about an identifier that ends up
3109 being used as a declarator. So we call it again to get the error
3111 id
= lookup_name (token
, 0);
3112 return error_mark_node
;
3115 if (!id
|| (TREE_CODE (id
) == FUNCTION_DECL
3116 && DECL_ANTICIPATED (id
)))
3118 if (current_template_parms
)
3119 return build_min_nt (LOOKUP_EXPR
, token
);
3120 else if (IDENTIFIER_OPNAME_P (token
))
3122 if (token
!= ansi_opname (ERROR_MARK
))
3123 cp_error ("`%D' not defined", token
);
3124 id
= error_mark_node
;
3126 else if (in_call
&& ! flag_strict_prototype
)
3129 id
= implicitly_declare (token
);
3132 /* Implicit declaration of built-in function. Don't
3133 change the built-in declaration, but don't let this
3134 go by silently, either. */
3135 cp_pedwarn ("implicit declaration of function `%D'", token
);
3136 DECL_ANTICIPATED (id
) = 0; /* only issue this warning once */
3139 else if (current_function_decl
== 0)
3141 cp_error ("`%D' was not declared in this scope", token
);
3142 id
= error_mark_node
;
3146 if (IDENTIFIER_NAMESPACE_VALUE (token
) != error_mark_node
3147 || IDENTIFIER_ERROR_LOCUS (token
) != current_function_decl
)
3149 static int undeclared_variable_notice
;
3151 cp_error ("`%D' undeclared (first use this function)", token
);
3153 if (! undeclared_variable_notice
)
3155 error ("(Each undeclared identifier is reported only once for each function it appears in.)");
3156 undeclared_variable_notice
= 1;
3159 id
= error_mark_node
;
3160 /* Prevent repeated error messages. */
3161 SET_IDENTIFIER_NAMESPACE_VALUE (token
, error_mark_node
);
3162 SET_IDENTIFIER_ERROR_LOCUS (token
, current_function_decl
);
3166 if (TREE_CODE (id
) == VAR_DECL
&& DECL_DEAD_FOR_LOCAL (id
))
3168 tree shadowed
= DECL_SHADOWED_FOR_VAR (id
);
3169 while (shadowed
!= NULL_TREE
&& TREE_CODE (shadowed
) == VAR_DECL
3170 && DECL_DEAD_FOR_LOCAL (shadowed
))
3171 shadowed
= DECL_SHADOWED_FOR_VAR (shadowed
);
3173 shadowed
= IDENTIFIER_NAMESPACE_VALUE (DECL_NAME (id
));
3176 if (!DECL_ERROR_REPORTED (id
))
3178 warning ("name lookup of `%s' changed",
3179 IDENTIFIER_POINTER (token
));
3180 cp_warning_at (" matches this `%D' under ISO standard rules",
3182 cp_warning_at (" matches this `%D' under old rules", id
);
3183 DECL_ERROR_REPORTED (id
) = 1;
3187 else if (!DECL_ERROR_REPORTED (id
))
3189 DECL_ERROR_REPORTED (id
) = 1;
3190 if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (id
)))
3192 error ("name lookup of `%s' changed for new ISO `for' scoping",
3193 IDENTIFIER_POINTER (token
));
3194 cp_error_at (" cannot use obsolete binding at `%D' because it has a destructor", id
);
3195 id
= error_mark_node
;
3199 pedwarn ("name lookup of `%s' changed for new ISO `for' scoping",
3200 IDENTIFIER_POINTER (token
));
3201 cp_pedwarn_at (" using obsolete binding at `%D'", id
);
3205 /* TREE_USED is set in `hack_identifier'. */
3206 if (TREE_CODE (id
) == CONST_DECL
)
3209 if (IDENTIFIER_CLASS_VALUE (token
) == id
)
3210 enforce_access (CP_DECL_CONTEXT(id
), id
);
3211 if (!processing_template_decl
|| DECL_TEMPLATE_PARM_P (id
))
3212 id
= DECL_INITIAL (id
);
3215 id
= hack_identifier (id
, token
);
3217 /* We must look up dependent names when the template is
3218 instantiated, not while parsing it. For now, we don't
3219 distinguish between dependent and independent names. So, for
3220 example, we look up all overloaded functions at
3221 instantiation-time, even though in some cases we should just use
3222 the DECL we have here. We also use LOOKUP_EXPRs to find things
3223 like local variables, rather than creating TEMPLATE_DECLs for the
3224 local variables and then finding matching instantiations. */
3225 if (current_template_parms
3226 && (is_overloaded_fn (id
)
3227 /* Some local VAR_DECLs (such as those for local variables
3228 in member functions of local classes) are built on the
3229 permanent obstack. */
3230 || (TREE_CODE (id
) == VAR_DECL
3231 && CP_DECL_CONTEXT (id
)
3232 && TREE_CODE (CP_DECL_CONTEXT (id
)) == FUNCTION_DECL
)
3233 || TREE_CODE (id
) == PARM_DECL
3234 || TREE_CODE (id
) == RESULT_DECL
3235 || TREE_CODE (id
) == USING_DECL
))
3236 id
= build_min_nt (LOOKUP_EXPR
, token
);
3242 do_scoped_id (token
, parsing
)
3247 /* during parsing, this is ::name. Otherwise, it is black magic. */
3250 id
= make_node (CPLUS_BINDING
);
3251 if (!qualified_lookup_using_namespace (token
, global_namespace
, id
, 0))
3254 id
= BINDING_VALUE (id
);
3257 id
= IDENTIFIER_GLOBAL_VALUE (token
);
3258 if (parsing
&& yychar
== YYEMPTY
)
3262 if (processing_template_decl
)
3264 id
= build_min_nt (LOOKUP_EXPR
, token
);
3265 LOOKUP_EXPR_GLOBAL (id
) = 1;
3268 if (parsing
&& (yychar
== '(' || yychar
== LEFT_RIGHT
)
3269 && ! flag_strict_prototype
)
3270 id
= implicitly_declare (token
);
3273 if (IDENTIFIER_NAMESPACE_VALUE (token
) != error_mark_node
)
3274 cp_error ("`::%D' undeclared (first use here)", token
);
3275 id
= error_mark_node
;
3276 /* Prevent repeated error messages. */
3277 SET_IDENTIFIER_NAMESPACE_VALUE (token
, error_mark_node
);
3282 if (TREE_CODE (id
) == ADDR_EXPR
)
3283 mark_used (TREE_OPERAND (id
, 0));
3284 else if (TREE_CODE (id
) != OVERLOAD
)
3287 if (TREE_CODE (id
) == CONST_DECL
&& ! processing_template_decl
)
3289 /* XXX CHS - should we set TREE_USED of the constant? */
3290 id
= DECL_INITIAL (id
);
3291 /* This is to prevent an enum whose value is 0
3292 from being considered a null pointer constant. */
3293 id
= build1 (NOP_EXPR
, TREE_TYPE (id
), id
);
3294 TREE_CONSTANT (id
) = 1;
3297 if (processing_template_decl
)
3299 if (is_overloaded_fn (id
))
3301 id
= build_min_nt (LOOKUP_EXPR
, token
);
3302 LOOKUP_EXPR_GLOBAL (id
) = 1;
3305 /* else just use the decl */
3307 return convert_from_reference (id
);
3311 identifier_typedecl_value (node
)
3315 type
= IDENTIFIER_TYPE_VALUE (node
);
3316 if (type
== NULL_TREE
)
3319 if (IDENTIFIER_BINDING (node
))
3321 t
= IDENTIFIER_VALUE (node
);
3322 if (t
&& TREE_CODE (t
) == TYPE_DECL
&& TREE_TYPE (t
) == type
)
3325 if (IDENTIFIER_NAMESPACE_VALUE (node
))
3327 t
= IDENTIFIER_NAMESPACE_VALUE (node
);
3328 if (t
&& TREE_CODE (t
) == TYPE_DECL
&& TREE_TYPE (t
) == type
)
3332 /* Will this one ever happen? */
3333 if (TYPE_MAIN_DECL (type
))
3334 return TYPE_MAIN_DECL (type
);
3336 /* We used to do an internal error of 62 here, but instead we will
3337 handle the return of a null appropriately in the callers. */
3351 int conversion_errno
;
3352 REAL_VALUE_TYPE value
;
3359 struct pf_args
* args
= (struct pf_args
*) data
;
3360 int fflag
= 0, lflag
= 0;
3361 /* Copy token_buffer now, while it has just the number
3362 and not the suffixes; once we add `f' or `i',
3363 REAL_VALUE_ATOF may not work any more. */
3364 char *copy
= (char *) alloca (args
->p
- token_buffer
+ 1);
3365 bcopy (token_buffer
, copy
, args
->p
- token_buffer
+ 1);
3367 args
->conversion_errno
= 0;
3368 args
->type
= double_type_node
;
3374 /* Read the suffixes to choose a data type. */
3379 error ("more than one `f' in numeric constant");
3385 error ("more than one `l' in numeric constant");
3391 error ("more than one `i' or `j' in numeric constant");
3393 pedwarn ("ISO C++ forbids imaginary numeric constants");
3404 if (args
->p
>= token_buffer
+ maxtoken
- 3)
3405 args
->p
= extend_token_buffer (args
->p
);
3406 *(args
->p
++) = args
->c
;
3411 /* The second argument, machine_mode, of REAL_VALUE_ATOF
3412 tells the desired precision of the binary result
3413 of decimal-to-binary conversion. */
3418 error ("both `f' and `l' in floating constant");
3420 args
->type
= float_type_node
;
3422 if (args
->base
== 16)
3423 args
->value
= REAL_VALUE_HTOF (copy
, TYPE_MODE (args
->type
));
3425 args
->value
= REAL_VALUE_ATOF (copy
, TYPE_MODE (args
->type
));
3426 args
->conversion_errno
= errno
;
3427 /* A diagnostic is required here by some ANSI C testsuites.
3428 This is not pedwarn, because some people don't want
3429 an error for this. */
3430 if (REAL_VALUE_ISINF (args
->value
) && pedantic
)
3431 warning ("floating point number exceeds range of `float'");
3435 args
->type
= long_double_type_node
;
3437 if (args
->base
== 16)
3438 args
->value
= REAL_VALUE_HTOF (copy
, TYPE_MODE (args
->type
));
3440 args
->value
= REAL_VALUE_ATOF (copy
, TYPE_MODE (args
->type
));
3441 args
->conversion_errno
= errno
;
3442 if (REAL_VALUE_ISINF (args
->value
) && pedantic
)
3443 warning ("floating point number exceeds range of `long double'");
3448 if (args
->base
== 16)
3449 args
->value
= REAL_VALUE_HTOF (copy
, TYPE_MODE (args
->type
));
3451 args
->value
= REAL_VALUE_ATOF (copy
, TYPE_MODE (args
->type
));
3452 args
->conversion_errno
= errno
;
3453 if (REAL_VALUE_ISINF (args
->value
) && pedantic
)
3454 warning ("floating point number exceeds range of `double'");
3458 /* Get the next character, staying within the current token if possible.
3459 If we're lexing a token, we don't want to look beyond the end of the
3460 token cpplib has prepared for us; otherwise, we end up reading in the
3461 next token, which screws up feed_input. So just return a null
3468 if (yy_cur
== yy_lim
)
3485 /* Read a single token from the input stream, and assign it lexical
3488 Note: We used to do token pasting here, to produce compound tokens like
3489 LEFT_RIGHT and EXTERN_LANG_STRING. That's now handled in spew.c, along
3490 with symbol table interaction and other context-sensitivity. */
3502 /* Effectively do c = skip_white_space (c)
3503 but do it faster in the usual cases. */
3513 if (cpp_token
== CPP_HSPACE
)
3514 c
= yy_get_token ();
3521 /* Call skip_white_space so we can warn if appropriate. */
3526 c
= skip_white_space (c
);
3528 goto found_nonwhite
;
3532 token_buffer
[0] = c
;
3533 token_buffer
[1] = 0;
3535 /* yylloc.first_line = lineno; */
3541 token_buffer
[0] = 0;
3543 value
= END_OF_LINE
;
3544 else if (input_redirected ())
3545 value
= END_OF_SAVED_INPUT
;
3552 if (cpp_token
== CPP_NAME
)
3555 /* Capital L may start a wide-string or wide-character constant. */
3557 register int c
= token_getch ();
3566 goto string_constant
;
3571 case 'A': case 'B': case 'C': case 'D': case 'E':
3572 case 'F': case 'G': case 'H': case 'I': case 'J':
3573 case 'K': case 'M': case 'N': case 'O':
3574 case 'P': case 'Q': case 'R': case 'S': case 'T':
3575 case 'U': case 'V': case 'W': case 'X': case 'Y':
3577 case 'a': case 'b': case 'c': case 'd': case 'e':
3578 case 'f': case 'g': case 'h': case 'i': case 'j':
3579 case 'k': case 'l': case 'm': case 'n': case 'o':
3580 case 'p': case 'q': case 'r': case 's': case 't':
3581 case 'u': case 'v': case 'w': case 'x': case 'y':
3587 if (cpp_token
== CPP_NAME
)
3589 /* Note that one character has already been read from
3590 yy_cur into token_buffer. Also, cpplib complains about
3591 $ in identifiers, so we don't have to. */
3593 int len
= yy_lim
- yy_cur
+ 1;
3594 if (len
>= maxtoken
)
3595 extend_token_buffer_to (len
+ 1);
3596 memcpy (token_buffer
+ 1, yy_cur
, len
);
3597 p
= token_buffer
+ len
;
3606 /* Make sure this char really belongs in an identifier. */
3607 if (ISALNUM (c
) || c
== '_')
3611 if (! dollars_in_ident
)
3612 error ("`$' in identifier");
3614 pedwarn ("`$' in identifier");
3616 /* FIXME we should use some sort of multibyte character
3617 encoding. Locale-dependent? Always UTF-8? */
3618 else if (is_extended_char (c
))
3620 sorry ("universal characters in identifiers");
3626 if (p
>= token_buffer
+ maxtoken
)
3627 p
= extend_token_buffer (p
);
3637 c
= readescape (&ignore
);
3650 /* Try to recognize a keyword. Uses minimum-perfect hash function */
3653 register struct resword
*ptr
;
3655 if ((ptr
= is_reserved_word (token_buffer
, p
- token_buffer
)))
3659 if (ptr
->token
== VISSPEC
)
3664 yylval
.ttype
= access_public_node
;
3667 yylval
.ttype
= access_private_node
;
3670 yylval
.ttype
= access_protected_node
;
3673 my_friendly_abort (63);
3677 yylval
.ttype
= ridpointers
[(int) ptr
->rid
];
3679 else switch (ptr
->token
)
3682 yylval
.code
= NE_EXPR
;
3683 token_buffer
[0] = '!';
3684 token_buffer
[1] = '=';
3685 token_buffer
[2] = 0;
3689 if (strcmp ("and_eq", token_buffer
) == 0)
3691 yylval
.code
= BIT_AND_EXPR
;
3692 token_buffer
[0] = '&';
3694 else if (strcmp ("or_eq", token_buffer
) == 0)
3696 yylval
.code
= BIT_IOR_EXPR
;
3697 token_buffer
[0] = '|';
3699 else if (strcmp ("xor_eq", token_buffer
) == 0)
3701 yylval
.code
= BIT_XOR_EXPR
;
3702 token_buffer
[0] = '^';
3704 token_buffer
[1] = '=';
3705 token_buffer
[2] = 0;
3709 yylval
.code
= BIT_AND_EXPR
;
3710 token_buffer
[0] = '&';
3711 token_buffer
[1] = 0;
3715 yylval
.code
= BIT_IOR_EXPR
;
3716 token_buffer
[0] = '|';
3717 token_buffer
[1] = 0;
3721 yylval
.code
= BIT_XOR_EXPR
;
3722 token_buffer
[0] = '^';
3723 token_buffer
[1] = 0;
3727 value
= (int) ptr
->token
;
3731 /* If we did not find a keyword, look for an identifier
3734 if (value
== IDENTIFIER
|| value
== TYPESPEC
)
3735 GNU_xref_ref (current_function_decl
, token_buffer
);
3737 if (value
== IDENTIFIER
)
3739 register tree tmp
= get_identifier (token_buffer
);
3741 #if !defined(VMS) && defined(JOINER)
3742 /* Make sure that user does not collide with our internal
3745 && (THIS_NAME_P (tmp
)
3746 || VPTR_NAME_P (tmp
)
3747 || DESTRUCTOR_NAME_P (tmp
)
3748 || VTABLE_NAME_P (tmp
)
3749 || TEMP_NAME_P (tmp
)
3750 || ANON_AGGRNAME_P (tmp
)
3751 || ANON_PARMNAME_P (tmp
)))
3752 warning ("identifier name `%s' conflicts with GNU C++ internal naming strategy",
3758 if (value
== NEW
&& ! global_bindings_p ())
3767 if (yy_cur
< yy_lim
)
3770 /* It's hard to preserve tokenization on '.' because
3771 it could be a symbol by itself, or it could be the
3772 start of a floating point number and cpp won't tell us. */
3773 register int c1
= token_getch ();
3774 token_buffer
[1] = c1
;
3778 token_buffer
[2] = 0;
3783 c1
= token_getch ();
3786 token_buffer
[2] = c1
;
3787 token_buffer
[3] = 0;
3791 error ("parse error at `..'");
3795 token_put_back (c1
);
3798 token_put_back (c1
);
3801 token_buffer
[1] = 0;
3805 /* Optimize for most frequent case. */
3810 cond
= (yy_cur
== yy_lim
);
3812 register int c1
= token_getch ();
3813 token_put_back (c1
);
3814 cond
= (! ISALNUM (c1
) && c1
!= '.');
3818 yylval
.ttype
= (c
== '0') ? integer_zero_node
: integer_one_node
;
3824 case '2': case '3': case '4':
3825 case '5': case '6': case '7': case '8': case '9':
3830 int largest_digit
= 0;
3834 /* We actually store only HOST_BITS_PER_CHAR bits in each part.
3835 The code below which fills the parts array assumes that a host
3836 int is at least twice as wide as a host char, and that
3837 HOST_BITS_PER_WIDE_INT is an even multiple of HOST_BITS_PER_CHAR.
3838 Two HOST_WIDE_INTs is the largest int literal we can store.
3839 In order to detect overflow below, the number of parts (TOTAL_PARTS)
3840 must be exactly the number of parts needed to hold the bits
3841 of two HOST_WIDE_INTs. */
3842 #define TOTAL_PARTS ((HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2)
3843 unsigned int parts
[TOTAL_PARTS
];
3845 enum anon1
{ NOT_FLOAT
, AFTER_POINT
, TOO_MANY_POINTS
, AFTER_EXPON
}
3846 floatflag
= NOT_FLOAT
;
3848 for (count
= 0; count
< TOTAL_PARTS
; count
++)
3856 *p
++ = (c
= token_getch ());
3857 if ((c
== 'x') || (c
== 'X'))
3860 *p
++ = (c
= token_getch ());
3862 /* Leading 0 forces octal unless the 0 is the only digit. */
3863 else if (c
>= '0' && c
<= '9')
3872 /* Read all the digits-and-decimal-points. */
3875 || (ISALNUM (c
) && c
!= 'l' && c
!= 'L'
3876 && c
!= 'u' && c
!= 'U'
3877 && c
!= 'i' && c
!= 'I' && c
!= 'j' && c
!= 'J'
3878 && (floatflag
== NOT_FLOAT
3879 || ((base
!= 16) && (c
!= 'f') && (c
!= 'F'))
3884 if (base
== 16 && pedantic
)
3885 pedwarn ("floating constant may not be in radix 16");
3886 if (floatflag
== TOO_MANY_POINTS
)
3887 /* We have already emitted an error. Don't need another. */
3889 else if (floatflag
== AFTER_POINT
|| floatflag
== AFTER_EXPON
)
3891 error ("malformed floating constant");
3892 floatflag
= TOO_MANY_POINTS
;
3893 /* Avoid another error from atof by forcing all characters
3894 from here on to be ignored. */
3898 floatflag
= AFTER_POINT
;
3902 *p
++ = c
= token_getch ();
3903 /* Accept '.' as the start of a floating-point number
3904 only when it is followed by a digit. */
3905 if (p
== token_buffer
+ 2 && !ISDIGIT (c
))
3906 my_friendly_abort (990710);
3910 /* It is not a decimal point.
3911 It should be a digit (perhaps a hex digit). */
3917 else if (base
<= 10)
3919 if (c
== 'e' || c
== 'E')
3922 floatflag
= AFTER_EXPON
;
3923 break; /* start of exponent */
3925 error ("nondigits in number and not hexadecimal");
3928 else if (base
== 16 && (c
== 'p' || c
== 'P'))
3930 floatflag
= AFTER_EXPON
;
3931 break; /* start of exponent */
3941 if (c
>= largest_digit
)
3945 for (count
= 0; count
< TOTAL_PARTS
; count
++)
3947 parts
[count
] *= base
;
3951 += (parts
[count
-1] >> HOST_BITS_PER_CHAR
);
3953 &= (1 << HOST_BITS_PER_CHAR
) - 1;
3959 /* If the highest-order part overflows (gets larger than
3960 a host char will hold) then the whole number has
3961 overflowed. Record this and truncate the highest-order
3963 if (parts
[TOTAL_PARTS
- 1] >> HOST_BITS_PER_CHAR
)
3966 parts
[TOTAL_PARTS
- 1] &= (1 << HOST_BITS_PER_CHAR
) - 1;
3969 if (p
>= token_buffer
+ maxtoken
- 3)
3970 p
= extend_token_buffer (p
);
3971 *p
++ = (c
= token_getch ());
3975 /* This can happen on input like `int i = 0x;' */
3977 error ("numeric constant with no digits");
3979 if (largest_digit
>= base
)
3980 error ("numeric constant contains digits beyond the radix");
3982 /* Remove terminating char from the token buffer and delimit the
3986 if (floatflag
!= NOT_FLOAT
)
3989 int imag
, conversion_errno
;
3990 REAL_VALUE_TYPE value
;
3991 struct pf_args args
;
3993 /* Read explicit exponent if any, and put it in tokenbuf. */
3995 if ((base
== 10 && ((c
== 'e') || (c
== 'E')))
3996 || (base
== 16 && (c
== 'p' || c
== 'P')))
3998 if (p
>= token_buffer
+ maxtoken
- 3)
3999 p
= extend_token_buffer (p
);
4002 if ((c
== '+') || (c
== '-'))
4007 /* Exponent is decimal, even if string is a hex float. */
4009 error ("floating constant exponent has no digits");
4012 if (p
>= token_buffer
+ maxtoken
- 3)
4013 p
= extend_token_buffer (p
);
4018 if (base
== 16 && floatflag
!= AFTER_EXPON
)
4019 error ("hexadecimal floating constant has no exponent");
4023 /* Setup input for parse_float() */
4028 /* Convert string to a double, checking for overflow. */
4029 if (do_float_handler (parse_float
, (PTR
) &args
))
4031 /* Receive output from parse_float() */
4036 /* We got an exception from parse_float() */
4037 error ("floating constant out of range");
4041 /* Receive output from parse_float() */
4045 conversion_errno
= args
.conversion_errno
;
4048 /* ERANGE is also reported for underflow,
4049 so test the value to distinguish overflow from that. */
4050 if (conversion_errno
== ERANGE
&& pedantic
4051 && (REAL_VALUES_LESS (dconst1
, value
)
4052 || REAL_VALUES_LESS (value
, dconstm1
)))
4053 warning ("floating point number exceeds range of `double'");
4056 /* If the result is not a number, assume it must have been
4057 due to some error message above, so silently convert
4059 if (REAL_VALUE_ISNAN (value
))
4062 /* Create a node with determined type and value. */
4064 yylval
.ttype
= build_complex (NULL_TREE
,
4065 convert (type
, integer_zero_node
),
4066 build_real (type
, value
));
4068 yylval
.ttype
= build_real (type
, value
);
4073 HOST_WIDE_INT high
, low
;
4074 int spec_unsigned
= 0;
4076 int spec_long_long
= 0;
4083 if (c
== 'u' || c
== 'U')
4086 error ("two `u's in integer constant");
4089 else if (c
== 'l' || c
== 'L')
4094 error ("three `l's in integer constant");
4095 else if (pedantic
&& ! in_system_header
&& warn_long_long
)
4096 pedwarn ("ISO C++ forbids long long integer constants");
4101 else if (c
== 'i' || c
== 'j' || c
== 'I' || c
== 'J')
4104 error ("more than one `i' or `j' in numeric constant");
4106 pedwarn ("ISO C++ forbids imaginary numeric constants");
4111 if (p
>= token_buffer
+ maxtoken
- 3)
4112 p
= extend_token_buffer (p
);
4117 /* If the literal overflowed, pedwarn about it now. */
4121 pedwarn ("integer constant is too large for this configuration of the compiler - truncated to %d bits", HOST_BITS_PER_WIDE_INT
* 2);
4124 /* This is simplified by the fact that our constant
4125 is always positive. */
4129 for (i
= 0; i
< HOST_BITS_PER_WIDE_INT
/ HOST_BITS_PER_CHAR
; i
++)
4131 high
|= ((HOST_WIDE_INT
) parts
[i
+ (HOST_BITS_PER_WIDE_INT
4132 / HOST_BITS_PER_CHAR
)]
4133 << (i
* HOST_BITS_PER_CHAR
));
4134 low
|= (HOST_WIDE_INT
) parts
[i
] << (i
* HOST_BITS_PER_CHAR
);
4137 yylval
.ttype
= build_int_2 (low
, high
);
4138 TREE_TYPE (yylval
.ttype
) = long_long_unsigned_type_node
;
4140 /* Calculate the ANSI type. */
4141 if (! spec_long
&& ! spec_unsigned
4142 && int_fits_type_p (yylval
.ttype
, integer_type_node
))
4143 type
= integer_type_node
;
4144 else if (! spec_long
&& (base
!= 10 || spec_unsigned
)
4145 && int_fits_type_p (yylval
.ttype
, unsigned_type_node
))
4146 type
= unsigned_type_node
;
4147 else if (! spec_unsigned
&& !spec_long_long
4148 && int_fits_type_p (yylval
.ttype
, long_integer_type_node
))
4149 type
= long_integer_type_node
;
4150 else if (! spec_long_long
4151 && int_fits_type_p (yylval
.ttype
,
4152 long_unsigned_type_node
))
4153 type
= long_unsigned_type_node
;
4154 else if (! spec_unsigned
4155 && int_fits_type_p (yylval
.ttype
,
4156 long_long_integer_type_node
))
4157 type
= long_long_integer_type_node
;
4158 else if (int_fits_type_p (yylval
.ttype
,
4159 long_long_unsigned_type_node
))
4160 type
= long_long_unsigned_type_node
;
4161 else if (! spec_unsigned
4162 && int_fits_type_p (yylval
.ttype
,
4163 widest_integer_literal_type_node
))
4164 type
= widest_integer_literal_type_node
;
4166 type
= widest_unsigned_literal_type_node
;
4168 if (pedantic
&& !spec_long_long
&& !warn
4169 && (TYPE_PRECISION (long_integer_type_node
)
4170 < TYPE_PRECISION (type
)))
4173 pedwarn ("integer constant larger than the maximum value of an unsigned long int");
4176 if (base
== 10 && ! spec_unsigned
&& TREE_UNSIGNED (type
))
4177 warning ("decimal constant is so large that it is unsigned");
4181 if (TYPE_PRECISION (type
)
4182 <= TYPE_PRECISION (integer_type_node
))
4184 = build_complex (NULL_TREE
, integer_zero_node
,
4185 convert (integer_type_node
,
4188 error ("complex integer constant is too wide for `__complex int'");
4191 TREE_TYPE (yylval
.ttype
) = type
;
4194 /* If it's still an integer (not a complex), and it doesn't
4195 fit in the type we choose for it, then pedwarn. */
4198 && TREE_CODE (TREE_TYPE (yylval
.ttype
)) == INTEGER_TYPE
4199 && ! int_fits_type_p (yylval
.ttype
, TREE_TYPE (yylval
.ttype
)))
4200 pedwarn ("integer constant is larger than the maximum value for its type");
4206 if (ISALNUM (c
) || c
== '.' || c
== '_' || c
== '$'
4207 || ((c
== '-' || c
== '+')
4208 && (p
[-1] == 'e' || p
[-1] == 'E')))
4209 error ("missing white space after number `%s'", token_buffer
);
4211 value
= CONSTANT
; break;
4217 register int result
= 0;
4218 register int num_chars
= 0;
4220 unsigned width
= TYPE_PRECISION (char_type_node
);
4222 #ifdef MULTIBYTE_CHARS
4223 int longest_char
= local_mb_cur_max ();
4224 local_mbtowc (NULL_PTR
, NULL_PTR
, 0);
4227 max_chars
= TYPE_PRECISION (integer_type_node
) / width
;
4229 width
= WCHAR_TYPE_SIZE
;
4236 if (c
== '\'' || c
== EOF
)
4243 c
= readescape (&ignore
);
4246 if (width
< HOST_BITS_PER_INT
4247 && (unsigned) c
>= ((unsigned)1 << width
))
4248 pedwarn ("escape sequence out of range for character");
4249 #ifdef MAP_CHARACTER
4251 c
= MAP_CHARACTER (c
);
4257 pedwarn ("ISO C++ forbids newline in character constant");
4262 #ifdef MULTIBYTE_CHARS
4266 for (i
= 1; i
<= longest_char
; ++i
)
4268 if (i
> maxtoken
- 4)
4269 extend_token_buffer (token_buffer
);
4271 token_buffer
[i
] = c
;
4272 char_len
= local_mbtowc (& wc
,
4281 /* mbtowc sometimes needs an extra char before accepting */
4286 /* Merge character into result; ignore excess chars. */
4287 for (i
= 1; i
<= char_len
; ++i
)
4291 if (width
< HOST_BITS_PER_INT
)
4292 result
= (result
<< width
)
4294 & ((1 << width
) - 1));
4296 result
= token_buffer
[i
];
4298 num_chars
+= char_len
;
4307 warning ("Ignoring invalid multibyte character");
4308 /* Replace all but the first byte. */
4309 for (--i
; i
> 1; --i
)
4310 token_put_back (token_buffer
[i
]);
4311 wc
= token_buffer
[1];
4313 #ifdef MAP_CHARACTER
4314 c
= MAP_CHARACTER (wc
);
4319 #else /* ! MULTIBYTE_CHARS */
4320 #ifdef MAP_CHARACTER
4321 c
= MAP_CHARACTER (c
);
4323 #endif /* ! MULTIBYTE_CHARS */
4328 if (chars_seen
== 1) /* only keep the first one */
4333 /* Merge character into result; ignore excess chars. */
4334 num_chars
+= (width
/ TYPE_PRECISION (char_type_node
));
4335 if (num_chars
< max_chars
+ 1)
4337 if (width
< HOST_BITS_PER_INT
)
4338 result
= (result
<< width
) | (c
& ((1 << width
) - 1));
4345 error ("malformatted character constant");
4346 else if (chars_seen
== 0)
4347 error ("empty character constant");
4348 else if (num_chars
> max_chars
)
4350 num_chars
= max_chars
;
4351 error ("character constant too long");
4353 else if (chars_seen
!= 1 && warn_multichar
)
4354 warning ("multi-character character constant");
4356 /* If char type is signed, sign-extend the constant. */
4359 int num_bits
= num_chars
* width
;
4361 /* We already got an error; avoid invalid shift. */
4362 yylval
.ttype
= build_int_2 (0, 0);
4363 else if (TREE_UNSIGNED (char_type_node
)
4364 || ((result
>> (num_bits
- 1)) & 1) == 0)
4366 = build_int_2 (result
& (~(unsigned HOST_WIDE_INT
) 0
4367 >> (HOST_BITS_PER_WIDE_INT
- num_bits
)),
4371 = build_int_2 (result
| ~(~(unsigned HOST_WIDE_INT
) 0
4372 >> (HOST_BITS_PER_WIDE_INT
- num_bits
)),
4374 /* In C, a character constant has type 'int'; in C++, 'char'. */
4375 if (chars_seen
<= 1)
4376 TREE_TYPE (yylval
.ttype
) = char_type_node
;
4378 TREE_TYPE (yylval
.ttype
) = integer_type_node
;
4382 yylval
.ttype
= build_int_2 (result
, 0);
4383 TREE_TYPE (yylval
.ttype
) = wchar_type_node
;
4393 unsigned width
= wide_flag
? WCHAR_TYPE_SIZE
4394 : TYPE_PRECISION (char_type_node
);
4395 #ifdef MULTIBYTE_CHARS
4396 int longest_char
= local_mb_cur_max ();
4397 local_mbtowc (NULL_PTR
, NULL_PTR
, 0);
4401 p
= token_buffer
+ 1;
4403 while (c
!= '"' && c
!= EOF
)
4405 /* ignore_escape_flag is set for reading the filename in #line. */
4406 if (!ignore_escape_flag
&& c
== '\\')
4409 c
= readescape (&ignore
);
4412 if (width
< HOST_BITS_PER_INT
4413 && (unsigned) c
>= ((unsigned)1 << width
))
4414 pedwarn ("escape sequence out of range for character");
4419 pedwarn ("ISO C++ forbids newline in string constant");
4424 #ifdef MULTIBYTE_CHARS
4428 for (i
= 0; i
< longest_char
; ++i
)
4430 if (p
+ i
>= token_buffer
+ maxtoken
)
4431 p
= extend_token_buffer (p
);
4434 char_len
= local_mbtowc (& wc
, p
, i
+ 1);
4441 warning ("Ignoring invalid multibyte character");
4442 /* Replace all except the first byte. */
4444 for (--i
; i
> 0; --i
)
4445 token_put_back (p
[i
]);
4448 /* mbtowc sometimes needs an extra char before accepting */
4458 #endif /* MULTIBYTE_CHARS */
4461 /* Add this single character into the buffer either as a wchar_t
4462 or as a single byte. */
4465 unsigned width
= TYPE_PRECISION (char_type_node
);
4466 unsigned bytemask
= (1 << width
) - 1;
4469 if (p
+ WCHAR_BYTES
> token_buffer
+ maxtoken
)
4470 p
= extend_token_buffer (p
);
4472 for (byte
= 0; byte
< WCHAR_BYTES
; ++byte
)
4475 if (byte
>= (int) sizeof (c
))
4478 value
= (c
>> (byte
* width
)) & bytemask
;
4479 if (BYTES_BIG_ENDIAN
)
4480 p
[WCHAR_BYTES
- byte
- 1] = value
;
4488 if (p
>= token_buffer
+ maxtoken
)
4489 p
= extend_token_buffer (p
);
4497 /* Terminate the string value, either with a single byte zero
4498 or with a wide zero. */
4501 if (p
+ WCHAR_BYTES
> token_buffer
+ maxtoken
)
4502 p
= extend_token_buffer (p
);
4503 bzero (p
, WCHAR_BYTES
);
4508 if (p
>= token_buffer
+ maxtoken
)
4509 p
= extend_token_buffer (p
);
4514 error ("Unterminated string constant");
4516 /* We have read the entire constant.
4517 Construct a STRING_CST for the result. */
4519 yylval
.ttype
= build_string (p
- (token_buffer
+ 1), token_buffer
+ 1);
4522 TREE_TYPE (yylval
.ttype
) = wchar_array_type_node
;
4524 TREE_TYPE (yylval
.ttype
) = char_array_type_node
;
4526 value
= STRING
; break;
4550 yylval
.code
= PLUS_EXPR
; break;
4552 yylval
.code
= MINUS_EXPR
; break;
4554 yylval
.code
= BIT_AND_EXPR
; break;
4556 yylval
.code
= BIT_IOR_EXPR
; break;
4558 yylval
.code
= MULT_EXPR
; break;
4560 yylval
.code
= TRUNC_DIV_EXPR
; break;
4562 yylval
.code
= TRUNC_MOD_EXPR
; break;
4564 yylval
.code
= BIT_XOR_EXPR
; break;
4566 yylval
.code
= LSHIFT_EXPR
; break;
4568 yylval
.code
= RSHIFT_EXPR
; break;
4570 yylval
.code
= LT_EXPR
; break;
4572 yylval
.code
= GT_EXPR
; break;
4575 token_buffer
[1] = c1
= token_getch ();
4576 token_buffer
[2] = 0;
4583 value
= ARITHCOMPARE
; yylval
.code
= LE_EXPR
; goto done
;
4585 value
= ARITHCOMPARE
; yylval
.code
= GE_EXPR
; goto done
;
4587 value
= EQCOMPARE
; yylval
.code
= NE_EXPR
; goto done
;
4589 value
= EQCOMPARE
; yylval
.code
= EQ_EXPR
; goto done
;
4591 value
= ASSIGN
; goto done
;
4597 value
= PLUSPLUS
; goto done
;
4599 value
= MINUSMINUS
; goto done
;
4601 value
= ANDAND
; goto done
;
4603 value
= OROR
; goto done
;
4615 else if (c1
== '?' && (c
== '<' || c
== '>'))
4617 token_buffer
[3] = 0;
4619 c1
= token_getch ();
4620 yylval
.code
= (c
== '<' ? MIN_EXPR
: MAX_EXPR
);
4623 /* <?= or >?= expression. */
4624 token_buffer
[2] = c1
;
4630 token_put_back (c1
);
4633 pedwarn ("use of `operator %s' is not standard C++",
4643 c1
= token_getch ();
4645 value
= POINTSAT_STAR
;
4648 token_put_back (c1
);
4658 { value
= ']'; goto done
; }
4662 { value
= '{'; indent_level
++; goto done
; }
4664 { value
= '['; goto done
; }
4668 { value
= '}'; indent_level
--; goto done
; }
4672 token_put_back (c1
);
4673 token_buffer
[1] = 0;
4675 /* Here the C frontend changes < and > to ARITHCOMPARE. We don't
4676 do that because of templates. */
4683 /* Don't make yyparse think this is eof. */
4698 if (is_extended_char (c
))
4704 /* yylloc.last_line = lineno; */
4705 #ifdef GATHER_STATISTICS
4706 #ifdef REDUCE_LENGTH
4707 token_count
[value
] += 1;
4718 return !!is_reserved_word (IDENTIFIER_POINTER (t
), IDENTIFIER_LENGTH (t
));
4721 #ifdef GATHER_STATISTICS
4722 /* The original for tree_node_kind is in the toplevel tree.c; changes there
4723 need to be brought into here, unless this were actually put into a header
4725 /* Statistics-gathering stuff. */
4746 extern int tree_node_counts
[];
4747 extern int tree_node_sizes
[];
4751 build_lang_decl (code
, name
, type
)
4752 enum tree_code code
;
4758 t
= build_decl (code
, name
, type
);
4759 retrofit_lang_decl (t
);
4764 /* Add DECL_LANG_SPECIFIC info to T. Called from build_lang_decl
4765 and pushdecl (for functions generated by the backend). */
4768 retrofit_lang_decl (t
)
4771 struct lang_decl
*ld
;
4774 if (CAN_HAVE_FULL_LANG_DECL_P (t
))
4775 size
= sizeof (struct lang_decl
);
4777 size
= sizeof (struct lang_decl_flags
);
4779 ld
= (struct lang_decl
*) ggc_alloc_obj (size
, 1);
4781 DECL_LANG_SPECIFIC (t
) = ld
;
4782 if (current_lang_name
== lang_name_cplusplus
)
4783 DECL_LANGUAGE (t
) = lang_cplusplus
;
4784 else if (current_lang_name
== lang_name_c
)
4785 DECL_LANGUAGE (t
) = lang_c
;
4786 else if (current_lang_name
== lang_name_java
)
4787 DECL_LANGUAGE (t
) = lang_java
;
4788 else my_friendly_abort (64);
4790 #ifdef GATHER_STATISTICS
4791 tree_node_counts
[(int)lang_decl
] += 1;
4792 tree_node_sizes
[(int)lang_decl
] += size
;
4797 copy_lang_decl (node
)
4801 struct lang_decl
*ld
;
4803 if (! DECL_LANG_SPECIFIC (node
))
4806 if (!CAN_HAVE_FULL_LANG_DECL_P (node
))
4807 size
= sizeof (struct lang_decl_flags
);
4809 size
= sizeof (struct lang_decl
);
4810 ld
= (struct lang_decl
*) ggc_alloc (size
);
4811 bcopy ((char *)DECL_LANG_SPECIFIC (node
), (char *)ld
, size
);
4812 DECL_LANG_SPECIFIC (node
) = ld
;
4815 /* Copy DECL, including any language-specific parts. */
4823 copy
= copy_node (decl
);
4824 copy_lang_decl (copy
);
4829 cp_make_lang_type (code
)
4830 enum tree_code code
;
4832 register tree t
= make_node (code
);
4834 /* Set up some flags that give proper default behavior. */
4835 if (IS_AGGR_TYPE_CODE (code
))
4837 struct lang_type
*pi
;
4839 pi
= (struct lang_type
*) ggc_alloc (sizeof (struct lang_type
));
4840 bzero ((char *) pi
, (int) sizeof (struct lang_type
));
4842 TYPE_LANG_SPECIFIC (t
) = pi
;
4843 SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t
, interface_unknown
);
4844 CLASSTYPE_INTERFACE_ONLY (t
) = interface_only
;
4846 /* Make sure this is laid out, for ease of use later. In the
4847 presence of parse errors, the normal was of assuring this
4848 might not ever get executed, so we lay it out *immediately*. */
4849 build_pointer_type (t
);
4851 #ifdef GATHER_STATISTICS
4852 tree_node_counts
[(int)lang_type
] += 1;
4853 tree_node_sizes
[(int)lang_type
] += sizeof (struct lang_type
);
4857 /* We use TYPE_ALIAS_SET for the CLASSTYPE_MARKED bits. But,
4858 TYPE_ALIAS_SET is initialized to -1 by default, so we must
4860 TYPE_ALIAS_SET (t
) = 0;
4862 /* We need to allocate a TYPE_BINFO even for TEMPLATE_TYPE_PARMs
4863 since they can be virtual base types, and we then need a
4864 canonical binfo for them. Ideally, this would be done lazily for
4866 if (IS_AGGR_TYPE_CODE (code
) || code
== TEMPLATE_TYPE_PARM
)
4867 TYPE_BINFO (t
) = make_binfo (size_zero_node
, t
, NULL_TREE
, NULL_TREE
);
4873 make_aggr_type (code
)
4874 enum tree_code code
;
4876 tree t
= cp_make_lang_type (code
);
4878 if (IS_AGGR_TYPE_CODE (code
))
4879 SET_IS_AGGR_TYPE (t
, 1);
4885 dump_time_statistics ()
4887 register tree prev
= 0, decl
, next
;
4888 int this_time
= get_run_time ();
4889 TREE_INT_CST_LOW (TIME_IDENTIFIER_TIME (this_filename_time
))
4890 += this_time
- body_time
;
4892 fprintf (stderr
, "\n******\n");
4893 print_time ("header files (total)", header_time
);
4894 print_time ("main file (total)", this_time
- body_time
);
4895 fprintf (stderr
, "ratio = %g : 1\n",
4896 (double)header_time
/ (double)(this_time
- body_time
));
4897 fprintf (stderr
, "\n******\n");
4899 for (decl
= filename_times
; decl
; decl
= next
)
4901 next
= IDENTIFIER_GLOBAL_VALUE (decl
);
4902 SET_IDENTIFIER_GLOBAL_VALUE (decl
, prev
);
4906 for (decl
= prev
; decl
; decl
= IDENTIFIER_GLOBAL_VALUE (decl
))
4907 print_time (IDENTIFIER_POINTER (decl
),
4908 TREE_INT_CST_LOW (TIME_IDENTIFIER_TIME (decl
)));
4912 compiler_error
VPARAMS ((const char *msg
, ...))
4914 #ifndef ANSI_PROTOTYPES
4922 #ifndef ANSI_PROTOTYPES
4923 msg
= va_arg (ap
, const char *);
4926 vsprintf (buf
, msg
, ap
);
4928 error_with_file_and_line (input_filename
, lineno
, "%s (compiler error)", buf
);
4931 /* Return the type-qualifier corresponding to the identifier given by
4935 cp_type_qual_from_rid (rid
)
4938 if (rid
== ridpointers
[(int) RID_CONST
])
4939 return TYPE_QUAL_CONST
;
4940 else if (rid
== ridpointers
[(int) RID_VOLATILE
])
4941 return TYPE_QUAL_VOLATILE
;
4942 else if (rid
== ridpointers
[(int) RID_RESTRICT
])
4943 return TYPE_QUAL_RESTRICT
;
4945 my_friendly_abort (0);
4946 return TYPE_UNQUALIFIED
;