|
|
1.1 ! root 1: /* Variables and structures for overloading rules. ! 2: Copyright (C) 1993 Free Software Foundation, Inc. ! 3: ! 4: This file is part of GNU CC. ! 5: ! 6: GNU CC is free software; you can redistribute it and/or modify ! 7: it under the terms of the GNU General Public License as published by ! 8: the Free Software Foundation; either version 2, or (at your option) ! 9: any later version. ! 10: ! 11: GNU CC is distributed in the hope that it will be useful, ! 12: but WITHOUT ANY WARRANTY; without even the implied warranty of ! 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! 14: GNU General Public License for more details. ! 15: ! 16: You should have received a copy of the GNU General Public License ! 17: along with GNU CC; see the file COPYING. If not, write to ! 18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ ! 19: ! 20: /* The following structure is used when comparing various alternatives ! 21: for overloading. The unsigned quantity `strikes.i' is used ! 22: for fast comparison of two possibilities. This number is an ! 23: aggregate of four constituents: ! 24: ! 25: EVIL: if this is non-zero, then the candidate should not be considered ! 26: ELLIPSIS: if this is non-zero, then some actual argument has been matched ! 27: against an ellipsis ! 28: USER: if this is non-zero, then a user-defined type conversion is needed ! 29: B_OR_D: if this is non-zero, then use a base pointer instead of the ! 30: type of the pointer we started with. ! 31: EASY: if this is non-zero, then we have a builtin conversion ! 32: (such as int to long, int to float, etc) to do. ! 33: ! 34: If two candidates require user-defined type conversions, and the ! 35: type conversions are not identical, then an ambiguity error ! 36: is reported. ! 37: ! 38: If two candidates agree on user-defined type conversions, ! 39: and one uses pointers of strictly higher type (derived where ! 40: another uses base), then that alternative is silently chosen. ! 41: ! 42: Note that this technique really only works for 255 arguments. Perhaps ! 43: this is not enough. */ ! 44: ! 45: /* These macros and harshness_code are used by the NEW METHOD. */ ! 46: #define EVIL_CODE (1<<7) ! 47: #define CONST_CODE (1<<6) ! 48: #define ELLIPSIS_CODE (1<<5) ! 49: #define USER_CODE (1<<4) ! 50: #define STD_CODE (1<<3) ! 51: #define PROMO_CODE (1<<2) ! 52: #define QUAL_CODE (1<<1) ! 53: #define TRIVIAL_CODE (1<<0) ! 54: ! 55: struct harshness_code ! 56: { ! 57: /* What kind of conversion is involved. */ ! 58: unsigned short code; ! 59: ! 60: /* The inheritance distance. */ ! 61: short distance; ! 62: ! 63: /* For a PROMO_CODE, Any special penalties involved in integral conversions. ! 64: This exists because $4.1 of the ARM states that something like ! 65: `short unsigned int' should promote to `int', not `unsigned int'. ! 66: If, for example, it tries to match two fns, f(int) and f(unsigned), ! 67: f(int) should be a better match than f(unsigned) by this rule. Without ! 68: this extra metric, they both only appear as "integral promotions", which ! 69: will lead to an ambiguity. ! 70: For a TRIVIAL_CODE, This is also used by build_overload_call_real and ! 71: convert_harshness to keep track of other information we need. */ ! 72: unsigned short int_penalty; ! 73: }; ! 74: ! 75: struct candidate ! 76: { ! 77: struct harshness_code h; /* Used for single-argument conversions. */ ! 78: ! 79: int h_len; /* The length of the harshness vector. */ ! 80: ! 81: tree function; /* A FUNCTION_DECL */ ! 82: tree basetypes; /* The path to function. */ ! 83: tree arg; /* first parm to function. */ ! 84: ! 85: /* Indexed by argument number, encodes evil, user, d_to_b, and easy ! 86: strikes for that argument. At end of array, we store the index+1 ! 87: of where we started using default parameters, or 0 if there are ! 88: none. */ ! 89: struct harshness_code *harshness; ! 90: ! 91: union ! 92: { ! 93: tree field; /* If no evil strikes, the FUNCTION_DECL of ! 94: the function (if a member function). */ ! 95: int bad_arg; /* the index of the first bad argument: ! 96: 0 if no bad arguments ! 97: > 0 is first bad argument ! 98: -1 if extra actual arguments ! 99: -2 if too few actual arguments. ! 100: -3 if const/non const method mismatch. ! 101: -4 if type unification failed. ! 102: -5 if contravariance violation. */ ! 103: } u; ! 104: }; ! 105: int rank_for_overload (); ! 106: ! 107: /* Variables shared between class.c and call.c. */ ! 108: ! 109: extern int n_vtables; ! 110: extern int n_vtable_entries; ! 111: extern int n_vtable_searches; ! 112: extern int n_vtable_elems; ! 113: extern int n_convert_harshness; ! 114: extern int n_compute_conversion_costs; ! 115: extern int n_build_method_call; ! 116: extern int n_inner_fields_searched;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.