Commit 9ba5ff0f by Nathan Sidwell Committed by Nathan Sidwell

vec.h: Propagate location information properly.

.:	* vec.h: Propagate location information properly.
	(VEC_T_iterate): Add result pointer parameter.
	(VEC_T_space): New.
	(VEC_T_reserve): Use it.
cp:
	* class.c (add_method): Delay adding the slot until the end.
	(determine_primary_base): Adjust VEC_iterate invokation.
	(resort_type_method_vec, finish_struct_methods, warn_hidden,
	walk_subobject_offsets, end_of_class, warn_about_ambiguous_bases,
	build_vtbl_initializer): Likewise.
	* init.c (sort_mem_initializers, build_delete, push_base_cleanups,
	build_vbase_delete): Likewise.
	* method.c (do_build_copy_constructor): Likewise.
	* name-lookup.c (new_class_binding, print_binding_level,
	poplevel_class, store_class_bindings, push_to_top_level,
	pop_from_top_level): Likewise.
	* pt.c (check_explicit_specialization): Likewise.
	* search.c (lookup_conversion_operator, lookup_fnfields_1,
	get_pure_virtuals, add_conversions, dfs_check_overlap,
	binfo_for_vbase): Likewise.

From-SVN: r84924
parent 6df91b00
2004-07-19 Nathan Sidwell <nathan@codesourcery.com>
* vec.h: Propagate location information properly.
(VEC_T_iterate): Add result pointer parameter.
(VEC_T_space): New.
(VEC_T_reserve): Use it.
2004-07-19 Daniel Jacobowitz <dan@debian.org>
* Makefile.in (c-format.o): Depend on c-format.h.
......
2004-07-19 Nathan Sidwell <nathan@codesourcery.com>
* class.c (add_method): Delay adding the slot until the end.
(determine_primary_base): Adjust VEC_iterate invokation.
(resort_type_method_vec, finish_struct_methods, warn_hidden,
walk_subobject_offsets, end_of_class, warn_about_ambiguous_bases,
build_vtbl_initializer): Likewise.
* init.c (sort_mem_initializers, build_delete, push_base_cleanups,
build_vbase_delete): Likewise.
* method.c (do_build_copy_constructor): Likewise.
* name-lookup.c (new_class_binding, print_binding_level,
poplevel_class, store_class_bindings, push_to_top_level,
pop_from_top_level): Likewise.
* pt.c (check_explicit_specialization): Likewise.
* search.c (lookup_conversion_operator, lookup_fnfields_1,
get_pure_virtuals, add_conversions, dfs_check_overlap,
binfo_for_vbase): Likewise.
2004-07-19 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/12170
......
......@@ -801,12 +801,13 @@ void
add_method (tree type, tree method)
{
int using;
size_t len;
size_t slot;
unsigned slot;
tree overload;
int template_conv_p;
VEC(tree) *method_vec;
bool complete_p;
bool insert_p = false;
tree current_fns;
if (method == error_mark_node)
return;
......@@ -830,8 +831,6 @@ add_method (tree type, tree method)
CLASSTYPE_METHOD_VEC (type) = method_vec;
}
len = VEC_length (tree, method_vec);
/* Constructors and destructors go in special slots. */
if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (method))
slot = CLASSTYPE_CONSTRUCTOR_SLOT;
......@@ -848,13 +847,13 @@ add_method (tree type, tree method)
}
else
{
bool insert_p = true;
bool conv_p = DECL_CONV_FN_P (method);
tree m;
insert_p = true;
/* See if we already have an entry with this name. */
for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT;
(m = VEC_iterate (tree, method_vec, slot));
VEC_iterate (tree, method_vec, slot, m);
++slot)
{
m = OVL_CURRENT (m);
......@@ -877,24 +876,8 @@ add_method (tree type, tree method)
&& DECL_NAME (m) > DECL_NAME (method))
break;
}
/* If we need a new slot, make room. */
if (insert_p)
{
/* We expect to add few methods in the COMPLETE_P case, so
just make room for one more method. */
if (complete_p)
VEC_reserve (tree, method_vec, 1);
if (slot == len)
VEC_safe_push (tree, method_vec, NULL_TREE);
else
VEC_safe_insert (tree, method_vec, slot, NULL_TREE);
len++;
/* Inserting a new slot may have caused the vector to be
reallocated. */
CLASSTYPE_METHOD_VEC (type) = method_vec;
}
}
current_fns = insert_p ? NULL_TREE : VEC_index (tree, method_vec, slot);
if (processing_template_decl)
/* TYPE is a template class. Don't issue any errors now; wait
......@@ -905,9 +888,7 @@ add_method (tree type, tree method)
tree fns;
/* Check to see if we've already got this method. */
for (fns = VEC_index (tree, method_vec, slot);
fns;
fns = OVL_NEXT (fns))
for (fns = current_fns; fns; fns = OVL_NEXT (fns))
{
tree fn = OVL_CURRENT (fns);
tree parms1;
......@@ -975,13 +956,24 @@ add_method (tree type, tree method)
}
/* Add the new binding. */
overload = build_overload (method, VEC_index (tree, method_vec, slot));
if (!DECL_CONSTRUCTOR_P (method)
&& !DECL_DESTRUCTOR_P (method)
&& !complete_p)
overload = build_overload (method, current_fns);
if (slot >= CLASSTYPE_FIRST_CONVERSION_SLOT && !complete_p)
push_class_level_binding (DECL_NAME (method), overload);
/* Actually insert the new method. */
if (insert_p)
{
/* We only expect to add few methods in the COMPLETE_P case, so
just make room for one more method in that case. */
if (VEC_reserve (tree, method_vec, complete_p ? 1 : -1))
CLASSTYPE_METHOD_VEC (type) = method_vec;
if (slot == VEC_length (tree, method_vec))
VEC_quick_push (tree, method_vec, overload);
else
VEC_quick_insert (tree, method_vec, slot, overload);
}
else
/* Replace the current slot. */
VEC_replace (tree, method_vec, slot, overload);
}
......@@ -1275,8 +1267,9 @@ static void
determine_primary_base (tree t)
{
unsigned i, n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (t));
tree type_binfo;
tree type_binfo = TYPE_BINFO (t);
tree vbase_binfo;
VEC(tree) *vbases;
/* If there are no baseclasses, there is certainly no primary base. */
if (n_baseclasses == 0)
......@@ -1324,8 +1317,8 @@ determine_primary_base (tree t)
/* Find the indirect primary bases - those virtual bases which are primary
bases of something else in this hierarchy. */
for (i = 0; (vbase_binfo = VEC_iterate
(tree, CLASSTYPE_VBASECLASSES (t), i)); i++)
for (vbases = CLASSTYPE_VBASECLASSES (t), i = 0;
VEC_iterate (tree, vbases, i, vbase_binfo); i++)
{
unsigned j;
......@@ -1335,11 +1328,12 @@ determine_primary_base (tree t)
for (j = 0; j != n_baseclasses; ++j)
{
unsigned k;
VEC (tree) *base_vbases;
tree base_vbase_binfo;
tree basetype = BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (t), j));
for (k = 0; (base_vbase_binfo = VEC_iterate
(tree, CLASSTYPE_VBASECLASSES (basetype), k)); k++)
for (base_vbases = CLASSTYPE_VBASECLASSES (basetype), k = 0;
VEC_iterate (tree, base_vbases, k, base_vbase_binfo); k++)
{
if (BINFO_PRIMARY_P (base_vbase_binfo)
&& same_type_p (BINFO_TYPE (base_vbase_binfo),
......@@ -1677,7 +1671,7 @@ resort_type_method_vec (void* obj,
/* The type conversion ops have to live at the front of the vec, so we
can't sort them. */
for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT;
(fn = VEC_iterate (tree, method_vec, slot));
VEC_iterate (tree, method_vec, slot, fn);
++slot)
if (!DECL_CONV_FN_P (OVL_CURRENT (fn)))
break;
......@@ -1738,8 +1732,8 @@ finish_struct_methods (tree t)
/* The type conversion ops have to live at the front of the vec, so we
can't sort them. */
for (slot = 2;
(fn_fields = VEC_iterate (tree, method_vec, slot));
for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT;
VEC_iterate (tree, method_vec, slot, fn_fields);
++slot)
if (!DECL_CONV_FN_P (OVL_CURRENT (fn_fields)))
break;
......@@ -2369,7 +2363,7 @@ warn_hidden (tree t)
/* We go through each separately named virtual function. */
for (i = CLASSTYPE_FIRST_CONVERSION_SLOT;
(fns = VEC_iterate (tree, method_vec, i));
VEC_iterate (tree, method_vec, i, fns);
++i)
{
tree fn;
......@@ -3229,6 +3223,7 @@ walk_subobject_offsets (tree type,
if (abi_version_at_least (2) && CLASSTYPE_VBASECLASSES (type))
{
unsigned ix;
VEC (tree) *vbases;
/* Iterate through the virtual base classes of TYPE. In G++
3.2, we included virtual bases in the direct base class
......@@ -3236,8 +3231,8 @@ walk_subobject_offsets (tree type,
correct offsets for virtual bases are only known when
working with the most derived type. */
if (vbases_p)
for (ix = 0; (binfo = VEC_iterate
(tree, CLASSTYPE_VBASECLASSES (type), ix)); ix++)
for (vbases = CLASSTYPE_VBASECLASSES (type), ix = 0;
VEC_iterate (tree, vbases, ix, binfo); ix++)
{
r = walk_subobject_offsets (binfo,
f,
......@@ -4402,7 +4397,9 @@ static tree
end_of_class (tree t, int include_virtuals_p)
{
tree result = size_zero_node;
VEC (tree) *vbases;
tree binfo;
tree base_binfo;
tree offset;
int i;
......@@ -4422,10 +4419,10 @@ end_of_class (tree t, int include_virtuals_p)
/* G++ 3.2 did not check indirect virtual bases. */
if (abi_version_at_least (2) && include_virtuals_p)
for (i = 0; (binfo = VEC_iterate
(tree, CLASSTYPE_VBASECLASSES (t), i)); i++)
for (vbases = CLASSTYPE_VBASECLASSES (t), i = 0;
VEC_iterate (tree, vbases, i, base_binfo); i++)
{
offset = end_of_base (binfo);
offset = end_of_base (base_binfo);
if (INT_CST_LT_UNSIGNED (result, offset))
result = offset;
}
......@@ -4447,11 +4444,13 @@ static void
warn_about_ambiguous_bases (tree t)
{
int i;
VEC (tree) *vbases;
tree basetype;
tree binfo;
/* Check direct bases. */
for (i = 0; i < BINFO_N_BASE_BINFOS (TYPE_BINFO (t)); ++i)
for (i = 0;
i < BINFO_N_BASE_BINFOS (TYPE_BINFO (t)); ++i)
{
basetype = BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (t), i));
......@@ -4462,8 +4461,8 @@ warn_about_ambiguous_bases (tree t)
/* Check for ambiguous virtual bases. */
if (extra_warnings)
for (i = 0; (binfo = VEC_iterate
(tree, CLASSTYPE_VBASECLASSES (t), i)); i++)
for (vbases = CLASSTYPE_VBASECLASSES (t), i = 0;
VEC_iterate (tree, vbases, i, binfo); i++)
{
basetype = BINFO_TYPE (binfo);
......@@ -7237,6 +7236,7 @@ build_vtbl_initializer (tree binfo,
vtbl_init_data vid;
unsigned ix;
tree vbinfo;
VEC (tree) *vbases;
/* Initialize VID. */
memset (&vid, 0, sizeof (vid));
......@@ -7262,8 +7262,8 @@ build_vtbl_initializer (tree binfo,
/* Clear BINFO_VTABLE_PATH_MARKED; it's set by
build_vbase_offset_vtbl_entries. */
for (ix = 0; (vbinfo = VEC_iterate
(tree, CLASSTYPE_VBASECLASSES (t), ix)); ix++)
for (vbases = CLASSTYPE_VBASECLASSES (t), ix = 0;
VEC_iterate (tree, vbases, ix, vbinfo); ix++)
BINFO_VTABLE_PATH_MARKED (vbinfo) = 0;
/* If the target requires padding between data entries, add that now. */
......
......@@ -460,6 +460,7 @@ sort_mem_initializers (tree t, tree mem_inits)
tree base;
tree sorted_inits;
tree next_subobject;
VEC (tree) *vbases;
int i;
int uses_unions_p;
......@@ -470,8 +471,8 @@ sort_mem_initializers (tree t, tree mem_inits)
sorted_inits = NULL_TREE;
/* Process the virtual bases. */
for (i = 0; (base = VEC_iterate
(tree, CLASSTYPE_VBASECLASSES (t), i)); i++)
for (vbases = CLASSTYPE_VBASECLASSES (t), i = 0;
VEC_iterate (tree, vbases, i, base); i++)
sorted_inits = tree_cons (base, NULL_TREE, sorted_inits);
/* Process the direct bases. */
......@@ -2857,10 +2858,11 @@ build_delete (tree type, tree addr, special_function_kind auto_delete,
void
push_base_cleanups (void)
{
tree binfos;
tree binfos, base_binfo;
int i, n_baseclasses;
tree member;
tree expr;
VEC (tree) *vbases;
/* Run destructors for all virtual baseclasses. */
if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))
......@@ -2872,16 +2874,15 @@ push_base_cleanups (void)
/* The CLASSTYPE_VBASECLASSES vector is in initialization
order, which is also the right order for pushing cleanups. */
for (i = 0; (binfos = VEC_iterate
(tree, CLASSTYPE_VBASECLASSES (current_class_type), i));
i++)
for (vbases = CLASSTYPE_VBASECLASSES (current_class_type), i = 0;
VEC_iterate (tree, vbases, i, base_binfo); i++)
{
if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (BINFO_TYPE (binfos)))
if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (BINFO_TYPE (base_binfo)))
{
expr = build_special_member_call (current_class_ref,
base_dtor_identifier,
NULL_TREE,
binfos,
base_binfo,
(LOOKUP_NORMAL
| LOOKUP_NONVIRTUAL));
expr = build (COND_EXPR, void_type_node, cond,
......@@ -2938,13 +2939,14 @@ build_vbase_delete (tree type, tree decl)
unsigned ix;
tree binfo;
tree result;
VEC (tree) *vbases;
tree addr = build_unary_op (ADDR_EXPR, decl, 0);
my_friendly_assert (addr != error_mark_node, 222);
result = convert_to_void (integer_zero_node, NULL);
for (ix = 0; (binfo = VEC_iterate
(tree, CLASSTYPE_VBASECLASSES (type), ix)); ix++)
for (vbases = CLASSTYPE_VBASECLASSES (type), ix = 0;
VEC_iterate (tree, vbases, ix, binfo); ix++)
{
tree base_addr = convert_force
(build_pointer_type (BINFO_TYPE (binfo)), addr, 0);
......
......@@ -521,15 +521,15 @@ do_build_copy_constructor (tree fndecl)
int cvquals = cp_type_quals (TREE_TYPE (parm));
int i;
tree binfo;
VEC (tree) *vbases;
/* Initialize all the base-classes with the parameter converted
to their type so that we get their copy constructor and not
another constructor that takes current_class_type. We must
deal with the binfo's directly as a direct base might be
inaccessible due to ambiguity. */
for (i = 0; (binfo = VEC_iterate
(tree, CLASSTYPE_VBASECLASSES (current_class_type), i));
i++)
for (vbases = CLASSTYPE_VBASECLASSES (current_class_type), i = 0;
VEC_iterate (tree, vbases, i, binfo); i++)
{
member_init_list
= tree_cons (binfo,
......
......@@ -387,7 +387,7 @@ new_class_binding (tree name, tree value, tree type, cxx_scope *scope)
size_t i;
for (i = 0;
(cb = VEC_iterate (cp_class_binding, scope->class_shadowed, i));
VEC_iterate (cp_class_binding, scope->class_shadowed, i, cb);
i++)
{
cxx_binding **b;
......@@ -1656,9 +1656,7 @@ print_binding_level (struct cp_binding_level* lvl)
cp_class_binding *b;
fprintf (stderr, " class-shadowed:");
for (i = 0;
(b = VEC_iterate(cp_class_binding,
lvl->class_shadowed,
i));
VEC_iterate(cp_class_binding, lvl->class_shadowed, i, b);
++i)
fprintf (stderr, " %s ", IDENTIFIER_POINTER (b->identifier));
fprintf (stderr, "\n");
......@@ -2617,7 +2615,7 @@ poplevel_class (void)
if (level->class_shadowed)
{
for (i = 0;
(cb = VEC_iterate (cp_class_binding, level->class_shadowed, i));
VEC_iterate (cp_class_binding, level->class_shadowed, i, cb);
++i)
IDENTIFIER_BINDING (cb->identifier) = cb->base.previous;
ggc_free (level->class_shadowed);
......@@ -4924,9 +4922,7 @@ store_class_bindings (VEC(cp_class_binding) *names,
cp_class_binding *cb;
timevar_push (TV_NAME_LOOKUP);
for (i = 0;
(cb = VEC_iterate(cp_class_binding, names, i));
++i)
for (i = 0; VEC_iterate(cp_class_binding, names, i, cb); ++i)
store_binding (cb->identifier, old_bindings);
timevar_pop (TV_NAME_LOOKUP);
}
......@@ -4982,9 +4978,7 @@ push_to_top_level (void)
SET_IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (t), TREE_VALUE (t));
}
for (i = 0;
(sb = VEC_iterate (cxx_saved_binding, s->old_bindings, i));
++i)
for (i = 0; VEC_iterate (cxx_saved_binding, s->old_bindings, i, sb); ++i)
IDENTIFIER_MARKED (sb->identifier) = 0;
s->prev = scope_chain;
......@@ -5015,9 +5009,7 @@ pop_from_top_level (void)
current_lang_base = 0;
scope_chain = s->prev;
for (i = 0;
(saved = VEC_iterate (cxx_saved_binding, s->old_bindings, i));
++i)
for (i = 0; VEC_iterate (cxx_saved_binding, s->old_bindings, i, saved); ++i)
{
tree id = saved->identifier;
......
......@@ -1838,7 +1838,7 @@ check_explicit_specialization (tree declarator,
methods = CLASSTYPE_METHOD_VEC (ctype);
if (methods)
for (idx = CLASSTYPE_FIRST_CONVERSION_SLOT;
(ovl = VEC_iterate (tree, methods, idx));
VEC_iterate (tree, methods, idx, ovl);
++idx)
{
if (!DECL_CONV_FN_P (OVL_CURRENT (ovl)))
......
......@@ -1319,8 +1319,7 @@ lookup_conversion_operator (tree class_type, tree type)
for (pass = 0; pass < 2; ++pass)
for (i = CLASSTYPE_FIRST_CONVERSION_SLOT;
(fn = VEC_iterate (tree, methods, i));
++i)
VEC_iterate (tree, methods, i, fn); ++i)
{
/* All the conversion operators come near the beginning of the
class. Therefore, if FN is not a conversion operator, there
......@@ -1410,7 +1409,7 @@ lookup_fnfields_1 (tree type, tree name)
/* Skip the conversion operators. */
for (i = CLASSTYPE_FIRST_CONVERSION_SLOT;
(fn = VEC_iterate (tree, method_vec, i));
VEC_iterate (tree, method_vec, i, fn);
++i)
if (!DECL_CONV_FN_P (OVL_CURRENT (fn)))
break;
......@@ -1442,9 +1441,7 @@ lookup_fnfields_1 (tree type, tree name)
}
}
else
for (;
(fn = VEC_iterate (tree, method_vec, i));
++i)
for (; VEC_iterate (tree, method_vec, i, fn); ++i)
{
#ifdef GATHER_STATISTICS
n_outer_fields_searched++;
......@@ -1887,6 +1884,7 @@ get_pure_virtuals (tree type)
{
unsigned ix;
tree binfo;
VEC (tree) *vbases;
/* Clear the CLASSTYPE_PURE_VIRTUALS list; whatever is already there
is going to be overridden. */
......@@ -1903,8 +1901,8 @@ get_pure_virtuals (tree type)
/* Put the pure virtuals in dfs order. */
CLASSTYPE_PURE_VIRTUALS (type) = nreverse (CLASSTYPE_PURE_VIRTUALS (type));
for (ix = 0; (binfo = VEC_iterate
(tree, CLASSTYPE_VBASECLASSES (type), ix)); ix++)
for (vbases = CLASSTYPE_VBASECLASSES (type), ix = 0;
VEC_iterate (tree, vbases, ix, binfo); ix++)
{
tree virtuals;
......@@ -2078,12 +2076,12 @@ add_conversions (tree binfo, void *data)
return NULL_TREE;
for (i = CLASSTYPE_FIRST_CONVERSION_SLOT;
(tmp = VEC_iterate (tree, method_vec, i));
VEC_iterate (tree, method_vec, i, tmp);
++i)
{
tree name;
if (!tmp || ! DECL_CONV_FN_P (OVL_CURRENT (tmp)))
if (!DECL_CONV_FN_P (OVL_CURRENT (tmp)))
break;
name = DECL_NAME (OVL_CURRENT (tmp));
......@@ -2153,6 +2151,7 @@ dfs_check_overlap (tree empty_binfo, void *data)
{
struct overlap_info *oi = (struct overlap_info *) data;
tree binfo;
for (binfo = TYPE_BINFO (oi->compare_type);
;
binfo = BINFO_BASE_BINFO (binfo, 0))
......@@ -2308,9 +2307,10 @@ binfo_for_vbase (tree base, tree t)
{
unsigned ix;
tree binfo;
VEC (tree) *vbases;
for (ix = 0; (binfo = VEC_iterate
(tree, CLASSTYPE_VBASECLASSES (t), ix)); ix++)
for (vbases = CLASSTYPE_VBASECLASSES (t), ix = 0;
VEC_iterate (tree, vbases, ix, binfo); ix++)
if (BINFO_TYPE (binfo) == base)
return binfo;
return NULL;
......
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