operators.def revision 110611
1/* -*-C-*- 2 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> 7 8 Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. 9 10This file is part of GNU CC. 11 12GNU CC is free software; you can redistribute it and/or modify 13it under the terms of the GNU General Public License as published by 14the Free Software Foundation; either version 2, or (at your option) 15any later version. 16 17GNU CC is distributed in the hope that it will be useful, 18but WITHOUT ANY WARRANTY; without even the implied warranty of 19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20GNU General Public License for more details. 21 22You should have received a copy of the GNU General Public License 23along with GNU CC; see the file COPYING. If not, write to 24the Free Software Foundation, 59 Temple Place - Suite 330, 25Boston, MA 02111-1307, USA. */ 26 27/* The DEF_OPERATOR macro takes the following arguments: 28 29 NAME 30 31 The name of the operator, as a C string, but without the 32 preceding `operator'. This is the name that would be given in 33 the source program. For `operator +', for example, this would be 34 `+'. 35 36 CODE 37 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. 42 43 MANGLING 44 45 The mangling prefix for the operator, as a C string, and as 46 mangled under the new ABI. For `operator +', for example, this 47 would be "pl". 48 49 ARITY 50 51 The arity of the operator, or -1 if any arity is allowed. (As 52 for `operator ()'.) Postincrement and postdecrement operators 53 are marked as binary. 54 55 ASSN_P 56 57 A boolean value. If non-zero, this is an assignment operator. 58 59 Before including this file, you should define DEFOPERATOR 60 to take these arguments. 61 62 There is code (such as in grok_op_properties) that depends on the 63 order the operators are presented in this file. In particular, 64 unary operators must precede binary operators. */ 65 66/* Use DEF_SIMPLE_OPERATOR to define a non-assignment operator. Its 67 arguments are as for DEF_OPERATOR, but there is no need to provide 68 an ASSIGNMENT_P argument; it is always zero. */ 69 70#define DEF_SIMPLE_OPERATOR(NAME, CODE, MANGLING, ARITY) \ 71 DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, 0) 72 73/* Use DEF_ASSN_OPERATOR to define an assignment operator. Its 74 arguments are as for DEF_OPERATOR, but there is no need to provide 75 an ASSIGNMENT_P argument; it is always one. */ 76 77#define DEF_ASSN_OPERATOR(NAME, CODE, MANGLING, ARITY) \ 78 DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, 1) 79 80/* Memory allocation operators. */ 81DEF_SIMPLE_OPERATOR ("new", NEW_EXPR, "nw", -1) 82DEF_SIMPLE_OPERATOR ("new []", VEC_NEW_EXPR, "na", -1) 83DEF_SIMPLE_OPERATOR ("delete", DELETE_EXPR, "dl", -1) 84DEF_SIMPLE_OPERATOR ("delete []", VEC_DELETE_EXPR, "da", -1) 85 86/* Unary operators. */ 87DEF_SIMPLE_OPERATOR ("+", CONVERT_EXPR, "ps", 1) 88DEF_SIMPLE_OPERATOR ("-", NEGATE_EXPR, "ng", 1) 89DEF_SIMPLE_OPERATOR ("&", ADDR_EXPR, "ad", 1) 90DEF_SIMPLE_OPERATOR ("*", INDIRECT_REF, "de", 1) 91DEF_SIMPLE_OPERATOR ("~", BIT_NOT_EXPR, "co", 1) 92DEF_SIMPLE_OPERATOR ("!", TRUTH_NOT_EXPR, "nt", 1) 93DEF_SIMPLE_OPERATOR ("++", PREINCREMENT_EXPR, "pp", 1) 94DEF_SIMPLE_OPERATOR ("--", PREDECREMENT_EXPR, "mm", 1) 95DEF_SIMPLE_OPERATOR ("sizeof", SIZEOF_EXPR, "sz", 1) 96/* This is an extension. */ 97DEF_SIMPLE_OPERATOR ("alignof", ALIGNOF_EXPR, "v17alignof", 1) 98 99/* The cast operator. */ 100DEF_SIMPLE_OPERATOR ("", TYPE_EXPR, "cv", 1) 101DEF_SIMPLE_OPERATOR ("", CAST_EXPR, "cv", 1) 102DEF_SIMPLE_OPERATOR ("", CONST_CAST_EXPR, "cv", 1) 103DEF_SIMPLE_OPERATOR ("", STATIC_CAST_EXPR, "cv", 1) 104 105/* Binary operators. */ 106DEF_SIMPLE_OPERATOR ("+", PLUS_EXPR, "pl", 2) 107DEF_SIMPLE_OPERATOR ("-", MINUS_EXPR, "mi", 2) 108DEF_SIMPLE_OPERATOR ("*", MULT_EXPR, "ml", 2) 109DEF_SIMPLE_OPERATOR ("/", TRUNC_DIV_EXPR, "dv", 2) 110DEF_SIMPLE_OPERATOR ("%", TRUNC_MOD_EXPR, "rm", 2) 111DEF_SIMPLE_OPERATOR ("&", BIT_AND_EXPR, "an", 2) 112DEF_SIMPLE_OPERATOR ("|", BIT_IOR_EXPR, "or", 2) 113DEF_SIMPLE_OPERATOR ("^", BIT_XOR_EXPR, "eo", 2) 114DEF_SIMPLE_OPERATOR ("<<", LSHIFT_EXPR, "ls", 2) 115DEF_SIMPLE_OPERATOR (">>", RSHIFT_EXPR, "rs", 2) 116DEF_SIMPLE_OPERATOR ("==", EQ_EXPR, "eq", 2) 117DEF_SIMPLE_OPERATOR ("!=", NE_EXPR, "ne", 2) 118DEF_SIMPLE_OPERATOR ("<", LT_EXPR, "lt", 2) 119DEF_SIMPLE_OPERATOR (">", GT_EXPR, "gt", 2) 120DEF_SIMPLE_OPERATOR ("<=", LE_EXPR, "le", 2) 121DEF_SIMPLE_OPERATOR (">=", GE_EXPR, "ge", 2) 122DEF_SIMPLE_OPERATOR ("&&", TRUTH_ANDIF_EXPR, "aa", 2) 123DEF_SIMPLE_OPERATOR ("||", TRUTH_ORIF_EXPR, "oo", 2) 124DEF_SIMPLE_OPERATOR (",", COMPOUND_EXPR, "cm", 2) 125DEF_SIMPLE_OPERATOR ("->*", MEMBER_REF, "pm", 2) 126DEF_SIMPLE_OPERATOR ("->", COMPONENT_REF, "pt", 2) 127DEF_SIMPLE_OPERATOR ("[]", ARRAY_REF, "ix", 2) 128DEF_SIMPLE_OPERATOR ("++", POSTINCREMENT_EXPR, "pp", 2) 129DEF_SIMPLE_OPERATOR ("--", POSTDECREMENT_EXPR, "mm", 2) 130/* These operators are GNU extensions. */ 131DEF_SIMPLE_OPERATOR ("<?", MIN_EXPR, "v23min", 2) 132DEF_SIMPLE_OPERATOR (">?", MAX_EXPR, "v23max", 2) 133/* This one is needed for mangling. */ 134DEF_SIMPLE_OPERATOR ("::", SCOPE_REF, "sr", 2); 135 136/* Assignment operators. */ 137DEF_ASSN_OPERATOR ("=", NOP_EXPR, "aS", 2) 138DEF_ASSN_OPERATOR ("+=", PLUS_EXPR, "pL", 2) 139DEF_ASSN_OPERATOR ("-=", MINUS_EXPR, "mI", 2) 140DEF_ASSN_OPERATOR ("*=", MULT_EXPR, "mL", 2) 141DEF_ASSN_OPERATOR ("/=", TRUNC_DIV_EXPR, "dV", 2) 142DEF_ASSN_OPERATOR ("%=", TRUNC_MOD_EXPR, "rM", 2) 143DEF_ASSN_OPERATOR ("&=", BIT_AND_EXPR, "aN", 2) 144DEF_ASSN_OPERATOR ("|=", BIT_IOR_EXPR, "oR", 2) 145DEF_ASSN_OPERATOR ("^=", BIT_XOR_EXPR, "eO", 2) 146DEF_ASSN_OPERATOR ("<<=", LSHIFT_EXPR, "lS", 2) 147DEF_ASSN_OPERATOR (">>=", RSHIFT_EXPR, "rS", 2) 148/* These operators are GNU extensions. */ 149DEF_ASSN_OPERATOR ("<?=", MIN_EXPR, "v23miN", 2); 150DEF_ASSN_OPERATOR (">?=", MAX_EXPR, "v23maX", 2); 151 152/* Ternary operators. */ 153DEF_SIMPLE_OPERATOR ("?:", COND_EXPR, "qu", 3) 154 155/* Miscellaneous. */ 156DEF_SIMPLE_OPERATOR ("()", CALL_EXPR, "cl", -1) 157