📄 call.c
字号:
/* 4 For every pair T, VQ), where T is an arithmetic or enumeration type, and VQ is either volatile or empty, there exist candidate operator functions of the form VQ T& operator++(VQ T&); T operator++(VQ T&, int); 5 For every pair T, VQ), where T is an enumeration type or an arithmetic type other than bool, and VQ is either volatile or empty, there exist candidate operator functions of the form VQ T& operator--(VQ T&); T operator--(VQ T&, int); 6 For every pair T, VQ), where T is a cv-qualified or cv-unqualified complete object type, and VQ is either volatile or empty, there exist candidate operator functions of the form T*VQ& operator++(T*VQ&); T*VQ& operator--(T*VQ&); T* operator++(T*VQ&, int); T* operator--(T*VQ&, int); */ case POSTDECREMENT_EXPR: case PREDECREMENT_EXPR: if (TREE_CODE (type1) == BOOLEAN_TYPE) return candidates; case POSTINCREMENT_EXPR: case PREINCREMENT_EXPR: if ((ARITHMETIC_TYPE_P (type1) && TREE_CODE (type1) != ENUMERAL_TYPE) || TYPE_PTROB_P (type1)) { type1 = build_reference_type (type1); break; } return candidates;/* 7 For every cv-qualified or cv-unqualified complete object type T, there exist candidate operator functions of the form T& operator*(T*); 8 For every function type T, there exist candidate operator functions of the form T& operator*(T*); */ case INDIRECT_REF: if (TREE_CODE (type1) == POINTER_TYPE && (TYPE_PTROB_P (type1) || TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE)) break; return candidates;/* 9 For every type T, there exist candidate operator functions of the form T* operator+(T*); 10For every promoted arithmetic type T, there exist candidate operator functions of the form T operator+(T); T operator-(T); */ case CONVERT_EXPR: /* unary + */ if (TREE_CODE (type1) == POINTER_TYPE && TREE_CODE (TREE_TYPE (type1)) != OFFSET_TYPE) break; case NEGATE_EXPR: if (ARITHMETIC_TYPE_P (type1)) break; return candidates;/* 11For every promoted integral type T, there exist candidate operator functions of the form T operator~(T); */ case BIT_NOT_EXPR: if (INTEGRAL_TYPE_P (type1)) break; return candidates;/* 12For every quintuple C1, C2, T, CV1, CV2), where C2 is a class type, C1 is the same type as C2 or is a derived class of C2, T is a complete object type or a function type, and CV1 and CV2 are cv-qualifier-seqs, there exist candidate operator functions of the form CV12 T& operator->*(CV1 C1*, CV2 T C2::*); where CV12 is the union of CV1 and CV2. */ case MEMBER_REF: if (TREE_CODE (type1) == POINTER_TYPE && (TYPE_PTRMEMFUNC_P (type2) || TYPE_PTRMEM_P (type2))) { tree c1 = TREE_TYPE (type1); tree c2 = (TYPE_PTRMEMFUNC_P (type2) ? TYPE_METHOD_BASETYPE (TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type2))) : TYPE_OFFSET_BASETYPE (TREE_TYPE (type2))); if (IS_AGGR_TYPE (c1) && DERIVED_FROM_P (c2, c1) && (TYPE_PTRMEMFUNC_P (type2) || is_complete (TREE_TYPE (TREE_TYPE (type2))))) break; } return candidates;/* 13For every pair of promoted arithmetic types L and R, there exist can- didate operator functions of the form LR operator*(L, R); LR operator/(L, R); LR operator+(L, R); LR operator-(L, R); bool operator<(L, R); bool operator>(L, R); bool operator<=(L, R); bool operator>=(L, R); bool operator==(L, R); bool operator!=(L, R); where LR is the result of the usual arithmetic conversions between types L and R. 14For every pair of types T and I, where T is a cv-qualified or cv- unqualified complete object type and I is a promoted integral type, there exist candidate operator functions of the form T* operator+(T*, I); T& operator[](T*, I); T* operator-(T*, I); T* operator+(I, T*); T& operator[](I, T*); 15For every T, where T is a pointer to complete object type, there exist candidate operator functions of the form112) ptrdiff_t operator-(T, T); 16For every pointer type T, there exist candidate operator functions of the form bool operator<(T, T); bool operator>(T, T); bool operator<=(T, T); bool operator>=(T, T); bool operator==(T, T); bool operator!=(T, T); 17For every pointer to member type T, there exist candidate operator functions of the form bool operator==(T, T); bool operator!=(T, T); */ case MINUS_EXPR: if (TYPE_PTROB_P (type1) && TYPE_PTROB_P (type2)) break; if (TYPE_PTROB_P (type1) && INTEGRAL_TYPE_P (type2)) { type2 = ptrdiff_type_node; break; } case MULT_EXPR: case TRUNC_DIV_EXPR: if (ARITHMETIC_TYPE_P (type1) && ARITHMETIC_TYPE_P (type2)) break; return candidates; case EQ_EXPR: case NE_EXPR: if ((TYPE_PTRMEMFUNC_P (type1) && TYPE_PTRMEMFUNC_P (type2)) || (TYPE_PTRMEM_P (type1) && TYPE_PTRMEM_P (type2))) break; if ((TYPE_PTRMEMFUNC_P (type1) || TYPE_PTRMEM_P (type1)) && null_ptr_cst_p (args[1])) { type2 = type1; break; } if ((TYPE_PTRMEMFUNC_P (type2) || TYPE_PTRMEM_P (type2)) && null_ptr_cst_p (args[0])) { type1 = type2; break; } case LT_EXPR: case GT_EXPR: case LE_EXPR: case GE_EXPR: case MAX_EXPR: case MIN_EXPR: if ((ARITHMETIC_TYPE_P (type1) && ARITHMETIC_TYPE_P (type2)) || (TYPE_PTR_P (type1) && TYPE_PTR_P (type2))) break; if (TYPE_PTR_P (type1) && null_ptr_cst_p (args[1])) { type2 = type1; break; } if (null_ptr_cst_p (args[0]) && TYPE_PTR_P (type2)) { type1 = type2; break; } return candidates; case PLUS_EXPR: if (ARITHMETIC_TYPE_P (type1) && ARITHMETIC_TYPE_P (type2)) break; case ARRAY_REF: if (INTEGRAL_TYPE_P (type1) && TYPE_PTROB_P (type2)) { type1 = ptrdiff_type_node; break; } if (TYPE_PTROB_P (type1) && INTEGRAL_TYPE_P (type2)) { type2 = ptrdiff_type_node; break; } return candidates;/* 18For every pair of promoted integral types L and R, there exist candi- date operator functions of the form LR operator%(L, R); LR operator&(L, R); LR operator^(L, R); LR operator|(L, R); L operator<<(L, R); L operator>>(L, R); where LR is the result of the usual arithmetic conversions between types L and R. */ case TRUNC_MOD_EXPR: case BIT_AND_EXPR: case BIT_IOR_EXPR: case BIT_XOR_EXPR: case LSHIFT_EXPR: case RSHIFT_EXPR: if (INTEGRAL_TYPE_P (type1) && INTEGRAL_TYPE_P (type2)) break; return candidates;/* 19For every triple L, VQ, R), where L is an arithmetic or enumeration type, VQ is either volatile or empty, and R is a promoted arithmetic type, there exist candidate operator functions of the form VQ L& operator=(VQ L&, R); VQ L& operator*=(VQ L&, R); VQ L& operator/=(VQ L&, R); VQ L& operator+=(VQ L&, R); VQ L& operator-=(VQ L&, R); 20For every pair T, VQ), where T is any type and VQ is either volatile or empty, there exist candidate operator functions of the form T*VQ& operator=(T*VQ&, T*); 21For every pair T, VQ), where T is a pointer to member type and VQ is either volatile or empty, there exist candidate operator functions of the form VQ T& operator=(VQ T&, T); 22For every triple T, VQ, I), where T is a cv-qualified or cv- unqualified complete object type, VQ is either volatile or empty, and I is a promoted integral type, there exist candidate operator func- tions of the form T*VQ& operator+=(T*VQ&, I); T*VQ& operator-=(T*VQ&, I); 23For every triple L, VQ, R), where L is an integral or enumeration type, VQ is either volatile or empty, and R is a promoted integral type, there exist candidate operator functions of the form VQ L& operator%=(VQ L&, R); VQ L& operator<<=(VQ L&, R); VQ L& operator>>=(VQ L&, R); VQ L& operator&=(VQ L&, R); VQ L& operator^=(VQ L&, R); VQ L& operator|=(VQ L&, R); */ case MODIFY_EXPR: switch (code2) { case PLUS_EXPR: case MINUS_EXPR: if (TYPE_PTROB_P (type1) && INTEGRAL_TYPE_P (type2)) { type2 = ptrdiff_type_node; break; } case MULT_EXPR: case TRUNC_DIV_EXPR: if (ARITHMETIC_TYPE_P (type1) && ARITHMETIC_TYPE_P (type2)) break; return candidates; case TRUNC_MOD_EXPR: case BIT_AND_EXPR: case BIT_IOR_EXPR: case BIT_XOR_EXPR: case LSHIFT_EXPR: case RSHIFT_EXPR: if (INTEGRAL_TYPE_P (type1) && INTEGRAL_TYPE_P (type2)) break; return candidates; case NOP_EXPR: if (ARITHMETIC_TYPE_P (type1) && ARITHMETIC_TYPE_P (type2)) break; if ((TYPE_PTRMEMFUNC_P (type1) && TYPE_PTRMEMFUNC_P (type2)) || (TYPE_PTR_P (type1) && TYPE_PTR_P (type2)) || (TYPE_PTRMEM_P (type1) && TYPE_PTRMEM_P (type2)) || ((TYPE_PTRMEMFUNC_P (type1) || TREE_CODE (type1) == POINTER_TYPE) && null_ptr_cst_p (args[1]))) { type2 = type1; break; } return candidates; default: my_friendly_abort (367); } type1 = build_reference_type (type1); break; case COND_EXPR: /* Kludge around broken overloading rules whereby bool ? const char& : enum is ambiguous (between int and const char&). */ flags |= LOOKUP_NO_TEMP_BIND; /* Extension: Support ?: of enumeral type. Hopefully this will not be an extension for long. */ if (TREE_CODE (type1) == ENUMERAL_TYPE && type1 == type2) break; else if (TREE_CODE (type1) == ENUMERAL_TYPE || TREE_CODE (type2) == ENUMERAL_TYPE) return candidates; if (ARITHMETIC_TYPE_P (type1) && ARITHMETIC_TYPE_P (type2)) break; if (TREE_CODE (type1) == TREE_CODE (type2) && (TREE_CODE (type1) == REFERENCE_TYPE || TREE_CODE (type1) == POINTER_TYPE || TYPE_PTRMEMFUNC_P (type1) || IS_AGGR_TYPE (type1))) break; if (TREE_CODE (type1) == REFERENCE_TYPE || TREE_CODE (type2) == REFERENCE_TYPE) return candidates; if (((TYPE_PTRMEMFUNC_P (type1) || TREE_CODE (type1) == POINTER_TYPE) && null_ptr_cst_p (args[1])) || IS_AGGR_TYPE (type1)) { type2 = type1; break; } if (((TYPE_PTRMEMFUNC_P (type2) || TREE_CODE (type2) == POINTER_TYPE) && null_ptr_cst_p (args[0])) || IS_AGGR_TYPE (type2)) { type1 = type2; break; } return candidates; default: my_friendly_abort (367); } /* If we're dealing with two pointer types, we need candidates for both of them. */ if (type2 && type1 != type2 && TREE_CODE (type1) == TREE_CODE (type2) && (TREE_CODE (type1) == REFERENCE_TYPE || (TREE_CODE (type1) == POINTER_TYPE && TYPE_PTRMEM_P (type1) == TYPE_PTRMEM_P (type2)) || TYPE_PTRMEMFUNC_P (type1) || IS_AGGR_TYPE (type1))) { candidates = build_builtin_candidate (candidates, fnname, type1, type1, args, argtypes, flags); return build_builtin_candidate (candidates, fnname, type2, type2, args, argtypes, flags); } return build_builtin_candidate (candidates, fnname, type1, type2, args, argtypes, flags);}treetype_decays_to (type) tree type;{ if (TREE_CODE (type) == ARRAY_TYPE) return build_pointer_type (TREE_TYPE (type)); if (TREE_CODE (type) == FUNCTION_TYPE) return build_pointer_type (type); return type;}/* There are three conditions of builtin candidates: 1) bool-taking candidates. These are the same regardless of the input. 2) pointer-pair taking candidates. These are generated for each type one of the input types converts to. 3) arithmetic candidates. According to the WP, we should generate all of these, but I'm trying not to... */static struct z_candidate *add_builtin_candidates (candidates, code, code2, fnname, args, flags) struct z_candidate *candidates; enum tree_code code, code2; tree fnname, *args; int flags;{ int ref1, i; tree type, argtypes[3], types[2]; for (i = 0; i < 3; ++i) { if (args[i]) argtypes[i] = lvalue_type (args[i]); else argtypes[i] = NULL_TREE; } switch (code) {/* 4 For every pair T, VQ), where T is an arithmetic or enumeration type, and VQ is either volatile or empty, there exist candidate operator functions of the form VQ T& operator++(VQ T&); */ case POSTINCREMENT_EXPR: case PREINCREMENT_EXPR: case POSTDECREMENT_EXPR: case PREDECREMENT_EXPR: case MODIFY_EXPR: ref1 = 1; break;/* 24There also exist candidate operator functions of the form bool operator!(bool); bool operator&&(bool, bool); bool operator||(bool, bool); */ case TRUTH_NOT_EXPR: return build_builtin_candidate (candidates, fnname, boolean_type_node, NULL_TREE, args, argtypes, flags); case TRUTH_ORIF_EXPR: case TRUTH_ANDIF_EXPR: return build_builtin_candidate (candidates, fnname, boolean_type_node, boolean_type_node, args, argtypes, flags); case ADDR_EXPR: case COMPOUND_EXPR: case COMPONENT_REF: return candidates; default: ref1 = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -