Commit 607cf131 by Mark Mitchell Committed by Mark Mitchell

class.c (check_field_decls): Don't return a value.

1999-12-16  Mark Mitchell  <mark@codesourcery.com>

	* class.c (check_field_decls): Don't return a value.
	(avoid_overlap): Moved here from tree.c.
	(build_base_fields): Likewise.
	(check_bases): New function, split out from finish_base_struct.
	(check_bases_and_members): New function, split out from finish_struct_1.
	(struct base_info): Remove cant_have_default_ctor,
	cant_have_const_ctor, cant_have_asn_ref.
	(finish_base_struct): Split semantic analysis into check_bases.
	(finish_struct_methods): Fix bogus assertion.
	(check_field_decls): Call finish_struct_anon here.
	(build_vbase_pointer_fields): Use CLASSTYPE_N_BASECLASSES.
	(finish_struct_1): Use check_bases_and_members.  Reorganize.
	* cp-tree.h (CLASSTYPE_VBASECLASSES): Improve documentation.
	(build_base_fields): Don't declare.
	* tree.c (avoid_overlap): Remove.
	(build_base_fields): Likewise.

From-SVN: r30983
parent a97901e6
1999-12-16 Mark Mitchell <mark@codesourcery.com> 1999-12-16 Mark Mitchell <mark@codesourcery.com>
* class.c (check_field_decls): Don't return a value.
(avoid_overlap): Moved here from tree.c.
(build_base_fields): Likewise.
(check_bases): New function, split out from finish_base_struct.
(check_bases_and_members): New function, split out from finish_struct_1.
(struct base_info): Remove cant_have_default_ctor,
cant_have_const_ctor, cant_have_asn_ref.
(finish_base_struct): Split semantic analysis into check_bases.
(finish_struct_methods): Fix bogus assertion.
(check_field_decls): Call finish_struct_anon here.
(build_vbase_pointer_fields): Use CLASSTYPE_N_BASECLASSES.
(finish_struct_1): Use check_bases_and_members. Reorganize.
* cp-tree.h (CLASSTYPE_VBASECLASSES): Improve documentation.
(build_base_fields): Don't declare.
* tree.c (avoid_overlap): Remove.
(build_base_fields): Likewise.
* optimize.c (struct inline_data): Remove scope_stmt. * optimize.c (struct inline_data): Remove scope_stmt.
(remap_block): Don't use insert_block_after_note. Don't update (remap_block): Don't use insert_block_after_note. Don't update
scope_stmt. scope_stmt.
......
...@@ -1388,7 +1388,8 @@ struct lang_type ...@@ -1388,7 +1388,8 @@ struct lang_type
/* The number of virtual functions defined for this /* The number of virtual functions defined for this
_CLASSTYPE node. */ _CLASSTYPE node. */
#define CLASSTYPE_VSIZE(NODE) (TYPE_LANG_SPECIFIC(NODE)->vsize) #define CLASSTYPE_VSIZE(NODE) (TYPE_LANG_SPECIFIC(NODE)->vsize)
/* The virtual base classes that this type uses. */ /* The direct and indirect virtual base classes that this type uses in
depth-first left-to-right order. */
#define CLASSTYPE_VBASECLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->vbases) #define CLASSTYPE_VBASECLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->vbases)
/* The virtual function pointer fields that this type contains. */ /* The virtual function pointer fields that this type contains. */
#define CLASSTYPE_VFIELDS(NODE) (TYPE_LANG_SPECIFIC(NODE)->vfields) #define CLASSTYPE_VFIELDS(NODE) (TYPE_LANG_SPECIFIC(NODE)->vfields)
...@@ -4012,7 +4013,6 @@ extern tree build_cplus_method_type PROTO((tree, tree, tree)); ...@@ -4012,7 +4013,6 @@ extern tree build_cplus_method_type PROTO((tree, tree, tree));
extern tree build_cplus_staticfn_type PROTO((tree, tree, tree)); extern tree build_cplus_staticfn_type PROTO((tree, tree, tree));
extern tree build_cplus_array_type PROTO((tree, tree)); extern tree build_cplus_array_type PROTO((tree, tree));
extern int layout_basetypes PROTO((tree, int)); extern int layout_basetypes PROTO((tree, int));
extern tree build_base_fields PROTO((tree));
extern tree hash_tree_cons PROTO((tree, tree, tree)); extern tree hash_tree_cons PROTO((tree, tree, tree));
extern tree hash_tree_chain PROTO((tree, tree)); extern tree hash_tree_chain PROTO((tree, tree));
extern tree hash_chainon PROTO((tree, tree)); extern tree hash_chainon PROTO((tree, tree));
......
...@@ -98,6 +98,7 @@ static int is_back_referenceable_type PROTO((tree)); ...@@ -98,6 +98,7 @@ static int is_back_referenceable_type PROTO((tree));
static int check_btype PROTO((tree)); static int check_btype PROTO((tree));
static void build_mangled_name_for_type PROTO((tree)); static void build_mangled_name_for_type PROTO((tree));
static void build_mangled_name_for_type_with_Gcode PROTO((tree, int)); static void build_mangled_name_for_type_with_Gcode PROTO((tree, int));
static void fixup_pending_inline PROTO((struct pending_inline *));
# define OB_INIT() (scratch_firstobj ? (obstack_free (&scratch_obstack, scratch_firstobj), 0) : 0) # define OB_INIT() (scratch_firstobj ? (obstack_free (&scratch_obstack, scratch_firstobj), 0) : 0)
# define OB_PUTC(C) (obstack_1grow (&scratch_obstack, (C))) # define OB_PUTC(C) (obstack_1grow (&scratch_obstack, (C)))
...@@ -142,6 +143,27 @@ init_method () ...@@ -142,6 +143,27 @@ init_method ()
value. */ value. */
static char digit_buffer[128]; static char digit_buffer[128];
/* Fixup the inline function given by INFO now that the class is
complete. */
static void
fixup_pending_inline (info)
struct pending_inline *info;
{
if (info)
{
tree args;
tree fn = info->fndecl;
args = DECL_ARGUMENTS (fn);
while (args)
{
DECL_CONTEXT (args) = fn;
args = TREE_CHAIN (args);
}
}
}
/* Move inline function definitions out of structure so that they /* Move inline function definitions out of structure so that they
can be processed normally. CNAME is the name of the class can be processed normally. CNAME is the name of the class
we are working from, METHOD_LIST is the list of method lists we are working from, METHOD_LIST is the list of method lists
...@@ -164,43 +186,13 @@ do_inline_function_hair (type, friend_list) ...@@ -164,43 +186,13 @@ do_inline_function_hair (type, friend_list)
method = TREE_VEC_ELT (method, 2); method = TREE_VEC_ELT (method, 2);
} }
while (method) /* Do inline member functions. */
{ for (; method; method = TREE_CHAIN (method))
/* Do inline member functions. */ fixup_pending_inline (DECL_PENDING_INLINE_INFO (method));
struct pending_inline *info = DECL_PENDING_INLINE_INFO (method);
if (info)
{
tree args;
my_friendly_assert (info->fndecl == method, 238);
args = DECL_ARGUMENTS (method);
while (args)
{
DECL_CONTEXT (args) = method;
args = TREE_CHAIN (args);
}
}
method = TREE_CHAIN (method);
}
while (friend_list)
{
tree fndecl = TREE_VALUE (friend_list);
struct pending_inline *info = DECL_PENDING_INLINE_INFO (fndecl);
if (info)
{
tree args;
my_friendly_assert (info->fndecl == fndecl, 239);
args = DECL_ARGUMENTS (fndecl);
while (args)
{
DECL_CONTEXT (args) = fndecl;
args = TREE_CHAIN (args);
}
}
friend_list = TREE_CHAIN (friend_list); /* Do friends. */
} for (; friend_list; friend_list = TREE_CHAIN (friend_list))
fixup_pending_inline (DECL_PENDING_INLINE_INFO (TREE_VALUE (friend_list)));
} }
/* Here is where overload code starts. */ /* Here is where overload code starts. */
......
...@@ -38,7 +38,6 @@ static void list_hash_add PROTO((int, tree)); ...@@ -38,7 +38,6 @@ static void list_hash_add PROTO((int, tree));
static int list_hash PROTO((tree, tree, tree)); static int list_hash PROTO((tree, tree, tree));
static tree list_hash_lookup PROTO((int, tree, tree, tree)); static tree list_hash_lookup PROTO((int, tree, tree, tree));
static void propagate_binfo_offsets PROTO((tree, tree)); static void propagate_binfo_offsets PROTO((tree, tree));
static int avoid_overlap PROTO((tree, tree));
static cp_lvalue_kind lvalue_p_1 PROTO((tree, int)); static cp_lvalue_kind lvalue_p_1 PROTO((tree, int));
static tree no_linkage_helper PROTO((tree *, int *, void *)); static tree no_linkage_helper PROTO((tree *, int *, void *));
static tree build_srcloc PROTO((char *, int)); static tree build_srcloc PROTO((char *, int));
...@@ -878,117 +877,6 @@ layout_basetypes (rec, max) ...@@ -878,117 +877,6 @@ layout_basetypes (rec, max)
return max; return max;
} }
/* If the empty base field in DECL overlaps with a base of the same type in
NEWDECL, which is either another base field or the first data field of
the class, pad the base just before NEWDECL and return 1. Otherwise,
return 0. */
static int
avoid_overlap (decl, newdecl)
tree decl, newdecl;
{
tree field;
if (newdecl == NULL_TREE
|| ! types_overlap_p (TREE_TYPE (decl), TREE_TYPE (newdecl)))
return 0;
for (field = decl; TREE_CHAIN (field) && TREE_CHAIN (field) != newdecl;
field = TREE_CHAIN (field))
;
DECL_SIZE (field) = integer_one_node;
return 1;
}
/* Returns a list of fields to stand in for the base class subobjects
of REC. These fields are later removed by layout_basetypes. */
tree
build_base_fields (rec)
tree rec;
{
/* Chain to hold all the new FIELD_DECLs which stand in for base class
subobjects. */
tree base_decls = NULL_TREE;
tree binfos = TYPE_BINFO_BASETYPES (rec);
int n_baseclasses = binfos ? TREE_VEC_LENGTH (binfos) : 0;
tree decl, nextdecl;
int i, saw_empty = 0;
unsigned int base_align = 0;
for (i = 0; i < n_baseclasses; ++i)
{
register tree base_binfo = TREE_VEC_ELT (binfos, i);
register tree basetype = BINFO_TYPE (base_binfo);
if (TYPE_SIZE (basetype) == 0)
/* This error is now reported in xref_tag, thus giving better
location information. */
continue;
if (TREE_VIA_VIRTUAL (base_binfo))
continue;
decl = build_lang_decl (FIELD_DECL, NULL_TREE, basetype);
DECL_ARTIFICIAL (decl) = 1;
DECL_FIELD_CONTEXT (decl) = DECL_CLASS_CONTEXT (decl) = rec;
DECL_SIZE (decl) = CLASSTYPE_SIZE (basetype);
DECL_ALIGN (decl) = CLASSTYPE_ALIGN (basetype);
TREE_CHAIN (decl) = base_decls;
base_decls = decl;
if (! flag_new_abi)
{
/* Brain damage for backwards compatibility. For no good reason,
the old layout_basetypes made every base at least as large as
the alignment for the bases up to that point, gratuitously
wasting space. So we do the same thing here. */
base_align = MAX (base_align, DECL_ALIGN (decl));
DECL_SIZE (decl)
= size_int (MAX (TREE_INT_CST_LOW (DECL_SIZE (decl)),
(int) base_align));
}
else if (DECL_SIZE (decl) == integer_zero_node)
saw_empty = 1;
}
/* Reverse the list of fields so we allocate the bases in the proper
order. */
base_decls = nreverse (base_decls);
/* In the presence of empty base classes, we run the risk of allocating
two objects of the same class on top of one another. Avoid that. */
if (flag_new_abi && saw_empty)
for (decl = base_decls; decl; decl = TREE_CHAIN (decl))
{
if (DECL_SIZE (decl) == integer_zero_node)
{
/* First step through the following bases until we find
an overlap or a non-empty base. */
for (nextdecl = TREE_CHAIN (decl); nextdecl;
nextdecl = TREE_CHAIN (nextdecl))
{
if (avoid_overlap (decl, nextdecl)
|| DECL_SIZE (nextdecl) != integer_zero_node)
goto nextbase;
}
/* If we're still looking, also check against the first
field. */
for (nextdecl = TYPE_FIELDS (rec);
nextdecl && TREE_CODE (nextdecl) != FIELD_DECL;
nextdecl = TREE_CHAIN (nextdecl))
/* keep looking */;
avoid_overlap (decl, nextdecl);
}
nextbase:;
}
return base_decls;
}
/* Hashing of lists so that we don't make duplicates. /* Hashing of lists so that we don't make duplicates.
The entry point is `list_hash_canon'. */ The entry point is `list_hash_canon'. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment