|
|
1.1.1.3 ! 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: 1.1 root 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 1.1.1.3 ! root 26: ELLIPSIS: if this is non-zero, then some actual argument has been matched ! 27: against an ellipsis 1.1 root 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: If two candidates have a non-monotonic derived/base pointer 43: relationship, and/or a non-monotonic easy conversion relationship, 44: then a warning is emitted to show which paths are possible, and 45: which one is being chosen. 46: 47: For example: 48: 49: int i; 50: double x; 51: 52: overload f; 53: int f (int, int); 54: double f (double, double); 55: 56: f (i, x); // draws a warning 57: 58: struct B 59: { 60: f (int); 61: } *bb; 62: struct D : B 63: { 64: f (double); 65: } *dd; 66: 67: dd->f (x); // exact match 68: dd->f (i); // draws warning 69: 70: Note that this technique really only works for 255 arguments. Perhaps 71: this is not enough. */ 72: 73: struct candidate 74: { 75: tree function; /* A FUNCTION_DECL */ 76: 77: unsigned char evil; /* !0 if this will never convert. */ 1.1.1.3 ! root 78: unsigned char ellipsis; /* !0 if a match against an ellipsis occurred */ 1.1 root 79: unsigned char user; /* !0 if at least one user-defined type conv. */ 80: unsigned short b_or_d; /* count number of derived->base or 81: base->derived conv. */ 82: unsigned short easy; /* count number of builtin type conv. */ 83: tree arg; /* first parm to function. */ 84: unsigned short *harshness; /* Indexed by argument number, encodes 85: evil, user, d_to_b, and easy strikes for 86: that argument. 87: At end of array, we store the index+1 88: of where we started using default 89: parameters, or 0 if there are none. */ 90: union 91: { 92: tree field; /* If no evil strikes, the FUNCTION_DECL of 93: the function (if a member function). */ 94: int bad_arg; /* the index of the first bad argument: 1.1.1.2 root 95: 0 if no bad arguments 1.1 root 96: > 0 is first bad argument 97: -1 if extra actual arguments 98: -2 if too few actual arguments. 99: -3 if const/non const method mismatch. 100: -4 if type unification failed. 101: -5 if contravariance violation. */ 102: } u; 103: }; 104: int rank_for_overload (); 105: 106: /* Variables shared between cp-class.c and cp-call.c. */ 107: 108: extern int n_vtables; 109: extern int n_vtable_entries; 110: extern int n_vtable_searches; 111: extern int n_vtable_elems; 112: extern int n_convert_harshness; 113: extern int n_compute_conversion_costs; 114: extern int n_build_method_call; 115: 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.