Added g++ script so g++ compiles .c files as c++ code
[unix-history] / gnu / usr.bin / cc / cc1plus / cp-class.h
CommitLineData
9bf86ebb
PR
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, 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 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
73struct candidate
74{
75 tree function; /* A FUNCTION_DECL */
76
77 unsigned char evil; /* !0 if this will never convert. */
78 unsigned char ellipsis; /* !0 if a match against an ellipsis occurred */
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:
95 0 if no bad arguments
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};
104int rank_for_overload ();
105
106/* Variables shared between cp-class.c and cp-call.c. */
107
108extern int n_vtables;
109extern int n_vtable_entries;
110extern int n_vtable_searches;
111extern int n_vtable_elems;
112extern int n_convert_harshness;
113extern int n_compute_conversion_costs;
114extern int n_build_method_call;
115extern int n_inner_fields_searched;