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