Annotation of gcc/cp-class.h, revision 1.1.1.1

1.1       root        1: /* The following structure is used when comparing various alternatives
                      2:    for overloading.  The unsigned quantity `strikes.i' is used
                      3:    for fast comparison of two possibilities.  This number is an
                      4:    aggregate of four constituents:
                      5: 
                      6:      EVIL: if this is non-zero, then the candidate should not be considered
                      7:      USER: if this is non-zero, then a user-defined type conversion is needed
                      8:      B_OR_D: if this is non-zero, then use a base pointer instead of the
                      9:              type of the pointer we started with.
                     10:      EASY: if this is non-zero, then we have a builtin conversion
                     11:            (such as int to long, int to float, etc) to do.
                     12: 
                     13:    If two candidates require user-defined type conversions, and the
                     14:    type conversions are not identical, then an ambiguity error
                     15:    is reported.
                     16: 
                     17:    If two candidates agree on user-defined type conversions,
                     18:    and one uses pointers of strictly higher type (derived where
                     19:    another uses base), then that alternative is silently chosen.
                     20: 
                     21:    If two candidates have a non-monotonic derived/base pointer
                     22:    relationship, and/or a non-monotonic easy conversion relationship,
                     23:    then a warning is emitted to show which paths are possible, and
                     24:    which one is being chosen.
                     25: 
                     26:    For example:
                     27: 
                     28:    int i;
                     29:    double x;
                     30: 
                     31:    overload f;
                     32:    int f (int, int);
                     33:    double f (double, double);
                     34: 
                     35:    f (i, x);   // draws a warning
                     36: 
                     37:    struct B
                     38:    {
                     39:      f (int);
                     40:    } *bb;
                     41:    struct D : B
                     42:    {
                     43:      f (double);
                     44:    } *dd;
                     45: 
                     46:    dd->f (x);  // exact match
                     47:    dd->f (i);  // draws warning
                     48: 
                     49:    Note that this technique really only works for 255 arguments.  Perhaps
                     50:    this is not enough.  */
                     51: 
                     52: struct candidate
                     53: {
                     54:   tree function;               /* A FUNCTION_DECL */
                     55: 
                     56:   unsigned char evil;          /* !0 if this will never convert.  */
                     57:   unsigned char user;          /* !0 if at least one user-defined type conv.  */
                     58:   unsigned short b_or_d;       /* count number of derived->base or
                     59:                                   base->derived conv.  */
                     60:   unsigned short easy;         /* count number of builtin type conv.  */
                     61:   tree arg;                    /* first parm to function.  */
                     62:   unsigned short *harshness;   /* Indexed by argument number, encodes
                     63:                                   evil, user, d_to_b, and easy strikes for
                     64:                                   that argument.
                     65:                                   At end of array, we store the index+1
                     66:                                   of where we started using default
                     67:                                   parameters, or 0 if there are none.  */
                     68:   union
                     69:     {
                     70:       tree field;              /* If no evil strikes, the FUNCTION_DECL of
                     71:                                   the function (if a member function).  */
                     72:       int bad_arg;             /* the index of the first bad argument:
                     73:                                   0 if no bad arguements
                     74:                                   > 0 is first bad argument
                     75:                                   -1 if extra actual arguments
                     76:                                   -2 if too few actual arguments.
                     77:                                   -3 if const/non const method mismatch.
                     78:                                   -4 if type unification failed.
                     79:                                   -5 if contravariance violation.  */
                     80:     } u;
                     81: };
                     82: int rank_for_overload ();
                     83: 
                     84: /* Variables shared between cp-class.c and cp-call.c.  */
                     85: 
                     86: extern int n_vtables;
                     87: extern int n_vtable_entries;
                     88: extern int n_vtable_searches;
                     89: extern int n_vtable_elems;
                     90: extern int n_convert_harshness;
                     91: extern int n_compute_conversion_costs;
                     92: extern int n_build_method_call;
                     93: 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.