BSD 4_4_Lite2 development
[unix-history] / usr / src / contrib / gcc-2.3.3 / g++int.texi
CommitLineData
f8cd3f85
C
1@node internals
2@chapter Internal Architecture of the Compiler
3
4This is meant to describe the C++ frontend for gcc in detail.
5Questions and comments to mrs@cygnus.com.
6
7@index delete, two argument
8For two argument delete, the second argument is always calculated by
9``virtual_size ='' in the source. It currently has a problem, in that
10object size is not calculated by the virtual destructor and passed back
11for the second parameter to delete. Destructors need to return a value
12just like constructors.
13
14@index visibility checking
15Visibility checking in general is unimplemented, there are a few cases
16where it is implemented. grok_enum_decls should be used in more places
17to do visibility checking, but this is only the tip of a bigger problem.
18
19@index volatile
20volatile is not implemented in general.
21
22@index const
23const is completely implemented except for function overload selection.
24
25@index protected base classes
26Protected base classes are not fully implemented.
27
28@item BLOCK_SUPERCONTEXT
29In the outermost scope of each function, it points to the FUNCTION_DECL
30node. It aids in better DWARF support of inline functions.
31
32@item DECL_CLASS_CONTEXT
33Identifys the context that the _DECL was found in.
34
35Has values of:
36
37 RECORD_TYPE, or UNION_TYPE.
38
39What things can this be used on:
40
41 TYPE_DECLs, *_DECLs
42
43@item DECL_NESTED_TYPENAME
44Holds the fully qualified type name. Example, Base::Derived.
45
46Has values of:
47
48 IDENTIFIER_NODE
49
50What things can this be used on:
51
52 TYPE_DECLs
53
54@item TYPE_NAME
55Names the type.
56
57Has values of:
58
59 0 for things that don't have names.
60 should be IDENTIFIER_NODE for RECORD_TYPEs UNION_TYPEs and ENUM_TYPEs.
61 TYPE_DECL for RECORD_TYPEs, UNION_TYPEs and ENUM_TYPEs, but shouldn't
62 be.
63 TYPE_DECL for typedefs, unsure why.
64
65What things can one use this on:
66
67 TYPE_DECLs
68 RECORD_TYPEs
69 UNION_TYPEs
70 ENUM_TYPEs
71
72How is it used:
73
74 Used by dwarfout.c to fetch the name of structs, unoins and enums
75 to create AT_name fields.
76
77History:
78
79 It currently points to the TYPE_DECL for RECORD_TYPEs,
80 UNION_TYPEs and ENUM_TYPEs, but it should be history soon.
81
82@item DECL_NAME
83
84Has values of:
85
86 0 for things that don't have names.
87 IDENTIFIER_NODE for TYPE_DECLs.
88
89@item TYPE_DECL
90Used to represent typedefs, and used to represent bindings layers.
91
92Components:
93
94 DECL_NAME is the name of the typedef. For example, foo would
95 be found in the DECL_NAME slot when @code{typedef int foo;} is
96 seen.
97
98 DECL_SOURCE_LINE identifies what source line number in the
99 source file the declaration was found at. A value of 0
100 indicates that this TYPE_DECL is just an internal binding layer
101 marker, and does not correspond to a user suppiled typedef.
102
103 DECL_SOURCE_FILE @xref{DECL_SOURCE_FILE}.
104
105@item DECL_IGNORED_P
106A bit that can be set to inform the debug information output routines in
107the backend that a certain _DECL node should be totally ignored.
108
109Used in cases where it is known that the debugging information will be
110output in another file, or where a sub-type is known not to be needed
111because the enclosing type is not needed.
112
113A compiler constructed virtual destructor in derived classes that do not
114define an exlicit destructor that was defined exlicit in a base class
115has this bit set as well. Also used on __FUNCTION__ and
116__PRETTY_FUNCTION__ to mark they are ``compiler generated.'' c-decl and
117c-lex.c both want DECL_IGNORED_P set for ``internally generated vars,''
118and ``user-invisible variable.''
119
120Functions built by the C++ front-end such as default destructors,
121virtual desctructors and default constructors want to be marked that
122they are compiler generated, but unsure why.
123
124Currently, it is used in an absolute way in the C++ front-end, as an
125optimization, to tell the debug information output routines to not
126generate debugging information that will be output by another separately
127compiled file.
128
129@findex DECL_SOURCE_FILE
130@item DECL_SOURCE_FILE
131Identifies what source file a particular declaration was found in.
132
133Has values of:
134
135 "<built-in>" on TYPE_DECLs to mean the typedef is built in.
136
137@item DECL_SOURCE_LINE
138Identifies what source line number in the source file the declaration
139was found at.
140
141Has values of:
142
143 0 for an undefined label.
144
145 0 for TYPE_DECLs that are internally generated.
146
147 0 for FUNCTION_DECLs for functions generated by the compiler.
148 (not yet, but should be.)
149
150@item DECL_VIRTUAL_P
151A flag used on FIELD_DECLs and VAR_DECLs. (Documentation in tree.h is
152wrong.) Used in VAR_DECLs to indicate that the variable is a vtable.
153It is also used in FIELD_DECLs for vtable pointers.
154
155What things can this be used on:
156
157 FIELD_DECLs and VAR_DECLs.
158
159@item DECL_VINDEX
160Used for FUNCTION_DECLs in two different ways. Before the structure
161containing the FUNCTION_DECL is laid out, DECL_VINDEX may point to a
162FUNCTION_DECL in a base class which is the FUNCTION_DECL which this
163FUNCTION_DECL will replace as a virtual function. When the class is
164laid out, this pointer is changed to an INTEGER_CST node which is
165suitable for use as an index into the virtual function table.
166
167DECL_VINDEX may be a TREE_LIST, that would seem to be a list of
168overridden FUNCTION_DECLs. add_virtual_function has code to deal with
169this when it uses the variable base_fndecl_list, but it would seem that
170somehow, it is possible for the TREE_LIST to pursist until method_call,
171and it should not.
172
173@item TREE_USED
174
175Has values of:
176
177 0 for unused labels.
178
179@item TREE_ADDRESSABLE
180A flag that is set for any type that has a constructor.
181
182@item CLASSTYPE_METHOD_VEC
183The following is true after finish_struct has been called (on the
184class?) but not before. Before finish_struct is called, things are
185different to some extent. Contains a TREE_VEC of methods of the class.
186The TREE_VEC_LENGTH is the number of differently named methods plus one
187for the 0th entry. The 0th entry is always allocated, and reserved for
188ctors and dtors. If there are none, TREE_VEC_ELT(N,0) == NULL_TREE.
189Each entry of the TREE_VEC is a FUNCTION_DECL. For each FUNCTION_DECL,
190there is a DECL_CHAIN slot. If the FUNCTION_DECL is the last one with a
191given name, the DECL_CHAIN slot is NULL_TREE. Otherwise it is the next
192method that has the same name (but a different signature). It would
193seem that it is not true that because the DECL_CHAIN slot is used in
194this way, we cannot call pushdecl to put the method in the global scope
195(cause that would overwrite the TREE_CHAIN slot), because they use
196different _CHAINs.
197
198friends are kept in TREE_LISTs, so that there's no need to use their
199TREE_CHAIN slot for anything.
200
201Has values of:
202
203 TREE_VEC
204
205@item TYPE_METHOD
206Related to CLASSTYPE_METHOD_VEC. Chained together with TREE_CHAIN.
207dbxout.c uses this to get at the methods of a class.
208
209@item CLASSTYPE_TAGS
210CLASSTYPE_TAGS is a linked (via TREE_CHAIN) list of member classes of a
211class. TREE_PURPOSE is the name, TREE_VALUE is the type (pushclass scans
212these and calls pushtag on them.)
213
214finish_struct scans these to produce TYPE_DECLs to add to the
215TYPE_FIELDS of the type.
216
217It is expected that name found in the TREE_PURPOSE slot is unique,
218resolve_scope_to_name is one such place that depends upon this
219uniqueness.
220
221@item TYPE_FIELDS
222TYPE_FIELDS is a linked list (via TREE_CHAIN) of member types of a
223class. The list can contain TYPE_DECLs, but there can also be other
224things in the list apparently. See also CLASSTYPE_TAGS.
225
226@item TREE_PRIVATE
227Set for FIELD_DECLs by finish_struct. But not uniformly set.
228
229The following routines do something with PRIVATE visibility:
230build_method_call, alter_visibility, finish_struct_methods,
231finish_struct, convert_to_aggr, CWriteLanguageDecl, CWriteLanguageType,
232CWriteUseObject, compute_visibility, lookup_field, dfs_pushdecl,
233GNU_xref_member, dbxout_type_fields, dbxout_type_method_1
234
235@item TREE_PROTECTED
236The following routines do something with PROTECTED visibility:
237build_method_call, alter_visibility, finish_struct, convert_to_aggr,
238CWriteLanguageDecl, CWriteLanguageType, CWriteUseObject,
239compute_visibility, lookup_field, GNU_xref_member, dbxout_type_fields,
240dbxout_type_method_1