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 1086452 : cp_feature_selector::has_feature () const
73 : {
74 1086452 : switch (kind)
75 : {
76 1040220 : case DIALECT:
77 1040220 : 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 46232 : case FLAG:
84 46232 : 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 23116 : cp_register_features ()
157 : {
158 23116 : using result = cp_feature_selector::result;
159 :
160 1109568 : for (unsigned i = 0; i < ARRAY_SIZE (cp_feature_table); i++)
161 : {
162 1086452 : const cp_feature_info *info = cp_feature_table + i;
163 1086452 : const auto res = info->selector.has_feature ();
164 1086452 : if (res == result::NONE)
165 54778 : continue;
166 :
167 1031674 : c_common_register_feature (info->ident, res == result::FEAT);
168 : }
169 23116 : }
170 :
171 : /* Special routine to get the alias set for C++. */
172 :
173 : alias_set_type
174 409944200 : cxx_get_alias_set (tree t)
175 : {
176 409944200 : 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 55167 : return get_alias_set (TYPE_CONTEXT (t));
180 :
181 409889033 : 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 2763874576 : cp_tree_size (enum tree_code code)
200 : {
201 2763874576 : gcc_checking_assert (code >= NUM_TREE_CODES);
202 2763874576 : 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 1673842 : 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 239872659 : 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 831860227 : default:
231 831860227 : switch (TREE_CODE_CLASS (code))
232 : {
233 : case tcc_declaration: return sizeof (tree_decl_non_common);
234 769863190 : 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 2217380697 : 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 2217380697 : if (TYPE_PTRMEM_P (type))
252 1738550 : return (variably_modified_type_p (TYPE_PTRMEM_CLASS_TYPE (type), fn)
253 1738550 : || 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 1413121 : cxx_types_compatible_p (tree x, tree y)
266 : {
267 1413121 : 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 1332007911 : cp_get_debug_type (const_tree type)
277 : {
278 1332007911 : tree dtype = NULL_TREE;
279 :
280 1332007911 : if (TYPE_PTRMEMFUNC_P (type) && !typedef_variant_p (type))
281 250810 : dtype = build_offset_type (TYPE_PTRMEMFUNC_OBJECT_TYPE (type),
282 250810 : 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 1332007911 : if (dtype)
291 : {
292 250810 : tree ktype = const_cast<tree> (type);
293 492004 : if (tree *slot = hash_map_safe_get (debug_type_map, ktype))
294 219970 : return *slot;
295 30840 : 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 621499501 : cp_decl_dwarf_attribute (const_tree decl, int attr)
305 : {
306 621499501 : if (decl == NULL_TREE)
307 : return -1;
308 :
309 621499501 : switch (attr)
310 : {
311 96417301 : case DW_AT_explicit:
312 96417301 : if (TREE_CODE (decl) == FUNCTION_DECL
313 96417301 : && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl))
314 192834517 : && DECL_NONCONVERTING_P (decl))
315 2787672 : return 1;
316 : break;
317 :
318 96417283 : case DW_AT_deleted:
319 96417283 : if (TREE_CODE (decl) == FUNCTION_DECL
320 96417283 : && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl))
321 192834481 : && DECL_DELETED_FN (decl))
322 3061910 : return 1;
323 : break;
324 :
325 97795784 : case DW_AT_defaulted:
326 97795784 : if (TREE_CODE (decl) == FUNCTION_DECL
327 97795784 : && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl))
328 195591483 : && DECL_DEFAULTED_FN (decl))
329 : {
330 6991441 : if (DECL_DEFAULTED_IN_CLASS_P (decl))
331 : return DW_DEFAULTED_in_class;
332 :
333 1094838 : if (DECL_DEFAULTED_OUTSIDE_CLASS_P (decl))
334 590 : return DW_DEFAULTED_out_of_class;
335 : }
336 : break;
337 :
338 58524889 : case DW_AT_const_expr:
339 58524889 : if (VAR_OR_FUNCTION_DECL_P (decl) && DECL_DECLARED_CONSTEXPR_P (decl))
340 52991636 : return 1;
341 : break;
342 :
343 96417283 : case DW_AT_reference:
344 96417283 : if (TREE_CODE (decl) == FUNCTION_DECL
345 96417283 : && DECL_IOBJ_MEMBER_FUNCTION_P (decl)
346 82363497 : && FUNCTION_REF_QUALIFIED (TREE_TYPE (decl))
347 96515267 : && !FUNCTION_RVALUE_QUALIFIED (TREE_TYPE (decl)))
348 36012 : return 1;
349 : break;
350 :
351 96417283 : case DW_AT_rvalue_reference:
352 96417283 : if (TREE_CODE (decl) == FUNCTION_DECL
353 96417283 : && DECL_IOBJ_MEMBER_FUNCTION_P (decl)
354 82363497 : && FUNCTION_REF_QUALIFIED (TREE_TYPE (decl))
355 96515267 : && FUNCTION_RVALUE_QUALIFIED (TREE_TYPE (decl)))
356 61972 : return 1;
357 : break;
358 :
359 78828857 : case DW_AT_inline:
360 78828857 : if (VAR_P (decl) && DECL_INLINE_VAR_P (decl))
361 : {
362 70050590 : if (DECL_VAR_DECLARED_INLINE_P (decl))
363 : return DW_INL_declared_inlined;
364 : else
365 40844973 : return DW_INL_inlined;
366 : }
367 : break;
368 :
369 680821 : case DW_AT_export_symbols:
370 680821 : if (TREE_CODE (decl) == NAMESPACE_DECL
371 680821 : && (DECL_NAMESPACE_INLINE_P (decl)
372 407604 : || (DECL_NAME (decl) == NULL_TREE && dwarf_version >= 5)))
373 274434 : 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 849159 : cp_type_dwarf_attribute (const_tree type, int attr)
387 : {
388 849159 : if (type == NULL_TREE)
389 : return -1;
390 :
391 849159 : switch (attr)
392 : {
393 325349 : case DW_AT_reference:
394 325349 : if (FUNC_OR_METHOD_TYPE_P (type)
395 325349 : && FUNCTION_REF_QUALIFIED (type)
396 325500 : && !FUNCTION_RVALUE_QUALIFIED (type))
397 104 : return 1;
398 : break;
399 :
400 325349 : case DW_AT_rvalue_reference:
401 325349 : if (FUNC_OR_METHOD_TYPE_P (type)
402 325349 : && FUNCTION_REF_QUALIFIED (type)
403 325500 : && FUNCTION_RVALUE_QUALIFIED (type))
404 47 : return 1;
405 : break;
406 :
407 198461 : case DW_AT_export_symbols:
408 198461 : if (ANON_AGGR_TYPE_P (type))
409 198461 : 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 89085 : cp_unit_size_without_reusable_padding (tree type)
423 : {
424 89085 : if (CLASS_TYPE_P (type))
425 89085 : 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 99971 : push_file_scope (void)
448 : {
449 99971 : }
450 :
451 : void
452 99836 : pop_file_scope (void)
453 : {
454 99836 : }
455 :
456 : /* c-pragma.cc needs to query whether a decl has extern "C" linkage. */
457 : bool
458 63257847 : has_c_linkage (const_tree decl)
459 : {
460 63257847 : 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 6397615 : cxx_block_may_fallthru (const_tree stmt)
468 : {
469 6397615 : switch (TREE_CODE (stmt))
470 : {
471 2815139 : case EXPR_STMT:
472 2815139 : return block_may_fallthru (EXPR_STMT_EXPR (stmt));
473 :
474 : case THROW_EXPR:
475 : return false;
476 :
477 859979 : case IF_STMT:
478 859979 : if (IF_STMT_CONSTEXPR_P (stmt))
479 : {
480 1105 : if (integer_nonzerop (IF_COND (stmt)))
481 22 : return block_may_fallthru (THEN_CLAUSE (stmt));
482 1083 : if (integer_zerop (IF_COND (stmt)))
483 6 : return block_may_fallthru (ELSE_CLAUSE (stmt));
484 : }
485 859951 : if (block_may_fallthru (THEN_CLAUSE (stmt)))
486 : return true;
487 181525 : 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 2704607 : default:
499 2704607 : 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 2026368 : cp_pushdecl (tree decl)
515 : {
516 2026368 : DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace);
517 2026368 : 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 3551842 : identifier_global_value (tree name)
525 : {
526 3551842 : 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 9795147 : names_builtin_p (const char *name)
546 : {
547 9795147 : tree id = get_identifier (name);
548 9795147 : if (tree binding = get_global_binding (id))
549 : {
550 3466863 : if (TREE_CODE (binding) == FUNCTION_DECL
551 3466863 : && 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 6328284 : 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 254925 : 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 101571 : cp_register_dumps (gcc::dump_manager *dumps)
600 : {
601 203142 : class_dump_id = dumps->dump_register
602 101571 : (".class", "lang-class", "lang-class", DK_lang, OPTGROUP_NONE, false);
603 :
604 203142 : module_dump_id = dumps->dump_register
605 101571 : (".module", "lang-module", "lang-module", DK_lang, OPTGROUP_NONE, false);
606 :
607 203142 : raw_dump_id = dumps->dump_register
608 101571 : (".raw", "lang-raw", "lang-raw", DK_lang, OPTGROUP_NONE, false);
609 203142 : coro_dump_id = dumps->dump_register
610 101571 : (".coro", "lang-coro", "lang-coro", DK_lang, OPTGROUP_NONE, false);
611 203142 : tinst_dump_id = dumps->dump_register
612 101571 : (".tinst", "lang-tinst", "lang-tinst", DK_lang, OPTGROUP_NONE, false);
613 101571 : }
614 :
615 : void
616 101571 : cp_common_init_ts (void)
617 : {
618 : /* With type. */
619 101571 : MARK_TS_TYPED (PTRMEM_CST);
620 101571 : MARK_TS_TYPED (LAMBDA_EXPR);
621 101571 : MARK_TS_TYPED (TYPE_ARGUMENT_PACK);
622 101571 : MARK_TS_TYPED (TRAIT_EXPR);
623 101571 : MARK_TS_TYPED (REQUIRES_EXPR);
624 :
625 : /* Random new trees. */
626 101571 : MARK_TS_COMMON (BASELINK);
627 101571 : MARK_TS_COMMON (OVERLOAD);
628 101571 : MARK_TS_COMMON (TEMPLATE_PARM_INDEX);
629 :
630 : /* New decls. */
631 101571 : MARK_TS_DECL_COMMON (TEMPLATE_DECL);
632 :
633 101571 : MARK_TS_DECL_NON_COMMON (USING_DECL);
634 :
635 : /* New Types. */
636 101571 : MARK_TS_TYPE_COMMON (UNBOUND_CLASS_TEMPLATE);
637 101571 : MARK_TS_TYPE_COMMON (TYPE_ARGUMENT_PACK);
638 101571 : MARK_TS_TYPE_COMMON (DEPENDENT_OPERATOR_TYPE);
639 :
640 101571 : MARK_TS_TYPE_NON_COMMON (DECLTYPE_TYPE);
641 101571 : MARK_TS_TYPE_NON_COMMON (TYPENAME_TYPE);
642 101571 : MARK_TS_TYPE_NON_COMMON (TYPEOF_TYPE);
643 101571 : MARK_TS_TYPE_NON_COMMON (TRAIT_TYPE);
644 101571 : MARK_TS_TYPE_NON_COMMON (BOUND_TEMPLATE_TEMPLATE_PARM);
645 101571 : MARK_TS_TYPE_NON_COMMON (TEMPLATE_TEMPLATE_PARM);
646 101571 : MARK_TS_TYPE_NON_COMMON (TEMPLATE_TYPE_PARM);
647 101571 : MARK_TS_TYPE_NON_COMMON (TYPE_PACK_EXPANSION);
648 101571 : MARK_TS_TYPE_NON_COMMON (PACK_INDEX_TYPE);
649 101571 : MARK_TS_TYPE_NON_COMMON (META_TYPE);
650 101571 : MARK_TS_TYPE_NON_COMMON (SPLICE_SCOPE);
651 :
652 : /* Statements. */
653 101571 : MARK_TS_EXP (CLEANUP_STMT);
654 101571 : MARK_TS_EXP (EH_SPEC_BLOCK);
655 101571 : MARK_TS_EXP (HANDLER);
656 101571 : MARK_TS_EXP (IF_STMT);
657 101571 : MARK_TS_EXP (OMP_DEPOBJ);
658 101571 : MARK_TS_EXP (RANGE_FOR_STMT);
659 101571 : MARK_TS_EXP (TEMPLATE_FOR_STMT);
660 101571 : MARK_TS_EXP (TRY_BLOCK);
661 101571 : MARK_TS_EXP (USING_STMT);
662 :
663 : /* Random expressions. */
664 101571 : MARK_TS_EXP (ADDRESSOF_EXPR);
665 101571 : MARK_TS_EXP (AGGR_INIT_EXPR);
666 101571 : MARK_TS_EXP (ALIGNOF_EXPR);
667 101571 : MARK_TS_EXP (ARROW_EXPR);
668 101571 : MARK_TS_EXP (AT_ENCODE_EXPR);
669 101571 : MARK_TS_EXP (BIT_CAST_EXPR);
670 101571 : MARK_TS_EXP (CAST_EXPR);
671 101571 : MARK_TS_EXP (CONST_CAST_EXPR);
672 101571 : MARK_TS_EXP (CTOR_INITIALIZER);
673 101571 : MARK_TS_EXP (DELETE_EXPR);
674 101571 : MARK_TS_EXP (DOTSTAR_EXPR);
675 101571 : MARK_TS_EXP (DYNAMIC_CAST_EXPR);
676 101571 : MARK_TS_EXP (EMPTY_CLASS_EXPR);
677 101571 : MARK_TS_EXP (EXPR_STMT);
678 101571 : MARK_TS_EXP (IMPLICIT_CONV_EXPR);
679 101571 : MARK_TS_EXP (MEMBER_REF);
680 101571 : MARK_TS_EXP (MODOP_EXPR);
681 101571 : MARK_TS_EXP (MUST_NOT_THROW_EXPR);
682 101571 : MARK_TS_EXP (NEW_EXPR);
683 101571 : MARK_TS_EXP (NOEXCEPT_EXPR);
684 101571 : MARK_TS_EXP (OFFSETOF_EXPR);
685 101571 : MARK_TS_EXP (OFFSET_REF);
686 101571 : MARK_TS_EXP (PSEUDO_DTOR_EXPR);
687 101571 : MARK_TS_EXP (REINTERPRET_CAST_EXPR);
688 101571 : MARK_TS_EXP (SCOPE_REF);
689 101571 : MARK_TS_EXP (STATIC_CAST_EXPR);
690 101571 : MARK_TS_EXP (STMT_EXPR);
691 101571 : MARK_TS_EXP (TAG_DEFN);
692 101571 : MARK_TS_EXP (TEMPLATE_ID_EXPR);
693 101571 : MARK_TS_EXP (THROW_EXPR);
694 101571 : MARK_TS_EXP (TYPEID_EXPR);
695 101571 : MARK_TS_EXP (TYPE_EXPR);
696 101571 : MARK_TS_EXP (UNARY_PLUS_EXPR);
697 101571 : MARK_TS_EXP (VEC_DELETE_EXPR);
698 101571 : MARK_TS_EXP (VEC_INIT_EXPR);
699 101571 : MARK_TS_EXP (VEC_NEW_EXPR);
700 101571 : MARK_TS_EXP (SPACESHIP_EXPR);
701 101571 : MARK_TS_EXP (SPLICE_EXPR);
702 101571 : MARK_TS_EXP (REFLECT_EXPR);
703 :
704 : /* Fold expressions. */
705 101571 : MARK_TS_EXP (BINARY_LEFT_FOLD_EXPR);
706 101571 : MARK_TS_EXP (BINARY_RIGHT_FOLD_EXPR);
707 101571 : MARK_TS_EXP (EXPR_PACK_EXPANSION);
708 101571 : MARK_TS_EXP (NONTYPE_ARGUMENT_PACK);
709 101571 : MARK_TS_EXP (UNARY_LEFT_FOLD_EXPR);
710 101571 : MARK_TS_EXP (UNARY_RIGHT_FOLD_EXPR);
711 101571 : MARK_TS_EXP (PACK_INDEX_EXPR);
712 :
713 : /* Constraints. */
714 101571 : MARK_TS_EXP (COMPOUND_REQ);
715 101571 : MARK_TS_EXP (CONJ_CONSTR);
716 101571 : MARK_TS_EXP (DISJ_CONSTR);
717 101571 : MARK_TS_EXP (ATOMIC_CONSTR);
718 101571 : MARK_TS_EXP (NESTED_REQ);
719 101571 : MARK_TS_EXP (SIMPLE_REQ);
720 101571 : MARK_TS_EXP (TYPE_REQ);
721 :
722 101571 : MARK_TS_EXP (CO_AWAIT_EXPR);
723 101571 : MARK_TS_EXP (CO_YIELD_EXPR);
724 101571 : MARK_TS_EXP (CO_RETURN_EXPR);
725 :
726 101571 : MARK_TS_EXP (ASSERTION_STMT);
727 101571 : MARK_TS_EXP (PRECONDITION_STMT);
728 101571 : MARK_TS_EXP (POSTCONDITION_STMT);
729 :
730 101571 : c_common_init_ts ();
731 101571 : }
732 :
733 : /* Handle C++-specficic options here. Punt to c_common otherwise. */
734 :
735 : bool
736 1978075 : 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 1978075 : if (handle_module_option (unsigned (scode), arg, value))
741 : return true;
742 :
743 1977084 : return c_common_handle_option (scode, arg, value, kind, loc, handlers);
744 : }
745 :
746 : #include "gt-cp-cp-objcp-common.h"
|