Line data Source code
1 : /* This file contains the definitions for C++-specific built-in traits.
2 :
3 : Copyright The GNU Toolchain Authors.
4 :
5 : This file is part of GCC.
6 :
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)
10 : any later version.
11 :
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.
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 : /* Add a DEFTRAIT_EXPR (CODE, NAME, N) line to this file to define an
22 : expression-yielding built-in trait that has internal code name CODE, is
23 : spelled as NAME and takes N type arguments (where N is either 1, 2, or
24 : the special value -1 which denotes that it takes at least one argument).
25 : Such traits are represented as TRAIT_EXPR tree whose TRAIT_EXPR_KIND is
26 : CPTK_CODE. Define the behavior of the trait in finish_trait_expr. */
27 :
28 : /* Add a DEFTRAIT_TYPE (CODE, NAME, N) line to this file to define a
29 : type-yielding built-in trait as described above. Such traits are
30 : generally represented as a TRAIT_TYPE tree whose TRAIT_TYPE_KIND is
31 : CPTK_CODE (exceptions are BASES and DIRECT_BASES below). Define the
32 : behavior of the trait in finish_trait_type. */
33 :
34 : #ifdef DEFTRAIT
35 : #define DEFTRAIT_EXPR(CODE, NAME, ARITY) DEFTRAIT(tcc_expression, CODE, NAME, ARITY)
36 : #define DEFTRAIT_TYPE(CODE, NAME, ARITY) DEFTRAIT(tcc_type, CODE, NAME, ARITY)
37 : #define DEFTRAIT_EXPR_DEFAULTED
38 : #define DEFTRAIT_TYPE_DEFAULTED
39 : #endif
40 :
41 : #ifndef DEFTRAIT_EXPR
42 : #define DEFTRAIT_EXPR(CODE, NAME, ARITY)
43 : #define DEFTRAIT_EXPR_DEFAULTED
44 : #endif
45 :
46 : #ifndef DEFTRAIT_TYPE
47 : #define DEFTRAIT_TYPE(CODE, NAME, ARITY)
48 : #define DEFTRAIT_TYPE_DEFAULTED
49 : #endif
50 :
51 0 : DEFTRAIT_TYPE (ADD_LVALUE_REFERENCE, "__add_lvalue_reference", 1)
52 0 : DEFTRAIT_TYPE (ADD_POINTER, "__add_pointer", 1)
53 0 : DEFTRAIT_TYPE (ADD_RVALUE_REFERENCE, "__add_rvalue_reference", 1)
54 3 : DEFTRAIT_TYPE (DECAY, "__decay", 1)
55 7 : DEFTRAIT_EXPR (HAS_NOTHROW_ASSIGN, "__has_nothrow_assign", 1)
56 7 : DEFTRAIT_EXPR (HAS_NOTHROW_CONSTRUCTOR, "__has_nothrow_constructor", 1)
57 7 : DEFTRAIT_EXPR (HAS_NOTHROW_COPY, "__has_nothrow_copy", 1)
58 7 : DEFTRAIT_EXPR (HAS_TRIVIAL_ASSIGN, "__has_trivial_assign", 1)
59 7 : DEFTRAIT_EXPR (HAS_TRIVIAL_CONSTRUCTOR, "__has_trivial_constructor", 1)
60 7 : DEFTRAIT_EXPR (HAS_TRIVIAL_COPY, "__has_trivial_copy", 1)
61 7 : DEFTRAIT_EXPR (HAS_TRIVIAL_DESTRUCTOR, "__has_trivial_destructor", 1)
62 3 : DEFTRAIT_EXPR (HAS_UNIQUE_OBJ_REPRESENTATIONS, "__has_unique_object_representations", 1)
63 7 : DEFTRAIT_EXPR (HAS_VIRTUAL_DESTRUCTOR, "__has_virtual_destructor", 1)
64 7 : DEFTRAIT_EXPR (IS_ABSTRACT, "__is_abstract", 1)
65 3 : DEFTRAIT_EXPR (IS_AGGREGATE, "__is_aggregate", 1)
66 0 : DEFTRAIT_EXPR (IS_ARRAY, "__is_array", 1)
67 3 : DEFTRAIT_EXPR (IS_ASSIGNABLE, "__is_assignable", 2)
68 4 : DEFTRAIT_EXPR (IS_BASE_OF, "__is_base_of", 2)
69 0 : DEFTRAIT_EXPR (IS_BOUNDED_ARRAY, "__is_bounded_array", 1)
70 96 : DEFTRAIT_EXPR (IS_CLASS, "__is_class", 1)
71 0 : DEFTRAIT_EXPR (IS_CONST, "__is_const", 1)
72 0 : DEFTRAIT_EXPR (IS_CONSTEVAL_ONLY, "__builtin_is_consteval_only", 1)
73 14 : DEFTRAIT_EXPR (IS_CONSTRUCTIBLE, "__is_constructible", -1)
74 0 : DEFTRAIT_EXPR (IS_CONVERTIBLE, "__is_convertible", 2)
75 0 : DEFTRAIT_EXPR (IS_DESTRUCTIBLE, "__is_destructible", 1)
76 10 : DEFTRAIT_EXPR (IS_EMPTY, "__is_empty", 1)
77 3 : DEFTRAIT_EXPR (IS_ENUM, "__is_enum", 1)
78 4 : DEFTRAIT_EXPR (IS_FINAL, "__is_final", 1)
79 0 : DEFTRAIT_EXPR (IS_FUNCTION, "__is_function", 1)
80 0 : DEFTRAIT_EXPR (IS_IMPLICIT_LIFETIME, "__builtin_is_implicit_lifetime", 1)
81 0 : DEFTRAIT_EXPR (IS_INVOCABLE, "__is_invocable", -1)
82 0 : DEFTRAIT_EXPR (IS_LAYOUT_COMPATIBLE, "__is_layout_compatible", 2)
83 0 : DEFTRAIT_EXPR (IS_LITERAL_TYPE, "__is_literal_type", 1)
84 0 : DEFTRAIT_EXPR (IS_MEMBER_FUNCTION_POINTER, "__is_member_function_pointer", 1)
85 0 : DEFTRAIT_EXPR (IS_MEMBER_OBJECT_POINTER, "__is_member_object_pointer", 1)
86 0 : DEFTRAIT_EXPR (IS_MEMBER_POINTER, "__is_member_pointer", 1)
87 3 : DEFTRAIT_EXPR (IS_NOTHROW_ASSIGNABLE, "__is_nothrow_assignable", 2)
88 9 : DEFTRAIT_EXPR (IS_NOTHROW_CONSTRUCTIBLE, "__is_nothrow_constructible", -1)
89 0 : DEFTRAIT_EXPR (IS_NOTHROW_CONVERTIBLE, "__is_nothrow_convertible", 2)
90 0 : DEFTRAIT_EXPR (IS_NOTHROW_DESTRUCTIBLE, "__is_nothrow_destructible", 1)
91 0 : DEFTRAIT_EXPR (IS_NOTHROW_INVOCABLE, "__is_nothrow_invocable", -1)
92 0 : DEFTRAIT_EXPR (IS_OBJECT, "__is_object", 1)
93 0 : DEFTRAIT_EXPR (IS_POINTER_INTERCONVERTIBLE_BASE_OF, "__is_pointer_interconvertible_base_of", 2)
94 7 : DEFTRAIT_EXPR (IS_POD, "__is_pod", 1)
95 0 : DEFTRAIT_EXPR (IS_POINTER, "__is_pointer", 1)
96 7 : DEFTRAIT_EXPR (IS_POLYMORPHIC, "__is_polymorphic", 1)
97 0 : DEFTRAIT_EXPR (IS_REFERENCE, "__is_reference", 1)
98 236 : DEFTRAIT_EXPR (IS_SAME, "__is_same", 2)
99 0 : DEFTRAIT_EXPR (IS_SCOPED_ENUM, "__is_scoped_enum", 1)
100 4 : DEFTRAIT_EXPR (IS_STD_LAYOUT, "__is_standard_layout", 1)
101 4 : DEFTRAIT_EXPR (IS_TRIVIAL, "__is_trivial", 1)
102 3 : DEFTRAIT_EXPR (IS_TRIVIALLY_ASSIGNABLE, "__is_trivially_assignable", 2)
103 9 : DEFTRAIT_EXPR (IS_TRIVIALLY_CONSTRUCTIBLE, "__is_trivially_constructible", -1)
104 3 : DEFTRAIT_EXPR (IS_TRIVIALLY_COPYABLE, "__is_trivially_copyable", 1)
105 0 : DEFTRAIT_EXPR (IS_TRIVIALLY_DESTRUCTIBLE, "__is_trivially_destructible", 1)
106 0 : DEFTRAIT_EXPR (IS_UNBOUNDED_ARRAY, "__is_unbounded_array", 1)
107 7 : DEFTRAIT_EXPR (IS_UNION, "__is_union", 1)
108 0 : DEFTRAIT_EXPR (IS_VIRTUAL_BASE_OF, "__builtin_is_virtual_base_of", 2)
109 0 : DEFTRAIT_EXPR (IS_VOLATILE, "__is_volatile", 1)
110 0 : DEFTRAIT_EXPR (RANK, "__array_rank", 1)
111 0 : DEFTRAIT_EXPR (REF_CONSTRUCTS_FROM_TEMPORARY, "__reference_constructs_from_temporary", 2)
112 0 : DEFTRAIT_EXPR (REF_CONVERTS_FROM_TEMPORARY, "__reference_converts_from_temporary", 2)
113 0 : DEFTRAIT_TYPE (REMOVE_ALL_EXTENTS, "__remove_all_extents", 1)
114 0 : DEFTRAIT_TYPE (REMOVE_CV, "__remove_cv", 1)
115 0 : DEFTRAIT_TYPE (REMOVE_CVREF, "__remove_cvref", 1)
116 0 : DEFTRAIT_TYPE (REMOVE_EXTENT, "__remove_extent", 1)
117 0 : DEFTRAIT_TYPE (REMOVE_POINTER, "__remove_pointer", 1)
118 0 : DEFTRAIT_TYPE (REMOVE_REFERENCE, "__remove_reference", 1)
119 0 : DEFTRAIT_EXPR (STRUCTURED_BINDING_SIZE, "__builtin_structured_binding_size", 1)
120 0 : DEFTRAIT_EXPR (TYPE_ORDER, "__builtin_type_order", 2)
121 9 : DEFTRAIT_TYPE (TYPE_PACK_ELEMENT, "__type_pack_element", -1)
122 36 : DEFTRAIT_TYPE (UNDERLYING_TYPE, "__underlying_type", 1)
123 :
124 : /* FIXME Added space to avoid direct usage in GCC 13. */
125 96 : DEFTRAIT_EXPR (IS_DEDUCIBLE, "__is_deducible ", 2)
126 :
127 : /* These traits yield a type pack, not a type, and are represented by
128 : cp_parser_trait as a special BASES tree instead of a TRAIT_TYPE tree. */
129 0 : DEFTRAIT_TYPE (BASES, "__bases", 1)
130 0 : DEFTRAIT_TYPE (DIRECT_BASES, "__direct_bases", 1)
131 :
132 : #ifdef DEFTRAIT_EXPR_DEFAULTED
133 : #undef DEFTRAIT_EXPR
134 : #undef DEFTRAIT_EXPR_DEFAULTED
135 : #endif
136 :
137 : #ifdef DEFTRAIT_TYPE_DEFAULTED
138 : #undef DEFTRAIT_TYPE
139 : #undef DEFTRAIT_TYPE_DEFAULTED
140 : #endif
|