Mercurial > hg > CbC > CbC_gcc
comparison gcc/cp/operators.def @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
3 This file contains definitions of the various C++ operators, | 3 This file contains definitions of the various C++ operators, |
4 including both overloadable operators (like `+') and | 4 including both overloadable operators (like `+') and |
5 non-overloadable operators (like the `?:' ternary operator). | 5 non-overloadable operators (like the `?:' ternary operator). |
6 Written by Mark Mitchell <mark@codesourcery.com> | 6 Written by Mark Mitchell <mark@codesourcery.com> |
7 | 7 |
8 Copyright (C) 2000-2017 Free Software Foundation, Inc. | 8 Copyright (C) 2000-2018 Free Software Foundation, Inc. |
9 | 9 |
10 This file is part of GCC. | 10 This file is part of GCC. |
11 | 11 |
12 GCC is free software; you can redistribute it and/or modify | 12 GCC is free software; you can redistribute it and/or modify |
13 it under the terms of the GNU General Public License as published by | 13 it under the terms of the GNU General Public License as published by |
43 | 43 |
44 The mangling prefix for the operator, as a C string, and as | 44 The mangling prefix for the operator, as a C string, and as |
45 mangled under the new ABI. For `operator +', for example, this | 45 mangled under the new ABI. For `operator +', for example, this |
46 would be "pl". | 46 would be "pl". |
47 | 47 |
48 ARITY | 48 FLAGS |
49 | 49 |
50 The arity of the operator, or -1 if any arity is allowed. (As | 50 ovl_op_flags bits. Postincrement and postdecrement operators are |
51 for `operator ()'.) Postincrement and postdecrement operators | 51 marked as binary. |
52 are marked as binary. | |
53 | |
54 ASSN_P | |
55 | |
56 A boolean value. If nonzero, this is an assignment operator. | |
57 | 52 |
58 Before including this file, you should define DEF_OPERATOR | 53 Before including this file, you should define DEF_OPERATOR |
59 to take these arguments. | 54 to take these arguments. |
60 | 55 |
61 There is code (such as in grok_op_properties) that depends on the | 56 There is code (such as in grok_op_properties) that depends on the |
62 order the operators are presented in this file. In particular, | 57 order the operators are presented in this file. Unary_ops must |
63 unary operators must precede binary operators. */ | 58 preceed a matching binary op (i.e. '+'). Assignment operators must |
64 | 59 be last, after OPERATOR_TRANSITION. */ |
65 /* Use DEF_SIMPLE_OPERATOR to define a non-assignment operator. Its | |
66 arguments are as for DEF_OPERATOR, but there is no need to provide | |
67 an ASSIGNMENT_P argument; it is always zero. */ | |
68 | |
69 #define DEF_SIMPLE_OPERATOR(NAME, CODE, MANGLING, ARITY) \ | |
70 DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, cik_simple_op) | |
71 | 60 |
72 /* Use DEF_ASSN_OPERATOR to define an assignment operator. Its | 61 /* Use DEF_ASSN_OPERATOR to define an assignment operator. Its |
73 arguments are as for DEF_OPERATOR, but there is no need to provide | 62 arguments are as for DEF_OPERATOR, but there is no need to provide |
74 an ASSIGNMENT_P argument; it is always one. */ | 63 FLAGS (OVL_OP_FLAG_BINARY). */ |
75 | 64 |
76 #define DEF_ASSN_OPERATOR(NAME, CODE, MANGLING, ARITY) \ | 65 #ifndef DEF_ASSN_OPERATOR |
77 DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, cik_assign_op) | 66 #define DEF_ASSN_OPERATOR(NAME, CODE, MANGLING) \ |
67 DEF_OPERATOR(NAME, CODE, MANGLING, OVL_OP_FLAG_BINARY) | |
68 #endif | |
78 | 69 |
79 /* Memory allocation operators. */ | 70 /* Memory allocation operators. ARITY has special meaning. */ |
80 DEF_OPERATOR ("new", NEW_EXPR, "nw", -1, cik_newdel_op) | 71 DEF_OPERATOR ("new", NEW_EXPR, "nw", OVL_OP_FLAG_ALLOC) |
81 DEF_OPERATOR ("new []", VEC_NEW_EXPR, "na", -1, cik_newdel_op) | 72 DEF_OPERATOR ("new []", VEC_NEW_EXPR, "na", |
82 DEF_OPERATOR ("delete", DELETE_EXPR, "dl", -1, cik_newdel_op) | 73 OVL_OP_FLAG_ALLOC | OVL_OP_FLAG_VEC) |
83 DEF_OPERATOR ("delete []", VEC_DELETE_EXPR, "da", -1, cik_newdel_op) | 74 DEF_OPERATOR ("delete", DELETE_EXPR, "dl", |
75 OVL_OP_FLAG_ALLOC | OVL_OP_FLAG_DELETE) | |
76 DEF_OPERATOR ("delete []", VEC_DELETE_EXPR, "da", | |
77 OVL_OP_FLAG_ALLOC | OVL_OP_FLAG_DELETE | OVL_OP_FLAG_VEC) | |
84 | 78 |
85 /* Unary operators. */ | 79 /* Unary operators. */ |
86 DEF_SIMPLE_OPERATOR ("+", UNARY_PLUS_EXPR, "ps", 1) | 80 DEF_OPERATOR ("+", UNARY_PLUS_EXPR, "ps", OVL_OP_FLAG_UNARY) |
87 DEF_SIMPLE_OPERATOR ("-", NEGATE_EXPR, "ng", 1) | 81 DEF_OPERATOR ("-", NEGATE_EXPR, "ng", OVL_OP_FLAG_UNARY) |
88 DEF_SIMPLE_OPERATOR ("&", ADDR_EXPR, "ad", 1) | 82 DEF_OPERATOR ("&", ADDR_EXPR, "ad", OVL_OP_FLAG_UNARY) |
89 DEF_SIMPLE_OPERATOR ("*", INDIRECT_REF, "de", 1) | 83 DEF_OPERATOR ("*", INDIRECT_REF, "de", OVL_OP_FLAG_UNARY) |
90 DEF_SIMPLE_OPERATOR ("~", BIT_NOT_EXPR, "co", 1) | 84 DEF_OPERATOR ("~", BIT_NOT_EXPR, "co", OVL_OP_FLAG_UNARY) |
91 DEF_SIMPLE_OPERATOR ("!", TRUTH_NOT_EXPR, "nt", 1) | 85 DEF_OPERATOR ("!", TRUTH_NOT_EXPR, "nt", OVL_OP_FLAG_UNARY) |
92 DEF_SIMPLE_OPERATOR ("++", PREINCREMENT_EXPR, "pp", 1) | 86 DEF_OPERATOR ("++", PREINCREMENT_EXPR, "pp", OVL_OP_FLAG_UNARY) |
93 DEF_SIMPLE_OPERATOR ("--", PREDECREMENT_EXPR, "mm", 1) | 87 DEF_OPERATOR ("--", PREDECREMENT_EXPR, "mm", OVL_OP_FLAG_UNARY) |
94 DEF_SIMPLE_OPERATOR ("sizeof", SIZEOF_EXPR, "sz", 1) | 88 DEF_OPERATOR ("->", COMPONENT_REF, "pt", OVL_OP_FLAG_UNARY) |
89 DEF_OPERATOR ("sizeof", SIZEOF_EXPR, "sz", OVL_OP_FLAG_UNARY) | |
90 | |
95 /* These are extensions. */ | 91 /* These are extensions. */ |
96 DEF_SIMPLE_OPERATOR ("alignof", ALIGNOF_EXPR, "az", 1) | 92 DEF_OPERATOR ("alignof", ALIGNOF_EXPR, "az", OVL_OP_FLAG_UNARY) |
97 DEF_SIMPLE_OPERATOR ("__imag__", IMAGPART_EXPR, "v18__imag__", 1) | 93 DEF_OPERATOR ("__imag__", IMAGPART_EXPR, "v18__imag__", OVL_OP_FLAG_UNARY) |
98 DEF_SIMPLE_OPERATOR ("__real__", REALPART_EXPR, "v18__real__", 1) | 94 DEF_OPERATOR ("__real__", REALPART_EXPR, "v18__real__", OVL_OP_FLAG_UNARY) |
99 | |
100 /* The cast operators. */ | |
101 DEF_SIMPLE_OPERATOR ("", CAST_EXPR, "cv", 1) | |
102 DEF_SIMPLE_OPERATOR ("dynamic_cast", DYNAMIC_CAST_EXPR, "dc", 1) | |
103 DEF_SIMPLE_OPERATOR ("reinterpret_cast", REINTERPRET_CAST_EXPR, "rc", 1) | |
104 DEF_SIMPLE_OPERATOR ("const_cast", CONST_CAST_EXPR, "cc", 1) | |
105 DEF_SIMPLE_OPERATOR ("static_cast", STATIC_CAST_EXPR, "sc", 1) | |
106 | 95 |
107 /* Binary operators. */ | 96 /* Binary operators. */ |
108 DEF_SIMPLE_OPERATOR ("+", PLUS_EXPR, "pl", 2) | 97 DEF_OPERATOR ("+", PLUS_EXPR, "pl", OVL_OP_FLAG_BINARY) |
109 DEF_SIMPLE_OPERATOR ("-", MINUS_EXPR, "mi", 2) | 98 DEF_OPERATOR ("-", MINUS_EXPR, "mi", OVL_OP_FLAG_BINARY) |
110 DEF_SIMPLE_OPERATOR ("*", MULT_EXPR, "ml", 2) | 99 DEF_OPERATOR ("*", MULT_EXPR, "ml", OVL_OP_FLAG_BINARY) |
111 DEF_SIMPLE_OPERATOR ("/", TRUNC_DIV_EXPR, "dv", 2) | 100 DEF_OPERATOR ("/", TRUNC_DIV_EXPR, "dv", OVL_OP_FLAG_BINARY) |
112 DEF_SIMPLE_OPERATOR ("%", TRUNC_MOD_EXPR, "rm", 2) | 101 DEF_OPERATOR ("%", TRUNC_MOD_EXPR, "rm", OVL_OP_FLAG_BINARY) |
113 DEF_SIMPLE_OPERATOR ("&", BIT_AND_EXPR, "an", 2) | 102 DEF_OPERATOR ("&", BIT_AND_EXPR, "an", OVL_OP_FLAG_BINARY) |
114 DEF_SIMPLE_OPERATOR ("|", BIT_IOR_EXPR, "or", 2) | 103 DEF_OPERATOR ("|", BIT_IOR_EXPR, "or", OVL_OP_FLAG_BINARY) |
115 DEF_SIMPLE_OPERATOR ("^", BIT_XOR_EXPR, "eo", 2) | 104 DEF_OPERATOR ("^", BIT_XOR_EXPR, "eo", OVL_OP_FLAG_BINARY) |
116 DEF_SIMPLE_OPERATOR ("<<", LSHIFT_EXPR, "ls", 2) | 105 DEF_OPERATOR ("<<", LSHIFT_EXPR, "ls", OVL_OP_FLAG_BINARY) |
117 DEF_SIMPLE_OPERATOR (">>", RSHIFT_EXPR, "rs", 2) | 106 DEF_OPERATOR (">>", RSHIFT_EXPR, "rs", OVL_OP_FLAG_BINARY) |
118 DEF_SIMPLE_OPERATOR ("==", EQ_EXPR, "eq", 2) | 107 DEF_OPERATOR ("==", EQ_EXPR, "eq", OVL_OP_FLAG_BINARY) |
119 DEF_SIMPLE_OPERATOR ("!=", NE_EXPR, "ne", 2) | 108 DEF_OPERATOR ("!=", NE_EXPR, "ne", OVL_OP_FLAG_BINARY) |
120 DEF_SIMPLE_OPERATOR ("<", LT_EXPR, "lt", 2) | 109 DEF_OPERATOR ("<", LT_EXPR, "lt", OVL_OP_FLAG_BINARY) |
121 DEF_SIMPLE_OPERATOR (">", GT_EXPR, "gt", 2) | 110 DEF_OPERATOR (">", GT_EXPR, "gt", OVL_OP_FLAG_BINARY) |
122 DEF_SIMPLE_OPERATOR ("<=", LE_EXPR, "le", 2) | 111 DEF_OPERATOR ("<=", LE_EXPR, "le", OVL_OP_FLAG_BINARY) |
123 DEF_SIMPLE_OPERATOR (">=", GE_EXPR, "ge", 2) | 112 DEF_OPERATOR (">=", GE_EXPR, "ge", OVL_OP_FLAG_BINARY) |
124 DEF_SIMPLE_OPERATOR ("&&", TRUTH_ANDIF_EXPR, "aa", 2) | 113 DEF_OPERATOR ("&&", TRUTH_ANDIF_EXPR, "aa", OVL_OP_FLAG_BINARY) |
125 DEF_SIMPLE_OPERATOR ("||", TRUTH_ORIF_EXPR, "oo", 2) | 114 DEF_OPERATOR ("||", TRUTH_ORIF_EXPR, "oo", OVL_OP_FLAG_BINARY) |
126 DEF_SIMPLE_OPERATOR (",", COMPOUND_EXPR, "cm", 2) | 115 DEF_OPERATOR (",", COMPOUND_EXPR, "cm", OVL_OP_FLAG_BINARY) |
127 DEF_SIMPLE_OPERATOR ("->*", MEMBER_REF, "pm", 2) | 116 DEF_OPERATOR ("->*", MEMBER_REF, "pm", OVL_OP_FLAG_BINARY) |
128 DEF_SIMPLE_OPERATOR (".*", DOTSTAR_EXPR, "ds", 2) | 117 DEF_OPERATOR (".*", DOTSTAR_EXPR, "ds", OVL_OP_FLAG_BINARY) |
129 DEF_SIMPLE_OPERATOR ("->", COMPONENT_REF, "pt", 2) | 118 DEF_OPERATOR ("[]", ARRAY_REF, "ix", OVL_OP_FLAG_BINARY) |
130 DEF_SIMPLE_OPERATOR ("[]", ARRAY_REF, "ix", 2) | 119 DEF_OPERATOR ("++", POSTINCREMENT_EXPR, "pp", OVL_OP_FLAG_BINARY) |
131 DEF_SIMPLE_OPERATOR ("++", POSTINCREMENT_EXPR, "pp", 2) | 120 DEF_OPERATOR ("--", POSTDECREMENT_EXPR, "mm", OVL_OP_FLAG_BINARY) |
132 DEF_SIMPLE_OPERATOR ("--", POSTDECREMENT_EXPR, "mm", 2) | 121 |
133 /* This one is needed for mangling. */ | 122 /* Miscellaneous. */ |
134 DEF_SIMPLE_OPERATOR ("::", SCOPE_REF, "sr", 2) | 123 DEF_OPERATOR ("?:", COND_EXPR, "qu", OVL_OP_FLAG_NONE) |
124 DEF_OPERATOR ("()", CALL_EXPR, "cl", OVL_OP_FLAG_NONE) | |
125 | |
126 /* Operators needed for mangling. */ | |
127 DEF_OPERATOR (NULL, CAST_EXPR, "cv", OVL_OP_FLAG_UNARY) | |
128 DEF_OPERATOR (NULL, DYNAMIC_CAST_EXPR, "dc", OVL_OP_FLAG_UNARY) | |
129 DEF_OPERATOR (NULL, REINTERPRET_CAST_EXPR, "rc", OVL_OP_FLAG_UNARY) | |
130 DEF_OPERATOR (NULL, CONST_CAST_EXPR, "cc", OVL_OP_FLAG_UNARY) | |
131 DEF_OPERATOR (NULL, STATIC_CAST_EXPR, "sc", OVL_OP_FLAG_UNARY) | |
132 DEF_OPERATOR (NULL, SCOPE_REF, "sr", OVL_OP_FLAG_NONE) | |
133 DEF_OPERATOR (NULL, EXPR_PACK_EXPANSION, "sp", OVL_OP_FLAG_NONE) | |
134 DEF_OPERATOR (NULL, UNARY_LEFT_FOLD_EXPR, "fl", OVL_OP_FLAG_NONE) | |
135 DEF_OPERATOR (NULL, UNARY_RIGHT_FOLD_EXPR, "fr", OVL_OP_FLAG_NONE) | |
136 DEF_OPERATOR (NULL, BINARY_LEFT_FOLD_EXPR, "fL", OVL_OP_FLAG_NONE) | |
137 DEF_OPERATOR (NULL, BINARY_RIGHT_FOLD_EXPR, "fR", OVL_OP_FLAG_NONE) | |
138 | |
139 #ifdef OPERATOR_TRANSITION | |
140 OPERATOR_TRANSITION | |
141 #undef OPERATOR_TRANSITION | |
142 #endif | |
135 | 143 |
136 /* Assignment operators. */ | 144 /* Assignment operators. */ |
137 DEF_ASSN_OPERATOR ("=", NOP_EXPR, "aS", 2) | 145 DEF_ASSN_OPERATOR ("=", NOP_EXPR, "aS") |
138 DEF_ASSN_OPERATOR ("+=", PLUS_EXPR, "pL", 2) | 146 DEF_ASSN_OPERATOR ("+=", PLUS_EXPR, "pL") |
139 DEF_ASSN_OPERATOR ("-=", MINUS_EXPR, "mI", 2) | 147 DEF_ASSN_OPERATOR ("-=", MINUS_EXPR, "mI") |
140 DEF_ASSN_OPERATOR ("*=", MULT_EXPR, "mL", 2) | 148 DEF_ASSN_OPERATOR ("*=", MULT_EXPR, "mL") |
141 DEF_ASSN_OPERATOR ("/=", TRUNC_DIV_EXPR, "dV", 2) | 149 DEF_ASSN_OPERATOR ("/=", TRUNC_DIV_EXPR, "dV") |
142 DEF_ASSN_OPERATOR ("%=", TRUNC_MOD_EXPR, "rM", 2) | 150 DEF_ASSN_OPERATOR ("%=", TRUNC_MOD_EXPR, "rM") |
143 DEF_ASSN_OPERATOR ("&=", BIT_AND_EXPR, "aN", 2) | 151 DEF_ASSN_OPERATOR ("&=", BIT_AND_EXPR, "aN") |
144 DEF_ASSN_OPERATOR ("|=", BIT_IOR_EXPR, "oR", 2) | 152 DEF_ASSN_OPERATOR ("|=", BIT_IOR_EXPR, "oR") |
145 DEF_ASSN_OPERATOR ("^=", BIT_XOR_EXPR, "eO", 2) | 153 DEF_ASSN_OPERATOR ("^=", BIT_XOR_EXPR, "eO") |
146 DEF_ASSN_OPERATOR ("<<=", LSHIFT_EXPR, "lS", 2) | 154 DEF_ASSN_OPERATOR ("<<=", LSHIFT_EXPR, "lS") |
147 DEF_ASSN_OPERATOR (">>=", RSHIFT_EXPR, "rS", 2) | 155 DEF_ASSN_OPERATOR (">>=", RSHIFT_EXPR, "rS") |
148 | 156 |
149 /* Ternary operators. */ | 157 #undef DEF_ASSN_OPERATOR |
150 DEF_SIMPLE_OPERATOR ("?:", COND_EXPR, "qu", 3) | 158 #undef DEF_OPERATOR |
151 | |
152 /* Miscellaneous. */ | |
153 DEF_SIMPLE_OPERATOR ("()", CALL_EXPR, "cl", -1) | |
154 | |
155 /* Variadic templates extension. */ | |
156 DEF_SIMPLE_OPERATOR ("...", EXPR_PACK_EXPANSION, "sp", 1) | |
157 DEF_SIMPLE_OPERATOR ("... +", UNARY_LEFT_FOLD_EXPR, "fl", 2) | |
158 DEF_SIMPLE_OPERATOR ("+ ...", UNARY_RIGHT_FOLD_EXPR, "fr", 2) | |
159 DEF_SIMPLE_OPERATOR ("+ ... +", BINARY_LEFT_FOLD_EXPR, "fL", 3) | |
160 DEF_SIMPLE_OPERATOR ("+ ... +", BINARY_RIGHT_FOLD_EXPR, "fR", 3) |