source: trunk/third/gcc/cp/class.h @ 8834

Revision 8834, 4.3 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r8833, which included commits to RCS files with non-trunk default branches.
Line 
1/* Variables and structures for overloading rules.
2   Copyright (C) 1993 Free Software Foundation, Inc.
3
4This file is part of GNU CC.
5
6GNU CC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU CC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING.  If not, write to
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA.  */
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
56struct 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
76struct 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};
106int rank_for_overload ();
107
108/* Variables shared between class.c and call.c.  */
109
110extern int n_vtables;
111extern int n_vtable_entries;
112extern int n_vtable_searches;
113extern int n_vtable_elems;
114extern int n_convert_harshness;
115extern int n_compute_conversion_costs;
116extern int n_build_method_call;
117extern int n_inner_fields_searched;
Note: See TracBrowser for help on using the repository browser.