Annotation of gcc/cp/class.h, revision 1.1.1.2

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
1.1.1.2 ! root       18: the Free Software Foundation, 59 Temple Place - Suite 330,
        !            19: Boston, MA 02111-1307, USA.  */
1.1       root       20: 
                     21: /* The following structure is used when comparing various alternatives
                     22:    for overloading.  The unsigned quantity `strikes.i' is used
                     23:    for fast comparison of two possibilities.  This number is an
                     24:    aggregate of four constituents:
                     25: 
                     26:      EVIL: if this is non-zero, then the candidate should not be considered
                     27:      ELLIPSIS: if this is non-zero, then some actual argument has been matched
                     28:                against an ellipsis
                     29:      USER: if this is non-zero, then a user-defined type conversion is needed
                     30:      B_OR_D: if this is non-zero, then use a base pointer instead of the
                     31:              type of the pointer we started with.
                     32:      EASY: if this is non-zero, then we have a builtin conversion
                     33:            (such as int to long, int to float, etc) to do.
                     34: 
                     35:    If two candidates require user-defined type conversions, and the
                     36:    type conversions are not identical, then an ambiguity error
                     37:    is reported.
                     38: 
                     39:    If two candidates agree on user-defined type conversions,
                     40:    and one uses pointers of strictly higher type (derived where
                     41:    another uses base), then that alternative is silently chosen.
                     42: 
                     43:    Note that this technique really only works for 255 arguments.  Perhaps
                     44:    this is not enough.  */
                     45: 
                     46: /* These macros and harshness_code are used by the NEW METHOD.  */
                     47: #define EVIL_CODE (1<<7)
                     48: #define CONST_CODE (1<<6)
                     49: #define ELLIPSIS_CODE (1<<5)
                     50: #define USER_CODE (1<<4)
                     51: #define STD_CODE (1<<3)
                     52: #define PROMO_CODE (1<<2)
                     53: #define QUAL_CODE (1<<1)
                     54: #define TRIVIAL_CODE (1<<0)
                     55: 
                     56: struct harshness_code
                     57: {
                     58:   /* What kind of conversion is involved.  */
                     59:   unsigned short code;
                     60: 
                     61:   /* The inheritance distance.  */
                     62:   short distance;
                     63: 
                     64:   /* For a PROMO_CODE, Any special penalties involved in integral conversions.
                     65:      This exists because $4.1 of the ARM states that something like
                     66:      `short unsigned int' should promote to `int', not `unsigned int'.
                     67:      If, for example, it tries to match two fns, f(int) and f(unsigned),
                     68:      f(int) should be a better match than f(unsigned) by this rule.  Without
                     69:      this extra metric, they both only appear as "integral promotions", which
                     70:      will lead to an ambiguity.
                     71:      For a TRIVIAL_CODE, This is also used by build_overload_call_real and
                     72:      convert_harshness to keep track of other information we need.  */
                     73:   unsigned short int_penalty;
                     74: };
                     75: 
                     76: struct candidate
                     77: {
                     78:   struct harshness_code h;     /* Used for single-argument conversions.  */
                     79: 
                     80:   int h_len;                   /* The length of the harshness vector.  */
                     81: 
                     82:   tree function;               /* A FUNCTION_DECL */
                     83:   tree basetypes;              /* The path to function. */
                     84:   tree arg;                    /* first parm to function.  */
                     85: 
                     86:   /* Indexed by argument number, encodes evil, user, d_to_b, and easy
                     87:      strikes for that argument.  At end of array, we store the index+1
                     88:      of where we started using default parameters, or 0 if there are
                     89:      none.  */
                     90:   struct harshness_code *harshness;
                     91: 
                     92:   union
                     93:     {
                     94:       tree field;              /* If no evil strikes, the FUNCTION_DECL of
                     95:                                   the function (if a member function).  */
                     96:       int bad_arg;             /* the index of the first bad argument:
                     97:                                   0 if no bad arguments
                     98:                                   > 0 is first bad argument
                     99:                                   -1 if extra actual arguments
                    100:                                   -2 if too few actual arguments.
                    101:                                   -3 if const/non const method mismatch.
                    102:                                   -4 if type unification failed.
                    103:                                   -5 if contravariance violation.  */
                    104:     } u;
                    105: };
                    106: int rank_for_overload ();
                    107: 
                    108: /* Variables shared between class.c and call.c.  */
                    109: 
                    110: extern int n_vtables;
                    111: extern int n_vtable_entries;
                    112: extern int n_vtable_searches;
                    113: extern int n_vtable_elems;
                    114: extern int n_convert_harshness;
                    115: extern int n_compute_conversion_costs;
                    116: extern int n_build_method_call;
                    117: extern int n_inner_fields_searched;

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.