1 /* Separate lexical analyzer for GNU C++.
2 Copyright (C) 1987-2017 Free Software Foundation, Inc.
3 Hacked by Michael Tiemann (tiemann@cygnus.com)
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
22 /* This file is the lexical analyzer for GNU C++. */
26 #include "coretypes.h"
28 #include "stringpool.h"
29 #include "c-family/c-pragma.h"
30 #include "c-family/c-objc.h"
32 static int interface_strcmp (const char *);
33 static void init_cp_pragma (void);
35 static tree
parse_strconst_pragma (const char *, int);
36 static void handle_pragma_vtable (cpp_reader
*);
37 static void handle_pragma_unit (cpp_reader
*);
38 static void handle_pragma_interface (cpp_reader
*);
39 static void handle_pragma_implementation (cpp_reader
*);
41 static void init_operators (void);
42 static void copy_lang_type (tree
);
44 /* A constraint that can be tested at compile time. */
45 #define CONSTRAINT(name, expr) extern int constraint_##name [(expr) ? 1 : -1]
47 /* Functions and data structures for #pragma interface.
49 `#pragma implementation' means that the main file being compiled
50 is considered to implement (provide) the classes that appear in
51 its main body. I.e., if this is file "foo.cc", and class `bar'
52 is defined in "foo.cc", then we say that "foo.cc implements bar".
54 All main input files "implement" themselves automagically.
56 `#pragma interface' means that unless this file (of the form "foo.h"
57 is not presently being included by file "foo.cc", the
58 CLASSTYPE_INTERFACE_ONLY bit gets set. The effect is that none
59 of the vtables nor any of the inline functions defined in foo.h
62 There are cases when we want to link files such as "defs.h" and
63 "main.cc". In this case, we give "defs.h" a `#pragma interface',
64 and "main.cc" has `#pragma implementation "defs.h"'. */
69 struct impl_files
*next
;
72 static struct impl_files
*impl_file_chain
;
80 ovl_op_info_t ovl_op_info
[2][OVL_OP_MAX
] =
83 {NULL_TREE
, NULL
, NULL
, ERROR_MARK
, OVL_OP_ERROR_MARK
, 0},
84 {NULL_TREE
, NULL
, NULL
, NOP_EXPR
, OVL_OP_NOP_EXPR
, 0},
85 #define DEF_OPERATOR(NAME, CODE, MANGLING, FLAGS) \
86 {NULL_TREE, NAME, MANGLING, CODE, OVL_OP_##CODE, FLAGS},
87 #define OPERATOR_TRANSITION }, { \
88 {NULL_TREE, NULL, NULL, ERROR_MARK, OVL_OP_ERROR_MARK, 0},
89 #include "operators.def"
92 unsigned char ovl_op_mapping
[MAX_TREE_CODES
];
93 unsigned char ovl_op_alternate
[OVL_OP_MAX
];
95 /* Get the name of the kind of identifier T. */
98 get_identifier_kind_name (tree id
)
100 /* Keep in sync with cp_id_kind enumeration. */
101 static const char *const names
[cik_max
] = {
102 "normal", "keyword", "constructor", "destructor",
103 "assign-op", "op-assign-op", "simple-op", "conv-op", };
106 kind
|= IDENTIFIER_KIND_BIT_2 (id
) << 2;
107 kind
|= IDENTIFIER_KIND_BIT_1 (id
) << 1;
108 kind
|= IDENTIFIER_KIND_BIT_0 (id
) << 0;
113 /* Set the identifier kind, which we expect to currently be zero. */
116 set_identifier_kind (tree id
, cp_identifier_kind kind
)
118 gcc_checking_assert (!IDENTIFIER_KIND_BIT_2 (id
)
119 & !IDENTIFIER_KIND_BIT_1 (id
)
120 & !IDENTIFIER_KIND_BIT_0 (id
));
121 IDENTIFIER_KIND_BIT_2 (id
) |= (kind
>> 2) & 1;
122 IDENTIFIER_KIND_BIT_1 (id
) |= (kind
>> 1) & 1;
123 IDENTIFIER_KIND_BIT_0 (id
) |= (kind
>> 0) & 1;
126 /* Create and tag the internal operator name for the overloaded
127 operator PTR describes. */
130 set_operator_ident (ovl_op_info_t
*ptr
)
133 size_t len
= snprintf (buffer
, sizeof (buffer
), "operator%s%s",
134 &" "[ptr
->name
[0] && ptr
->name
[0] != '_'
135 && !ISALPHA (ptr
->name
[0])],
137 gcc_checking_assert (len
< sizeof (buffer
));
139 tree ident
= get_identifier_with_length (buffer
, len
);
140 ptr
->identifier
= ident
;
145 /* Initialize data structures that keep track of operator names. */
148 init_operators (void)
150 /* We rely on both these being zero. */
151 gcc_checking_assert (!OVL_OP_ERROR_MARK
&& !ERROR_MARK
);
153 /* This loop iterates backwards because we need to move the
154 assignment operators down to their correct slots. I.e. morally
155 equivalent to an overlapping memmove where dest > src. Slot
156 zero is for error_mark, so hae no operator. */
157 for (unsigned ix
= OVL_OP_MAX
; --ix
;)
159 ovl_op_info_t
*op_ptr
= &ovl_op_info
[false][ix
];
163 /* Make sure it fits in lang_decl_fn::operator_code. */
164 gcc_checking_assert (op_ptr
->ovl_op_code
< (1 << 6));
165 tree ident
= set_operator_ident (op_ptr
);
166 if (unsigned index
= IDENTIFIER_CP_INDEX (ident
))
168 ovl_op_info_t
*bin_ptr
= &ovl_op_info
[false][index
];
170 /* They should only differ in unary/binary ness. */
171 gcc_checking_assert ((op_ptr
->flags
^ bin_ptr
->flags
)
172 == OVL_OP_FLAG_AMBIARY
);
173 bin_ptr
->flags
|= op_ptr
->flags
;
174 ovl_op_alternate
[index
] = ix
;
178 IDENTIFIER_CP_INDEX (ident
) = ix
;
179 set_identifier_kind (ident
,
180 op_ptr
->flags
& OVL_OP_FLAG_ALLOC
181 ? cik_newdel_op
: cik_simple_op
);
184 if (op_ptr
->tree_code
)
186 gcc_checking_assert (op_ptr
->ovl_op_code
== ix
187 && !ovl_op_mapping
[op_ptr
->tree_code
]);
188 ovl_op_mapping
[op_ptr
->tree_code
] = op_ptr
->ovl_op_code
;
191 ovl_op_info_t
*as_ptr
= &ovl_op_info
[true][ix
];
194 /* These will be placed at the start of the array, move to
195 the correct slot and initialize. */
196 if (as_ptr
->ovl_op_code
!= ix
)
198 ovl_op_info_t
*dst_ptr
= &ovl_op_info
[true][as_ptr
->ovl_op_code
];
199 gcc_assert (as_ptr
->ovl_op_code
> ix
&& !dst_ptr
->tree_code
);
200 memcpy (dst_ptr
, as_ptr
, sizeof (*dst_ptr
));
201 memset (as_ptr
, 0, sizeof (*as_ptr
));
205 tree ident
= set_operator_ident (as_ptr
);
206 gcc_checking_assert (!IDENTIFIER_CP_INDEX (ident
));
207 IDENTIFIER_CP_INDEX (ident
) = as_ptr
->ovl_op_code
;
208 set_identifier_kind (ident
, cik_assign_op
);
210 gcc_checking_assert (!ovl_op_mapping
[as_ptr
->tree_code
]
211 || (ovl_op_mapping
[as_ptr
->tree_code
]
212 == as_ptr
->ovl_op_code
));
213 ovl_op_mapping
[as_ptr
->tree_code
] = as_ptr
->ovl_op_code
;
218 /* Initialize the reserved words. */
227 if (cxx_dialect
< cxx11
)
230 mask
|= D_CXX_CONCEPTS
;
234 mask
|= D_ASM
| D_EXT
;
235 if (flag_no_gnu_keywords
)
238 /* The Objective-C keywords are all context-dependent. */
241 ridpointers
= ggc_cleared_vec_alloc
<tree
> ((int) RID_MAX
);
242 for (i
= 0; i
< num_c_common_reswords
; i
++)
244 if (c_common_reswords
[i
].disable
& D_CONLY
)
246 id
= get_identifier (c_common_reswords
[i
].word
);
247 C_SET_RID_CODE (id
, c_common_reswords
[i
].rid
);
248 ridpointers
[(int) c_common_reswords
[i
].rid
] = id
;
249 if (! (c_common_reswords
[i
].disable
& mask
))
250 set_identifier_kind (id
, cik_keyword
);
253 for (i
= 0; i
< NUM_INT_N_ENTS
; i
++)
256 sprintf (name
, "__int%d", int_n_data
[i
].bitsize
);
257 id
= get_identifier (name
);
258 C_SET_RID_CODE (id
, RID_FIRST_INT_N
+ i
);
259 set_identifier_kind (id
, cik_keyword
);
264 init_cp_pragma (void)
266 c_register_pragma (0, "vtable", handle_pragma_vtable
);
267 c_register_pragma (0, "unit", handle_pragma_unit
);
268 c_register_pragma (0, "interface", handle_pragma_interface
);
269 c_register_pragma (0, "implementation", handle_pragma_implementation
);
270 c_register_pragma ("GCC", "interface", handle_pragma_interface
);
271 c_register_pragma ("GCC", "implementation", handle_pragma_implementation
);
274 /* TRUE if a code represents a statement. */
276 bool statement_code_p
[MAX_TREE_CODES
];
278 /* Initialize the C++ front end. This function is very sensitive to
279 the exact order that things are done here. It would be nice if the
280 initialization done by this routine were moved to its subroutines,
281 and the ordering dependencies clarified and reduced. */
285 location_t saved_loc
;
287 static const enum tree_code stmt_codes
[] = {
288 CTOR_INITIALIZER
, TRY_BLOCK
, HANDLER
,
289 EH_SPEC_BLOCK
, USING_STMT
, TAG_DEFN
,
290 IF_STMT
, CLEANUP_STMT
, FOR_STMT
,
291 RANGE_FOR_STMT
, WHILE_STMT
, DO_STMT
,
292 BREAK_STMT
, CONTINUE_STMT
, SWITCH_STMT
,
296 memset (&statement_code_p
, 0, sizeof (statement_code_p
));
297 for (i
= 0; i
< ARRAY_SIZE (stmt_codes
); i
++)
298 statement_code_p
[stmt_codes
[i
]] = true;
300 saved_loc
= input_location
;
301 input_location
= BUILTINS_LOCATION
;
305 init_cp_semantics ();
309 current_function_decl
= NULL
;
311 class_type_node
= ridpointers
[(int) RID_CLASS
];
313 cxx_init_decl_processing ();
315 if (c_common_init () == false)
317 input_location
= saved_loc
;
325 input_location
= saved_loc
;
329 /* Return nonzero if S is not considered part of an
330 INTERFACE/IMPLEMENTATION pair. Otherwise, return 0. */
333 interface_strcmp (const char* s
)
335 /* Set the interface/implementation bits for this scope. */
336 struct impl_files
*ifiles
;
339 for (ifiles
= impl_file_chain
; ifiles
; ifiles
= ifiles
->next
)
341 const char *t1
= ifiles
->filename
;
344 if (*s1
== 0 || filename_ncmp (s1
, t1
, 1) != 0)
347 while (*s1
!= 0 && filename_ncmp (s1
, t1
, 1) == 0)
354 /* Don't get faked out by xxx.yyy.cc vs xxx.zzz.cc. */
355 if (strchr (s1
, '.') || strchr (t1
, '.'))
358 if (*s1
== '\0' || s1
[-1] != '.' || t1
[-1] != '.')
371 /* Parse a #pragma whose sole argument is a string constant.
372 If OPT is true, the argument is optional. */
374 parse_strconst_pragma (const char* name
, int opt
)
379 t
= pragma_lex (&result
);
382 if (pragma_lex (&x
) != CPP_EOF
)
383 warning (0, "junk at end of #pragma %s", name
);
387 if (t
== CPP_EOF
&& opt
)
390 error ("invalid #pragma %s", name
);
391 return error_mark_node
;
395 handle_pragma_vtable (cpp_reader
* /*dfile*/)
397 parse_strconst_pragma ("vtable", 0);
398 sorry ("#pragma vtable no longer supported");
402 handle_pragma_unit (cpp_reader
* /*dfile*/)
404 /* Validate syntax, but don't do anything. */
405 parse_strconst_pragma ("unit", 0);
409 handle_pragma_interface (cpp_reader
* /*dfile*/)
411 tree fname
= parse_strconst_pragma ("interface", 1);
412 struct c_fileinfo
*finfo
;
413 const char *filename
;
415 if (fname
== error_mark_node
)
418 filename
= lbasename (LOCATION_FILE (input_location
));
420 filename
= TREE_STRING_POINTER (fname
);
422 finfo
= get_fileinfo (LOCATION_FILE (input_location
));
424 if (impl_file_chain
== 0)
426 /* If this is zero at this point, then we are
427 auto-implementing. */
428 if (main_input_filename
== 0)
429 main_input_filename
= LOCATION_FILE (input_location
);
432 finfo
->interface_only
= interface_strcmp (filename
);
433 /* If MULTIPLE_SYMBOL_SPACES is set, we cannot assume that we can see
434 a definition in another file. */
435 if (!MULTIPLE_SYMBOL_SPACES
|| !finfo
->interface_only
)
436 finfo
->interface_unknown
= 0;
439 /* Note that we have seen a #pragma implementation for the key MAIN_FILENAME.
440 We used to only allow this at toplevel, but that restriction was buggy
441 in older compilers and it seems reasonable to allow it in the headers
442 themselves, too. It only needs to precede the matching #p interface.
444 We don't touch finfo->interface_only or finfo->interface_unknown;
445 the user must specify a matching #p interface for this to have
449 handle_pragma_implementation (cpp_reader
* /*dfile*/)
451 tree fname
= parse_strconst_pragma ("implementation", 1);
452 const char *filename
;
453 struct impl_files
*ifiles
= impl_file_chain
;
455 if (fname
== error_mark_node
)
460 if (main_input_filename
)
461 filename
= main_input_filename
;
463 filename
= LOCATION_FILE (input_location
);
464 filename
= lbasename (filename
);
468 filename
= TREE_STRING_POINTER (fname
);
469 if (cpp_included_before (parse_in
, filename
, input_location
))
470 warning (0, "#pragma implementation for %qs appears after "
471 "file is included", filename
);
474 for (; ifiles
; ifiles
= ifiles
->next
)
476 if (! filename_cmp (ifiles
->filename
, filename
))
481 ifiles
= XNEW (struct impl_files
);
482 ifiles
->filename
= xstrdup (filename
);
483 ifiles
->next
= impl_file_chain
;
484 impl_file_chain
= ifiles
;
488 /* Issue an error message indicating that the lookup of NAME (an
489 IDENTIFIER_NODE) failed. Returns the ERROR_MARK_NODE. */
492 unqualified_name_lookup_error (tree name
, location_t loc
)
494 if (loc
== UNKNOWN_LOCATION
)
495 loc
= EXPR_LOC_OR_LOC (name
, input_location
);
497 if (IDENTIFIER_ANY_OP_P (name
))
498 error_at (loc
, "%qD not defined", name
);
501 if (!objc_diagnose_private_ivar (name
))
503 error_at (loc
, "%qD was not declared in this scope", name
);
504 suggest_alternatives_for (loc
, name
, true);
506 /* Prevent repeated error messages by creating a VAR_DECL with
507 this NAME in the innermost block scope. */
508 if (local_bindings_p ())
510 tree decl
= build_decl (loc
, VAR_DECL
, name
, error_mark_node
);
511 TREE_USED (decl
) = true;
516 return error_mark_node
;
519 /* Like unqualified_name_lookup_error, but NAME_EXPR is an unqualified-id
520 NAME, encapsulated with its location in a CP_EXPR, used as a function.
521 Returns an appropriate expression for NAME. */
524 unqualified_fn_lookup_error (cp_expr name_expr
)
526 tree name
= name_expr
.get_value ();
527 location_t loc
= name_expr
.get_location ();
528 if (loc
== UNKNOWN_LOCATION
)
529 loc
= input_location
;
531 if (processing_template_decl
)
533 /* In a template, it is invalid to write "f()" or "f(3)" if no
534 declaration of "f" is available. Historically, G++ and most
535 other compilers accepted that usage since they deferred all name
536 lookup until instantiation time rather than doing unqualified
537 name lookup at template definition time; explain to the user what
540 Note that we have the exact wording of the following message in
541 the manual (trouble.texi, node "Name lookup"), so they need to
543 permerror (loc
, "there are no arguments to %qD that depend on a template "
544 "parameter, so a declaration of %qD must be available",
547 if (!flag_permissive
)
552 inform (loc
, "(if you use %<-fpermissive%>, G++ will accept your "
553 "code, but allowing the use of an undeclared name is "
561 return unqualified_name_lookup_error (name
, loc
);
565 /* Hasher for the conversion operator name hash table. */
566 struct conv_type_hasher
: ggc_ptr_hash
<tree_node
>
568 /* Hash NODE, an identifier node in the table. TYPE_UID is
569 suitable, as we're not concerned about matching canonicalness
571 static hashval_t
hash (tree node
)
573 return (hashval_t
) TYPE_UID (TREE_TYPE (node
));
576 /* Compare NODE, an identifier node in the table, against TYPE, an
577 incoming TYPE being looked up. */
578 static bool equal (tree node
, tree type
)
580 return TREE_TYPE (node
) == type
;
584 /* This hash table maps TYPEs to the IDENTIFIER for a conversion
585 operator to TYPE. The nodes are IDENTIFIERs whose TREE_TYPE is the
588 static GTY (()) hash_table
<conv_type_hasher
> *conv_type_names
;
590 /* Return an identifier for a conversion operator to TYPE. We can get
591 from the returned identifier to the type. We store TYPE, which is
592 not necessarily the canonical type, which allows us to report the
593 form the user used in error messages. All these identifiers are
594 not in the identifier hash table, and have the same string name.
595 These IDENTIFIERS are not in the identifier hash table, and all
596 have the same IDENTIFIER_STRING. */
599 make_conv_op_name (tree type
)
601 if (type
== error_mark_node
)
602 return error_mark_node
;
604 if (conv_type_names
== NULL
)
605 conv_type_names
= hash_table
<conv_type_hasher
>::create_ggc (31);
607 tree
*slot
= conv_type_names
->find_slot_with_hash
608 (type
, (hashval_t
) TYPE_UID (type
), INSERT
);
609 tree identifier
= *slot
;
612 /* Create a raw IDENTIFIER outside of the identifier hash
614 identifier
= copy_node (conv_op_identifier
);
616 /* Just in case something managed to bind. */
617 IDENTIFIER_BINDING (identifier
) = NULL
;
619 /* Hang TYPE off the identifier so it can be found easily later
620 when performing conversions. */
621 TREE_TYPE (identifier
) = type
;
629 /* Wrapper around build_lang_decl_loc(). Should gradually move to
630 build_lang_decl_loc() and then rename build_lang_decl_loc() back to
631 build_lang_decl(). */
634 build_lang_decl (enum tree_code code
, tree name
, tree type
)
636 return build_lang_decl_loc (input_location
, code
, name
, type
);
639 /* Build a decl from CODE, NAME, TYPE declared at LOC, and then add
640 DECL_LANG_SPECIFIC info to the result. */
643 build_lang_decl_loc (location_t loc
, enum tree_code code
, tree name
, tree type
)
647 t
= build_decl (loc
, code
, name
, type
);
648 retrofit_lang_decl (t
);
653 /* Maybe add a raw lang_decl to T, a decl. Return true if it needed
657 maybe_add_lang_decl_raw (tree t
, bool decomp_p
)
660 lang_decl_selector sel
;
663 sel
= lds_decomp
, size
= sizeof (struct lang_decl_decomp
);
664 else if (TREE_CODE (t
) == FUNCTION_DECL
)
665 sel
= lds_fn
, size
= sizeof (struct lang_decl_fn
);
666 else if (TREE_CODE (t
) == NAMESPACE_DECL
)
667 sel
= lds_ns
, size
= sizeof (struct lang_decl_ns
);
668 else if (TREE_CODE (t
) == PARM_DECL
)
669 sel
= lds_parm
, size
= sizeof (struct lang_decl_parm
);
670 else if (LANG_DECL_HAS_MIN (t
))
671 sel
= lds_min
, size
= sizeof (struct lang_decl_min
);
676 = (struct lang_decl
*) ggc_internal_cleared_alloc (size
);
678 ld
->u
.base
.selector
= sel
;
679 DECL_LANG_SPECIFIC (t
) = ld
;
682 /* Who'd create a namespace, only to put nothing in it? */
683 ld
->u
.ns
.bindings
= hash_table
<named_decl_hash
>::create_ggc (499);
685 if (GATHER_STATISTICS
)
687 tree_node_counts
[(int)lang_decl
] += 1;
688 tree_node_sizes
[(int)lang_decl
] += size
;
693 /* T has just had a decl_lang_specific added. Initialize its
697 set_decl_linkage (tree t
)
699 if (current_lang_name
== lang_name_cplusplus
700 || decl_linkage (t
) == lk_none
)
701 SET_DECL_LANGUAGE (t
, lang_cplusplus
);
702 else if (current_lang_name
== lang_name_c
)
703 SET_DECL_LANGUAGE (t
, lang_c
);
708 /* T is a VAR_DECL node that needs to be a decomposition of BASE. */
711 fit_decomposition_lang_decl (tree t
, tree base
)
713 if (struct lang_decl
*orig_ld
= DECL_LANG_SPECIFIC (t
))
715 if (orig_ld
->u
.base
.selector
== lds_min
)
717 maybe_add_lang_decl_raw (t
, true);
718 memcpy (DECL_LANG_SPECIFIC (t
), orig_ld
,
719 sizeof (struct lang_decl_min
));
720 /* Reset selector, which will have been bashed by the
722 DECL_LANG_SPECIFIC (t
)->u
.base
.selector
= lds_decomp
;
725 gcc_checking_assert (orig_ld
->u
.base
.selector
== lds_decomp
);
729 maybe_add_lang_decl_raw (t
, true);
730 set_decl_linkage (t
);
733 DECL_DECOMP_BASE (t
) = base
;
736 /* Add DECL_LANG_SPECIFIC info to T, if it needs one. Generally
737 every C++ decl needs one, but C builtins etc do not. */
740 retrofit_lang_decl (tree t
)
742 if (DECL_LANG_SPECIFIC (t
))
745 if (maybe_add_lang_decl_raw (t
, false))
746 set_decl_linkage (t
);
750 cxx_dup_lang_specific_decl (tree node
)
754 if (! DECL_LANG_SPECIFIC (node
))
757 switch (DECL_LANG_SPECIFIC (node
)->u
.base
.selector
)
760 size
= sizeof (struct lang_decl_min
);
763 size
= sizeof (struct lang_decl_fn
);
766 size
= sizeof (struct lang_decl_ns
);
769 size
= sizeof (struct lang_decl_parm
);
772 size
= sizeof (struct lang_decl_decomp
);
778 struct lang_decl
*ld
= (struct lang_decl
*) ggc_internal_alloc (size
);
779 memcpy (ld
, DECL_LANG_SPECIFIC (node
), size
);
780 DECL_LANG_SPECIFIC (node
) = ld
;
782 if (GATHER_STATISTICS
)
784 tree_node_counts
[(int)lang_decl
] += 1;
785 tree_node_sizes
[(int)lang_decl
] += size
;
789 /* Copy DECL, including any language-specific parts. */
792 copy_decl (tree decl MEM_STAT_DECL
)
796 copy
= copy_node (decl PASS_MEM_STAT
);
797 cxx_dup_lang_specific_decl (copy
);
801 /* Replace the shared language-specific parts of NODE with a new copy. */
804 copy_lang_type (tree node
)
806 if (! TYPE_LANG_SPECIFIC (node
))
810 = (struct lang_type
*) ggc_internal_alloc (sizeof (struct lang_type
));
812 memcpy (lt
, TYPE_LANG_SPECIFIC (node
), (sizeof (struct lang_type
)));
813 TYPE_LANG_SPECIFIC (node
) = lt
;
815 if (GATHER_STATISTICS
)
817 tree_node_counts
[(int)lang_type
] += 1;
818 tree_node_sizes
[(int)lang_type
] += sizeof (struct lang_type
);
822 /* Copy TYPE, including any language-specific parts. */
825 copy_type (tree type MEM_STAT_DECL
)
829 copy
= copy_node (type PASS_MEM_STAT
);
830 copy_lang_type (copy
);
834 /* Add a raw lang_type to T, a type, should it need one. */
837 maybe_add_lang_type_raw (tree t
)
839 if (!RECORD_OR_UNION_CODE_P (TREE_CODE (t
)))
842 TYPE_LANG_SPECIFIC (t
)
843 = (struct lang_type
*) (ggc_internal_cleared_alloc
844 (sizeof (struct lang_type
)));
846 if (GATHER_STATISTICS
)
848 tree_node_counts
[(int)lang_type
] += 1;
849 tree_node_sizes
[(int)lang_type
] += sizeof (struct lang_type
);
856 cxx_make_type (enum tree_code code
)
858 tree t
= make_node (code
);
860 if (maybe_add_lang_type_raw (t
))
862 /* Set up some flags that give proper default behavior. */
863 struct c_fileinfo
*finfo
=
864 get_fileinfo (LOCATION_FILE (input_location
));
865 SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t
, finfo
->interface_unknown
);
866 CLASSTYPE_INTERFACE_ONLY (t
) = finfo
->interface_only
;
873 make_class_type (enum tree_code code
)
875 tree t
= cxx_make_type (code
);
876 SET_CLASS_TYPE_P (t
, 1);
880 /* Returns true if we are currently in the main source file, or in a
881 template instantiation started from the main source file. */
884 in_main_input_context (void)
886 struct tinst_level
*tl
= outermost_tinst_level();
889 return filename_cmp (main_input_filename
,
890 LOCATION_FILE (tl
->locus
)) == 0;
892 return filename_cmp (main_input_filename
, LOCATION_FILE (input_location
)) == 0;
895 #include "gt-cp-lex.h"