3 This file contains definitions of the various C
++ operators
,
4 including both overloadable
operators (like `
+') and
5 non-overloadable operators (like the `?:' ternary operator
).
6 Writtey by Mark Mitchell
<mark@codesourcery.com
>
8 Copyright (C
) 2000 Free Software Foundation
, Inc.
10 This file is part of GNU CC.
12 GNU CC is free software
; you can redistribute it and
/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation
; either version
2, or (at your option
)
17 GNU CC is distributed in the hope that it will be useful
,
18 but WITHOUT ANY WARRANTY
; without even the implied warranty of
19 MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with GNU CC
; see the file COPYING. If not
, write to
24 the Free Software Foundation
, 59 Temple Place
- Suite
330,
25 Boston
, MA
02111-1307, USA.
*/
27 /* The DEF_OPERATOR macro takes the following arguments
:
31 The name of the operator
, as a C string
, but without the
32 preceeding `operator
'. This is the name that would be given in
33 the source program. For `operator +', for example
, this would be
38 The tree_code for this operator. For `operator +', for example
,
39 this would be PLUS_EXPR. Because there are no tree codes for
40 assignment operators
, the same tree
-codes are reused
; i.e.
,
41 `operator
+' will also have PLUS_EXPR as its CODE.
45 The mangling prefix for the operator, as a C string, and as
46 mangled under the new ABI. For `operator +', for example
, this
51 Analagous
, but for the old ABI.
55 The arity of the operator
, or
-1 if any arity is allowed.
(As
56 for `
operator ()'.) Postincrement and postdecrement operators
61 A boolean value. If non-zero, this is an assignment operator.
63 Before including this file, you should define DEFOPERATOR
64 to take these arguments.
66 There is code (such as in grok_op_properties) that depends on the
67 order the operators are presented in this file. In particular,
68 unary operators must preceed binary operators. */
70 /* Use DEF_SIMPLE_OPERATOR to define a non-assignment operator. Its
71 arguments are as for DEF_OPERATOR, but there is no need to provide
72 an ASSIGNMENT_P argument; it is always zero. */
74 #define DEF_SIMPLE_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGLING, ARITY) \
75 DEF_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGLING, ARITY, 0)
77 /* Use DEF_ASSN_OPERATOR to define an assignment operator. Its
78 arguments are as for DEF_OPERATOR, but there is no need to provide
79 an ASSIGNMENT_P argument; it is always one. */
81 #define DEF_ASSN_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGLING, ARITY) \
82 DEF_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGLING, ARITY, 1)
84 /* Memory allocation operators. */
85 DEF_SIMPLE_OPERATOR ("new", NEW_EXPR, "nw", "__nw", -1)
86 DEF_SIMPLE_OPERATOR ("new []", VEC_NEW_EXPR, "na", "__vn", -1)
87 DEF_SIMPLE_OPERATOR ("delete", DELETE_EXPR, "dl", "__dl", -1)
88 DEF_SIMPLE_OPERATOR ("delete []", VEC_DELETE_EXPR, "da", "__vd", -1)
90 /* Unary operators. */
91 DEF_SIMPLE_OPERATOR ("+", CONVERT_EXPR, "ps", "__pl", 1)
92 DEF_SIMPLE_OPERATOR ("-", NEGATE_EXPR, "ng", "__mi", 1)
93 DEF_SIMPLE_OPERATOR ("&", ADDR_EXPR, "ad", "__ad", 1)
94 DEF_SIMPLE_OPERATOR ("*", INDIRECT_REF, "de", "__ml", 1)
95 DEF_SIMPLE_OPERATOR ("~", BIT_NOT_EXPR, "co", "__co", 1)
96 DEF_SIMPLE_OPERATOR ("!", TRUTH_NOT_EXPR, "nt", "__nt", 1)
97 DEF_SIMPLE_OPERATOR ("++", PREINCREMENT_EXPR, "pp", "__pp", 1)
98 DEF_SIMPLE_OPERATOR ("--", PREDECREMENT_EXPR, "mm", "__mm", 1)
99 DEF_SIMPLE_OPERATOR ("sizeof", SIZEOF_EXPR, "sz", "__sz", 1)
100 /* This is an extension. */
101 DEF_SIMPLE_OPERATOR ("alignof", ALIGNOF_EXPR, "vx7alignof", "__al", 1)
103 /* The cast operator. */
104 DEF_SIMPLE_OPERATOR ("", TYPE_EXPR, "cv", OPERATOR_TYPENAME_FORMAT, 1)
106 /* Binary operators. */
107 DEF_SIMPLE_OPERATOR ("+", PLUS_EXPR, "pl", "__pl", 2)
108 DEF_SIMPLE_OPERATOR ("-", MINUS_EXPR, "mi", "__mi", 2)
109 DEF_SIMPLE_OPERATOR ("*", MULT_EXPR, "ml", "__ml", 2)
110 DEF_SIMPLE_OPERATOR ("/", TRUNC_DIV_EXPR, "dv", "__dv", 2)
111 DEF_SIMPLE_OPERATOR ("%", TRUNC_MOD_EXPR, "rm", "__md", 2)
112 DEF_SIMPLE_OPERATOR ("&", BIT_AND_EXPR, "an", "__ad", 2)
113 DEF_SIMPLE_OPERATOR ("|", BIT_IOR_EXPR, "or", "__or", 2)
114 DEF_SIMPLE_OPERATOR ("^", BIT_XOR_EXPR, "eo", "__er", 2)
115 DEF_SIMPLE_OPERATOR ("<<", LSHIFT_EXPR, "ls", "__ls", 2)
116 DEF_SIMPLE_OPERATOR (">>", RSHIFT_EXPR, "rs", "__rs", 2)
117 DEF_SIMPLE_OPERATOR ("==", EQ_EXPR, "eq", "__eq", 2)
118 DEF_SIMPLE_OPERATOR ("!=", NE_EXPR, "ne", "__ne", 2)
119 DEF_SIMPLE_OPERATOR ("<", LT_EXPR, "lt", "__lt", 2)
120 DEF_SIMPLE_OPERATOR (">", GT_EXPR, "gt", "__gt", 2)
121 DEF_SIMPLE_OPERATOR ("<=", LE_EXPR, "le", "__le", 2)
122 DEF_SIMPLE_OPERATOR (">=", GE_EXPR, "ge", "__ge", 2)
123 DEF_SIMPLE_OPERATOR ("&&", TRUTH_ANDIF_EXPR, "aa", "__aa", 2)
124 DEF_SIMPLE_OPERATOR ("||", TRUTH_ORIF_EXPR, "oo", "__oo", 2)
125 DEF_SIMPLE_OPERATOR (",", COMPOUND_EXPR, "cm", "__cm", 2)
126 DEF_SIMPLE_OPERATOR ("->*", MEMBER_REF, "pm", "__rm", 2)
127 DEF_SIMPLE_OPERATOR ("->", COMPONENT_REF, "pt", "__rf", 2)
128 DEF_SIMPLE_OPERATOR ("[]", ARRAY_REF, "ix", "__vc", 2)
129 DEF_SIMPLE_OPERATOR ("++", POSTINCREMENT_EXPR, "pp", "__pp", 2)
130 DEF_SIMPLE_OPERATOR ("--", POSTDECREMENT_EXPR, "mm", "__mm", 2)
131 /* These are extensions. */
132 DEF_SIMPLE_OPERATOR ("<?", MIN_EXPR, "vx3min", "__mn", 2)
133 DEF_SIMPLE_OPERATOR (">?", MAX_EXPR, "vx3max", "__mx", 2)
134 /* This one is needed for mangling. */
135 DEF_SIMPLE_OPERATOR ("::", SCOPE_REF, "sr", NULL, 2);
137 /* Assignment operators. */
138 DEF_ASSN_OPERATOR ("=", NOP_EXPR, "aS", "__as", 2)
139 DEF_ASSN_OPERATOR ("+=", PLUS_EXPR, "pL", "__apl", 2)
140 DEF_ASSN_OPERATOR ("-=", MINUS_EXPR, "mI", "__ami", 2)
141 DEF_ASSN_OPERATOR ("*=", MULT_EXPR, "mL", "__aml", 2)
142 DEF_ASSN_OPERATOR ("/=", TRUNC_DIV_EXPR, "dV", "__adv", 2)
143 DEF_ASSN_OPERATOR ("%=", TRUNC_MOD_EXPR, "rM", "__amd", 2)
144 DEF_ASSN_OPERATOR ("&=", BIT_AND_EXPR, "aN", "__aad", 2)
145 DEF_ASSN_OPERATOR ("|=", BIT_IOR_EXPR, "oR", "__aor", 2)
146 DEF_ASSN_OPERATOR ("^=", BIT_XOR_EXPR, "eO", "__aer", 2)
147 DEF_ASSN_OPERATOR ("<<=", LSHIFT_EXPR, "lS", "__als", 2)
148 DEF_ASSN_OPERATOR (">>=", RSHIFT_EXPR, "rS", "__ars", 2)
150 /* Ternary operators. */
151 DEF_SIMPLE_OPERATOR ("?:", COND_EXPR, "qu", "__cn", 3)
154 DEF_SIMPLE_OPERATOR ("()", CALL_EXPR, "cl", "__cl", -1)