Line data Source code
1 : /* Some code common to C++ and ObjC++ front ends.
2 : Copyright (C) 2004-2026 Free Software Foundation, Inc.
3 : Contributed by Ziemowit Laski <zlaski@apple.com>
4 :
5 : This file is part of GCC.
6 :
7 : GCC is free software; you can redistribute it and/or modify it under
8 : the terms of the GNU General Public License as published by the Free
9 : Software Foundation; either version 3, or (at your option) any later
10 : version.
11 :
12 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 : for more details.
16 :
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/>. */
20 :
21 : #include "config.h"
22 : #include "system.h"
23 : #include "coretypes.h"
24 : #include "cp-tree.h"
25 : #include "cp-objcp-common.h"
26 : #include "c-family/c-common.h"
27 : #include "dwarf2.h"
28 : #include "stringpool.h"
29 :
30 : /* Class to determine whether a given C++ language feature is available.
31 : Used to implement __has_{feature,extension}. */
32 :
33 : struct cp_feature_selector
34 : {
35 : enum
36 : {
37 : DIALECT,
38 : FLAG
39 : } kind;
40 :
41 : enum class result
42 : {
43 : NONE,
44 : EXT,
45 : FEAT
46 : };
47 :
48 : union
49 : {
50 : const int *enable_flag;
51 : struct {
52 : enum cxx_dialect feat;
53 : enum cxx_dialect ext;
54 : } dialect;
55 : };
56 :
57 : constexpr cp_feature_selector (const int *flag)
58 : : kind (FLAG), enable_flag (flag) {}
59 : constexpr cp_feature_selector (enum cxx_dialect feat,
60 : enum cxx_dialect ext)
61 : : kind (DIALECT), dialect{feat, ext} {}
62 : constexpr cp_feature_selector (enum cxx_dialect feat)
63 : : cp_feature_selector (feat, feat) {}
64 :
65 : inline result has_feature () const;
66 : };
67 :
68 : /* Check whether this language feature is available as a feature,
69 : extension, or not at all. */
70 :
71 : cp_feature_selector::result
72 1079308 : cp_feature_selector::has_feature () const
73 : {
74 1079308 : switch (kind)
75 : {
76 1033380 : case DIALECT:
77 1033380 : if (cxx_dialect >= dialect.feat)
78 : return result::FEAT;
79 61425 : else if (cxx_dialect >= dialect.ext)
80 : return result::EXT;
81 : else
82 53230 : return result::NONE;
83 45928 : case FLAG:
84 45928 : return *enable_flag ? result::FEAT : result::NONE;
85 : }
86 :
87 0 : gcc_unreachable ();
88 : }
89 :
90 : /* Information about a C++ language feature which can be queried
91 : through __has_{feature,extension}. IDENT is the name of the feature,
92 : and SELECTOR encodes how to compute whether the feature is available. */
93 :
94 : struct cp_feature_info
95 : {
96 : const char *ident;
97 : cp_feature_selector selector;
98 : };
99 :
100 : /* Table of features for __has_{feature,extension}. */
101 :
102 : static constexpr cp_feature_info cp_feature_table[] =
103 : {
104 : { "cxx_exceptions", &flag_exceptions },
105 : { "cxx_rtti", &flag_rtti },
106 : { "cxx_access_control_sfinae", { cxx11, cxx98 } },
107 : { "cxx_alias_templates", cxx11 },
108 : { "cxx_alignas", cxx11 },
109 : { "cxx_alignof", cxx11 },
110 : { "cxx_attributes", cxx11 },
111 : { "cxx_constexpr", cxx11 },
112 : { "cxx_decltype", cxx11 },
113 : { "cxx_decltype_incomplete_return_types", cxx11 },
114 : { "cxx_default_function_template_args", cxx11 },
115 : { "cxx_defaulted_functions", cxx11 },
116 : { "cxx_delegating_constructors", cxx11 },
117 : { "cxx_deleted_functions", cxx11 },
118 : { "cxx_explicit_conversions", cxx11 },
119 : { "cxx_generalized_initializers", cxx11 },
120 : { "cxx_implicit_moves", cxx11 },
121 : { "cxx_inheriting_constructors", cxx11 },
122 : { "cxx_inline_namespaces", { cxx11, cxx98 } },
123 : { "cxx_lambdas", cxx11 },
124 : { "cxx_local_type_template_args", cxx11 },
125 : { "cxx_noexcept", cxx11 },
126 : { "cxx_nonstatic_member_init", cxx11 },
127 : { "cxx_nullptr", cxx11 },
128 : { "cxx_override_control", cxx11 },
129 : { "cxx_reference_qualified_functions", cxx11 },
130 : { "cxx_range_for", cxx11 },
131 : { "cxx_raw_string_literals", cxx11 },
132 : { "cxx_rvalue_references", cxx11 },
133 : { "cxx_static_assert", cxx11 },
134 : { "cxx_thread_local", cxx11 },
135 : { "cxx_auto_type", cxx11 },
136 : { "cxx_strong_enums", cxx11 },
137 : { "cxx_trailing_return", cxx11 },
138 : { "cxx_unicode_literals", cxx11 },
139 : { "cxx_unrestricted_unions", cxx11 },
140 : { "cxx_user_literals", cxx11 },
141 : { "cxx_variadic_templates", { cxx11, cxx98 } },
142 : { "cxx_binary_literals", { cxx14, cxx98 } },
143 : { "cxx_contextual_conversions", { cxx14, cxx98 } },
144 : { "cxx_decltype_auto", cxx14 },
145 : { "cxx_aggregate_nsdmi", cxx14 },
146 : { "cxx_init_captures", { cxx14, cxx11 } },
147 : { "cxx_generic_lambdas", cxx14 },
148 : { "cxx_relaxed_constexpr", cxx14 },
149 : { "cxx_return_type_deduction", cxx14 },
150 : { "cxx_variable_templates", cxx14 },
151 : };
152 :
153 : /* Register C++ language features for __has_{feature,extension}. */
154 :
155 : void
156 22964 : cp_register_features ()
157 : {
158 22964 : using result = cp_feature_selector::result;
159 :
160 1102272 : for (unsigned i = 0; i < ARRAY_SIZE (cp_feature_table); i++)
161 : {
162 1079308 : const cp_feature_info *info = cp_feature_table + i;
163 1079308 : const auto res = info->selector.has_feature ();
164 1079308 : if (res == result::NONE)
165 54778 : continue;
166 :
167 1024530 : c_common_register_feature (info->ident, res == result::FEAT);
168 : }
169 22964 : }
170 :
171 : /* Special routine to get the alias set for C++. */
172 :
173 : alias_set_type
174 410250871 : cxx_get_alias_set (tree t)
175 : {
176 410250871 : if (IS_FAKE_BASE_TYPE (t))
177 : /* The base variant of a type must be in the same alias set as the
178 : complete type. */
179 55221 : return get_alias_set (TYPE_CONTEXT (t));
180 :
181 410195650 : return c_common_get_alias_set (t);
182 : }
183 :
184 : /* Called from check_global_declaration. */
185 :
186 : bool
187 2962 : cxx_warn_unused_global_decl (const_tree decl)
188 : {
189 2962 : if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl))
190 : return false;
191 93 : if (DECL_IN_SYSTEM_HEADER (decl))
192 0 : return false;
193 :
194 : return true;
195 : }
196 :
197 : /* Langhook for tree_size: determine size of our 'x' and 'c' nodes. */
198 : size_t
199 2758380941 : cp_tree_size (enum tree_code code)
200 : {
201 2758380941 : gcc_checking_assert (code >= NUM_TREE_CODES);
202 2758380941 : switch (code)
203 : {
204 : case PTRMEM_CST: return sizeof (ptrmem_cst);
205 : case BASELINK: return sizeof (tree_baselink);
206 : case TEMPLATE_PARM_INDEX: return sizeof (template_parm_index);
207 : case DEFERRED_PARSE: return sizeof (tree_deferred_parse);
208 : case DEFERRED_NOEXCEPT: return sizeof (tree_deferred_noexcept);
209 : case OVERLOAD: return sizeof (tree_overload);
210 : case STATIC_ASSERT: return sizeof (tree_static_assert);
211 : #if 0
212 : /* This would match cp_common_init_ts, but breaks GC because
213 : tree_node_structure_for_code returns TS_TYPE_NON_COMMON for all
214 : types. */
215 : case UNBOUND_CLASS_TEMPLATE:
216 : case TYPE_ARGUMENT_PACK: return sizeof (tree_type_common);
217 : #endif
218 : case ARGUMENT_PACK_SELECT: return sizeof (tree_argument_pack_select);
219 : case TRAIT_EXPR: return sizeof (tree_trait_expr);
220 1671803 : case LAMBDA_EXPR: return sizeof (tree_lambda_expr);
221 : case TEMPLATE_INFO: return sizeof (tree_template_info);
222 : case CONSTRAINT_INFO: return sizeof (tree_constraint_info);
223 : case USERDEF_LITERAL: return sizeof (tree_userdef_literal);
224 239562694 : case TEMPLATE_DECL: return sizeof (tree_template_decl);
225 : case ASSERTION_STMT: return sizeof (tree_exp);
226 : case PRECONDITION_STMT: return sizeof (tree_exp);
227 : case POSTCONDITION_STMT: return sizeof (tree_exp);
228 : case TU_LOCAL_ENTITY: return sizeof (tree_tu_local_entity);
229 : case REQUIRES_EXPR: return sizeof (tree_requires_expr);
230 830263284 : default:
231 830263284 : switch (TREE_CODE_CLASS (code))
232 : {
233 : case tcc_declaration: return sizeof (tree_decl_non_common);
234 768410881 : case tcc_type: return sizeof (tree_type_non_common);
235 0 : default: gcc_unreachable ();
236 : }
237 : }
238 : /* NOTREACHED */
239 : }
240 :
241 : /* Returns true if T is a variably modified type, in the sense of C99.
242 : FN is as passed to variably_modified_p.
243 : This routine needs only check cases that cannot be handled by the
244 : language-independent logic in tree.cc. */
245 :
246 : bool
247 2213175463 : cp_var_mod_type_p (tree type, tree fn)
248 : {
249 : /* If TYPE is a pointer-to-member, it is variably modified if either
250 : the class or the member are variably modified. */
251 2213175463 : if (TYPE_PTRMEM_P (type))
252 1737349 : return (variably_modified_type_p (TYPE_PTRMEM_CLASS_TYPE (type), fn)
253 1737349 : || variably_modified_type_p (TYPE_PTRMEM_POINTED_TO_TYPE (type),
254 : fn));
255 :
256 : /* All other types are not variably modified. */
257 : return false;
258 : }
259 :
260 : /* This compares two types for equivalence ("compatible" in C-based languages).
261 : This routine should only return 1 if it is sure. It should not be used
262 : in contexts where erroneously returning 0 causes problems. */
263 :
264 : int
265 1412249 : cxx_types_compatible_p (tree x, tree y)
266 : {
267 1412249 : return same_type_ignoring_top_level_qualifiers_p (x, y);
268 : }
269 :
270 : static GTY((cache)) type_tree_cache_map *debug_type_map;
271 :
272 : /* Return a type to use in the debug info instead of TYPE, or NULL_TREE to
273 : keep TYPE. */
274 :
275 : tree
276 1330143441 : cp_get_debug_type (const_tree type)
277 : {
278 1330143441 : tree dtype = NULL_TREE;
279 :
280 1330143441 : if (TYPE_PTRMEMFUNC_P (type) && !typedef_variant_p (type))
281 250646 : dtype = build_offset_type (TYPE_PTRMEMFUNC_OBJECT_TYPE (type),
282 250646 : TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type)));
283 :
284 : /* We cannot simply return the debug type here because the function uses
285 : the type canonicalization hashtable, which is GC-ed, so its behavior
286 : depends on the actual collection points. Since we are building these
287 : types on the fly for the debug info only, they would not be attached
288 : to any GC root and always be swept, so we would make the contents of
289 : the debug info depend on the collection points. */
290 1330143441 : if (dtype)
291 : {
292 250646 : tree ktype = const_cast<tree> (type);
293 491682 : if (tree *slot = hash_map_safe_get (debug_type_map, ktype))
294 219828 : return *slot;
295 30818 : hash_map_safe_put<hm_ggc> (debug_type_map, ktype, dtype);
296 : }
297 :
298 : return dtype;
299 : }
300 :
301 : /* Return -1 if dwarf ATTR shouldn't be added for DECL, or the attribute
302 : value otherwise. */
303 : int
304 620845567 : cp_decl_dwarf_attribute (const_tree decl, int attr)
305 : {
306 620845567 : if (decl == NULL_TREE)
307 : return -1;
308 :
309 620845567 : switch (attr)
310 : {
311 96326743 : case DW_AT_explicit:
312 96326743 : if (TREE_CODE (decl) == FUNCTION_DECL
313 96326743 : && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl))
314 192653401 : && DECL_NONCONVERTING_P (decl))
315 2783853 : return 1;
316 : break;
317 :
318 96326725 : case DW_AT_deleted:
319 96326725 : if (TREE_CODE (decl) == FUNCTION_DECL
320 96326725 : && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl))
321 192653365 : && DECL_DELETED_FN (decl))
322 3059802 : return 1;
323 : break;
324 :
325 97704721 : case DW_AT_defaulted:
326 97704721 : if (TREE_CODE (decl) == FUNCTION_DECL
327 97704721 : && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl))
328 195409357 : && DECL_DEFAULTED_FN (decl))
329 : {
330 6984415 : if (DECL_DEFAULTED_IN_CLASS_P (decl))
331 : return DW_DEFAULTED_in_class;
332 :
333 1093827 : if (DECL_DEFAULTED_OUTSIDE_CLASS_P (decl))
334 590 : return DW_DEFAULTED_out_of_class;
335 : }
336 : break;
337 :
338 58427453 : case DW_AT_const_expr:
339 58427453 : if (VAR_OR_FUNCTION_DECL_P (decl) && DECL_DECLARED_CONSTEXPR_P (decl))
340 52895924 : return 1;
341 : break;
342 :
343 96326725 : case DW_AT_reference:
344 96326725 : if (TREE_CODE (decl) == FUNCTION_DECL
345 96326725 : && DECL_IOBJ_MEMBER_FUNCTION_P (decl)
346 82277413 : && FUNCTION_REF_QUALIFIED (TREE_TYPE (decl))
347 96424607 : && !FUNCTION_RVALUE_QUALIFIED (TREE_TYPE (decl)))
348 35987 : return 1;
349 : break;
350 :
351 96326725 : case DW_AT_rvalue_reference:
352 96326725 : if (TREE_CODE (decl) == FUNCTION_DECL
353 96326725 : && DECL_IOBJ_MEMBER_FUNCTION_P (decl)
354 82277413 : && FUNCTION_REF_QUALIFIED (TREE_TYPE (decl))
355 96424607 : && FUNCTION_RVALUE_QUALIFIED (TREE_TYPE (decl)))
356 61895 : return 1;
357 : break;
358 :
359 78725902 : case DW_AT_inline:
360 78725902 : if (VAR_P (decl) && DECL_INLINE_VAR_P (decl))
361 : {
362 69956362 : if (DECL_VAR_DECLARED_INLINE_P (decl))
363 : return DW_INL_declared_inlined;
364 : else
365 40830581 : return DW_INL_inlined;
366 : }
367 : break;
368 :
369 680573 : case DW_AT_export_symbols:
370 680573 : if (TREE_CODE (decl) == NAMESPACE_DECL
371 680573 : && (DECL_NAMESPACE_INLINE_P (decl)
372 407451 : || (DECL_NAME (decl) == NULL_TREE && dwarf_version >= 5)))
373 274339 : return 1;
374 : break;
375 :
376 : default:
377 : break;
378 : }
379 :
380 : return -1;
381 : }
382 :
383 : /* Return -1 if dwarf ATTR shouldn't be added for TYPE, or the attribute
384 : value otherwise. */
385 : int
386 848557 : cp_type_dwarf_attribute (const_tree type, int attr)
387 : {
388 848557 : if (type == NULL_TREE)
389 : return -1;
390 :
391 848557 : switch (attr)
392 : {
393 325085 : case DW_AT_reference:
394 325085 : if (FUNC_OR_METHOD_TYPE_P (type)
395 325085 : && FUNCTION_REF_QUALIFIED (type)
396 325236 : && !FUNCTION_RVALUE_QUALIFIED (type))
397 104 : return 1;
398 : break;
399 :
400 325085 : case DW_AT_rvalue_reference:
401 325085 : if (FUNC_OR_METHOD_TYPE_P (type)
402 325085 : && FUNCTION_REF_QUALIFIED (type)
403 325236 : && FUNCTION_RVALUE_QUALIFIED (type))
404 47 : return 1;
405 : break;
406 :
407 198387 : case DW_AT_export_symbols:
408 198387 : if (ANON_AGGR_TYPE_P (type))
409 198387 : return 1;
410 : break;
411 :
412 : default:
413 : break;
414 : }
415 :
416 : return -1;
417 : }
418 :
419 : /* Return the unit size of TYPE without reusable tail padding. */
420 :
421 : tree
422 89010 : cp_unit_size_without_reusable_padding (tree type)
423 : {
424 89010 : if (CLASS_TYPE_P (type))
425 89010 : return CLASSTYPE_SIZE_UNIT (type);
426 0 : return TYPE_SIZE_UNIT (type);
427 : }
428 :
429 : /* Returns type corresponding to FIELD's type when FIELD is a C++ base class
430 : i.e., type without virtual base classes or tail padding. Returns
431 : NULL_TREE otherwise. */
432 :
433 : tree
434 14831 : cp_classtype_as_base (const_tree field)
435 : {
436 14831 : if (DECL_FIELD_IS_BASE (field))
437 : {
438 307 : tree type = TREE_TYPE (field);
439 307 : if (TYPE_LANG_SPECIFIC (type))
440 300 : return CLASSTYPE_AS_BASE (type);
441 : }
442 : return NULL_TREE;
443 : }
444 :
445 : /* Stubs to keep c-opts.cc happy. */
446 : void
447 99257 : push_file_scope (void)
448 : {
449 99257 : }
450 :
451 : void
452 99119 : pop_file_scope (void)
453 : {
454 99119 : }
455 :
456 : /* c-pragma.cc needs to query whether a decl has extern "C" linkage. */
457 : bool
458 63135233 : has_c_linkage (const_tree decl)
459 : {
460 63135233 : return DECL_EXTERN_C_P (decl);
461 : }
462 :
463 : /* Return true if stmt can fall through. Used by block_may_fallthru
464 : default case. */
465 :
466 : bool
467 6393277 : cxx_block_may_fallthru (const_tree stmt)
468 : {
469 6393277 : switch (TREE_CODE (stmt))
470 : {
471 2813041 : case EXPR_STMT:
472 2813041 : return block_may_fallthru (EXPR_STMT_EXPR (stmt));
473 :
474 : case THROW_EXPR:
475 : return false;
476 :
477 859744 : case IF_STMT:
478 859744 : if (IF_STMT_CONSTEXPR_P (stmt))
479 : {
480 1247 : if (integer_nonzerop (IF_COND (stmt)))
481 138 : return block_may_fallthru (THEN_CLAUSE (stmt));
482 1109 : if (integer_zerop (IF_COND (stmt)))
483 36 : return block_may_fallthru (ELSE_CLAUSE (stmt));
484 : }
485 859570 : if (block_may_fallthru (THEN_CLAUSE (stmt)))
486 : return true;
487 181411 : return block_may_fallthru (ELSE_CLAUSE (stmt));
488 :
489 11 : case CLEANUP_STMT:
490 : /* Just handle the try/finally cases. */
491 11 : if (!CLEANUP_EH_ONLY (stmt))
492 : {
493 11 : return (block_may_fallthru (CLEANUP_BODY (stmt))
494 19 : && block_may_fallthru (CLEANUP_EXPR (stmt)));
495 : }
496 : return true;
497 :
498 2702710 : default:
499 2702710 : return c_block_may_fallthru (stmt);
500 : }
501 : }
502 :
503 : /* Return the list of decls in the global namespace. */
504 :
505 : tree
506 0 : cp_get_global_decls ()
507 : {
508 0 : return NAMESPACE_LEVEL (global_namespace)->names;
509 : }
510 :
511 : /* Push DECL into the current (namespace) scope. */
512 :
513 : tree
514 2011028 : cp_pushdecl (tree decl)
515 : {
516 2011028 : DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace);
517 2011028 : return pushdecl (decl);
518 : }
519 :
520 : /* Get the global value binding of NAME. Called directly from
521 : c-common.cc, not via a hook. */
522 :
523 : tree
524 3524997 : identifier_global_value (tree name)
525 : {
526 3524997 : return get_global_binding (name);
527 : }
528 :
529 : /* Similarly, but return struct/class/union NAME instead. */
530 :
531 : tree
532 39 : identifier_global_tag (tree name)
533 : {
534 39 : tree ret = lookup_qualified_name (global_namespace, name, LOOK_want::TYPE,
535 : /*complain*/false);
536 39 : if (ret == error_mark_node)
537 3 : return NULL_TREE;
538 : return ret;
539 : }
540 :
541 : /* Returns non-zero (result of __has_builtin) if NAME refers to a built-in
542 : function or function-like operator. */
543 :
544 : int
545 8087617 : names_builtin_p (const char *name)
546 : {
547 8087617 : tree id = get_identifier (name);
548 8087617 : if (tree binding = get_global_binding (id))
549 : {
550 1763700 : if (TREE_CODE (binding) == FUNCTION_DECL
551 1763700 : && DECL_IS_UNDECLARED_BUILTIN (binding))
552 : return 1;
553 :
554 : /* Handle the case when an overload for a built-in name exists. */
555 9 : if (TREE_CODE (binding) != OVERLOAD)
556 : return 0;
557 :
558 9 : for (ovl_iterator it (binding); it; ++it)
559 : {
560 9 : tree decl = *it;
561 9 : if (DECL_IS_UNDECLARED_BUILTIN (decl))
562 9 : return 1;
563 : }
564 : }
565 :
566 : /* Check for built-in traits. */
567 6323917 : if (IDENTIFIER_TRAIT_P (id))
568 : return 1;
569 :
570 : /* Also detect common reserved C++ words that aren't strictly built-in
571 : functions. */
572 254491 : switch (C_RID_CODE (id))
573 : {
574 : case RID_ADDRESSOF:
575 : case RID_BUILTIN_CONVERTVECTOR:
576 : case RID_BUILTIN_HAS_ATTRIBUTE:
577 : case RID_BUILTIN_SHUFFLE:
578 : case RID_BUILTIN_SHUFFLEVECTOR:
579 : case RID_BUILTIN_LAUNDER:
580 : case RID_BUILTIN_ASSOC_BARRIER:
581 : case RID_BUILTIN_BIT_CAST:
582 : case RID_OFFSETOF:
583 : case RID_VA_ARG:
584 : case RID_C23_VA_START:
585 : return 1;
586 : case RID_BUILTIN_OPERATOR_NEW:
587 : case RID_BUILTIN_OPERATOR_DELETE:
588 : return 201802L;
589 : default:
590 : break;
591 : }
592 :
593 : return 0;
594 : }
595 :
596 : /* Register c++-specific dumps. */
597 :
598 : void
599 100804 : cp_register_dumps (gcc::dump_manager *dumps)
600 : {
601 201608 : class_dump_id = dumps->dump_register
602 100804 : (".class", "lang-class", "lang-class", DK_lang, OPTGROUP_NONE, false);
603 :
604 201608 : module_dump_id = dumps->dump_register
605 100804 : (".module", "lang-module", "lang-module", DK_lang, OPTGROUP_NONE, false);
606 :
607 201608 : raw_dump_id = dumps->dump_register
608 100804 : (".raw", "lang-raw", "lang-raw", DK_lang, OPTGROUP_NONE, false);
609 201608 : coro_dump_id = dumps->dump_register
610 100804 : (".coro", "lang-coro", "lang-coro", DK_lang, OPTGROUP_NONE, false);
611 201608 : tinst_dump_id = dumps->dump_register
612 100804 : (".tinst", "lang-tinst", "lang-tinst", DK_lang, OPTGROUP_NONE, false);
613 100804 : }
614 :
615 : void
616 100804 : cp_common_init_ts (void)
617 : {
618 : /* With type. */
619 100804 : MARK_TS_TYPED (PTRMEM_CST);
620 100804 : MARK_TS_TYPED (LAMBDA_EXPR);
621 100804 : MARK_TS_TYPED (TYPE_ARGUMENT_PACK);
622 100804 : MARK_TS_TYPED (TRAIT_EXPR);
623 100804 : MARK_TS_TYPED (REQUIRES_EXPR);
624 :
625 : /* Random new trees. */
626 100804 : MARK_TS_COMMON (BASELINK);
627 100804 : MARK_TS_COMMON (OVERLOAD);
628 100804 : MARK_TS_COMMON (TEMPLATE_PARM_INDEX);
629 :
630 : /* New decls. */
631 100804 : MARK_TS_DECL_COMMON (TEMPLATE_DECL);
632 :
633 100804 : MARK_TS_DECL_NON_COMMON (USING_DECL);
634 :
635 : /* New Types. */
636 100804 : MARK_TS_TYPE_COMMON (UNBOUND_CLASS_TEMPLATE);
637 100804 : MARK_TS_TYPE_COMMON (TYPE_ARGUMENT_PACK);
638 100804 : MARK_TS_TYPE_COMMON (DEPENDENT_OPERATOR_TYPE);
639 :
640 100804 : MARK_TS_TYPE_NON_COMMON (DECLTYPE_TYPE);
641 100804 : MARK_TS_TYPE_NON_COMMON (TYPENAME_TYPE);
642 100804 : MARK_TS_TYPE_NON_COMMON (TYPEOF_TYPE);
643 100804 : MARK_TS_TYPE_NON_COMMON (TRAIT_TYPE);
644 100804 : MARK_TS_TYPE_NON_COMMON (BOUND_TEMPLATE_TEMPLATE_PARM);
645 100804 : MARK_TS_TYPE_NON_COMMON (TEMPLATE_TEMPLATE_PARM);
646 100804 : MARK_TS_TYPE_NON_COMMON (TEMPLATE_TYPE_PARM);
647 100804 : MARK_TS_TYPE_NON_COMMON (TYPE_PACK_EXPANSION);
648 100804 : MARK_TS_TYPE_NON_COMMON (PACK_INDEX_TYPE);
649 100804 : MARK_TS_TYPE_NON_COMMON (META_TYPE);
650 100804 : MARK_TS_TYPE_NON_COMMON (SPLICE_SCOPE);
651 :
652 : /* Statements. */
653 100804 : MARK_TS_EXP (CLEANUP_STMT);
654 100804 : MARK_TS_EXP (EH_SPEC_BLOCK);
655 100804 : MARK_TS_EXP (HANDLER);
656 100804 : MARK_TS_EXP (IF_STMT);
657 100804 : MARK_TS_EXP (OMP_DEPOBJ);
658 100804 : MARK_TS_EXP (RANGE_FOR_STMT);
659 100804 : MARK_TS_EXP (TEMPLATE_FOR_STMT);
660 100804 : MARK_TS_EXP (TRY_BLOCK);
661 100804 : MARK_TS_EXP (USING_STMT);
662 :
663 : /* Random expressions. */
664 100804 : MARK_TS_EXP (ADDRESSOF_EXPR);
665 100804 : MARK_TS_EXP (AGGR_INIT_EXPR);
666 100804 : MARK_TS_EXP (ALIGNOF_EXPR);
667 100804 : MARK_TS_EXP (ARROW_EXPR);
668 100804 : MARK_TS_EXP (AT_ENCODE_EXPR);
669 100804 : MARK_TS_EXP (BIT_CAST_EXPR);
670 100804 : MARK_TS_EXP (CAST_EXPR);
671 100804 : MARK_TS_EXP (CONST_CAST_EXPR);
672 100804 : MARK_TS_EXP (CTOR_INITIALIZER);
673 100804 : MARK_TS_EXP (DELETE_EXPR);
674 100804 : MARK_TS_EXP (DOTSTAR_EXPR);
675 100804 : MARK_TS_EXP (DYNAMIC_CAST_EXPR);
676 100804 : MARK_TS_EXP (EMPTY_CLASS_EXPR);
677 100804 : MARK_TS_EXP (EXPR_STMT);
678 100804 : MARK_TS_EXP (IMPLICIT_CONV_EXPR);
679 100804 : MARK_TS_EXP (MEMBER_REF);
680 100804 : MARK_TS_EXP (MODOP_EXPR);
681 100804 : MARK_TS_EXP (MUST_NOT_THROW_EXPR);
682 100804 : MARK_TS_EXP (NEW_EXPR);
683 100804 : MARK_TS_EXP (NOEXCEPT_EXPR);
684 100804 : MARK_TS_EXP (OFFSETOF_EXPR);
685 100804 : MARK_TS_EXP (OFFSET_REF);
686 100804 : MARK_TS_EXP (PSEUDO_DTOR_EXPR);
687 100804 : MARK_TS_EXP (REINTERPRET_CAST_EXPR);
688 100804 : MARK_TS_EXP (SCOPE_REF);
689 100804 : MARK_TS_EXP (STATIC_CAST_EXPR);
690 100804 : MARK_TS_EXP (STMT_EXPR);
691 100804 : MARK_TS_EXP (TAG_DEFN);
692 100804 : MARK_TS_EXP (TEMPLATE_ID_EXPR);
693 100804 : MARK_TS_EXP (THROW_EXPR);
694 100804 : MARK_TS_EXP (TYPEID_EXPR);
695 100804 : MARK_TS_EXP (TYPE_EXPR);
696 100804 : MARK_TS_EXP (UNARY_PLUS_EXPR);
697 100804 : MARK_TS_EXP (VEC_DELETE_EXPR);
698 100804 : MARK_TS_EXP (VEC_INIT_EXPR);
699 100804 : MARK_TS_EXP (VEC_NEW_EXPR);
700 100804 : MARK_TS_EXP (SPACESHIP_EXPR);
701 100804 : MARK_TS_EXP (SPLICE_EXPR);
702 100804 : MARK_TS_EXP (REFLECT_EXPR);
703 :
704 : /* Fold expressions. */
705 100804 : MARK_TS_EXP (BINARY_LEFT_FOLD_EXPR);
706 100804 : MARK_TS_EXP (BINARY_RIGHT_FOLD_EXPR);
707 100804 : MARK_TS_EXP (EXPR_PACK_EXPANSION);
708 100804 : MARK_TS_EXP (NONTYPE_ARGUMENT_PACK);
709 100804 : MARK_TS_EXP (UNARY_LEFT_FOLD_EXPR);
710 100804 : MARK_TS_EXP (UNARY_RIGHT_FOLD_EXPR);
711 100804 : MARK_TS_EXP (PACK_INDEX_EXPR);
712 :
713 : /* Constraints. */
714 100804 : MARK_TS_EXP (COMPOUND_REQ);
715 100804 : MARK_TS_EXP (CONJ_CONSTR);
716 100804 : MARK_TS_EXP (DISJ_CONSTR);
717 100804 : MARK_TS_EXP (ATOMIC_CONSTR);
718 100804 : MARK_TS_EXP (NESTED_REQ);
719 100804 : MARK_TS_EXP (SIMPLE_REQ);
720 100804 : MARK_TS_EXP (TYPE_REQ);
721 :
722 100804 : MARK_TS_EXP (CO_AWAIT_EXPR);
723 100804 : MARK_TS_EXP (CO_YIELD_EXPR);
724 100804 : MARK_TS_EXP (CO_RETURN_EXPR);
725 :
726 100804 : MARK_TS_EXP (ASSERTION_STMT);
727 100804 : MARK_TS_EXP (PRECONDITION_STMT);
728 100804 : MARK_TS_EXP (POSTCONDITION_STMT);
729 :
730 100804 : c_common_init_ts ();
731 100804 : }
732 :
733 : /* Handle C++-specficic options here. Punt to c_common otherwise. */
734 :
735 : bool
736 1967444 : cp_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
737 : int kind, location_t loc,
738 : const struct cl_option_handlers *handlers)
739 : {
740 1967444 : if (handle_module_option (unsigned (scode), arg, value))
741 : return true;
742 :
743 1966459 : return c_common_handle_option (scode, arg, value, kind, loc, handlers);
744 : }
745 :
746 : #include "gt-cp-cp-objcp-common.h"
|