Commit d0cd8b44 by Jason Merrill Committed by Jason Merrill

cp-tree.h (THUNK_GENERATE_WITH_VTABLE_P): Lose.

        * cp-tree.h (THUNK_GENERATE_WITH_VTABLE_P): Lose.
        (struct lang_decl_flags): Lose generate_with_vtable_p.
        (BV_GENERATE_THUNK_WITH_VTABLE_P): Lose.
        * class.c (copy_virtuals): Adjust.
        * decl2.c (mark_vtable_entries): Adjust.
        * method.c (make_thunk, build_vtable_entry): Adjust.
        * class.c (update_vtable_entry_for_fn): Only look as far as the
        first defining class.
        (build_vtbl_initializer): Put nothing in the slot for a function only
        defined in a lost primary virtual base.
        (add_vcall_offset_vtbl_entries_1): Use the same code for
        the lost primary case and the normal case.
        (dfs_unshared_virtual_bases): Don't lose a non-virtual primary base.
        (get_vfield_offset, get_derived_offset): Lose.
        (dfs_find_final_overrider): Use look_for_overrides_here.
        (get_matching_virtual): New fn.
        * semantics.c (emit_associated_thunks): Check BV_USE_VCALL_INDEX_P,
        not BV_VCALL_INDEX.
        * search.c (look_for_overrides_here): Split out from...
        (look_for_overrides_r): Here.

        * class.c (find_final_overrider): Return error_mark_node on error.

From-SVN: r42949
parent acf97e0b
2001-06-06 Jason Merrill <jason_merrill@redhat.com>
* cp-tree.h (THUNK_GENERATE_WITH_VTABLE_P): Lose.
(struct lang_decl_flags): Lose generate_with_vtable_p.
(BV_GENERATE_THUNK_WITH_VTABLE_P): Lose.
* class.c (copy_virtuals): Adjust.
* decl2.c (mark_vtable_entries): Adjust.
* method.c (make_thunk, build_vtable_entry): Adjust.
* class.c (update_vtable_entry_for_fn): Only look as far as the
first defining class.
(build_vtbl_initializer): Put nothing in the slot for a function only
defined in a lost primary virtual base.
(add_vcall_offset_vtbl_entries_1): Use the same code for
the lost primary case and the normal case.
(dfs_unshared_virtual_bases): Don't lose a non-virtual primary base.
(get_vfield_offset, get_derived_offset): Lose.
(dfs_find_final_overrider): Use look_for_overrides_here.
(get_matching_virtual): New fn.
* semantics.c (emit_associated_thunks): Check BV_USE_VCALL_INDEX_P,
not BV_VCALL_INDEX.
* search.c (look_for_overrides_here): Split out from...
(look_for_overrides_r): Here.
* class.c (find_final_overrider): Return error_mark_node on error.
* decl2.c (key_method): #if 0 accidental change.
2001-06-06 John David Anglin <dave@hiauly1.hia.nrc.ca>
* call.c (convert_default_arg): Use INTEGRAL_TYPE_P.
......
......@@ -55,7 +55,6 @@ Boston, MA 02111-1307, USA. */
BASELINK_P (in TREE_LIST)
ICS_ELLIPSIS_FLAG (in _CONV)
BINFO_ACCESS (in BINFO)
BV_GENERATE_THUNK_WITH_VTABLE_P (in TREE_LIST)
2: IDENTIFIER_OPNAME_P.
TYPE_POLYMORHPIC_P (in _TYPE)
ICS_THIS_FLAG (in _CONV)
......@@ -133,10 +132,6 @@ Boston, MA 02111-1307, USA. */
The BV_FN is the declaration for the virtual function itself.
The BV_OVERRIDING_BASE is the binfo for the final overrider for
this function. (That binfo's BINFO_TYPE will always be the same
as the DECL_CLASS_CONTEXT for the function.)
BINFO_VTABLE
Sometimes this is a VAR_DECL. Under the new ABI, it is instead
an expression with POINTER_TYPE pointing that gives the value
......@@ -1736,14 +1731,6 @@ struct lang_type
/* Nonzero if we should use a virtual thunk for this entry. */
#define BV_USE_VCALL_INDEX_P(NODE) \
(TREE_LANG_FLAG_0 (NODE))
/* Nonzero if we should generate this thunk when the vtable that
references it is emitted, rather than with the final overrider. */
#define BV_GENERATE_THUNK_WITH_VTABLE_P(NODE) \
(TREE_LANG_FLAG_1 (NODE))
/* The most derived class. */
/* Nonzero for TREE_LIST node means that this list of things
is a list of parameters, as opposed to a list of expressions. */
......@@ -1806,8 +1793,7 @@ struct lang_decl_flags
unsigned global_dtor_p : 1;
unsigned assignment_operator_p : 1;
unsigned anticipated_p : 1;
unsigned generate_with_vtable_p : 1;
/* Two unused bits. */
/* Three unused bits. */
union {
/* In a FUNCTION_DECL, VAR_DECL, TYPE_DECL, or TEMPLATE_DECL, this
......@@ -3036,11 +3022,6 @@ enum ptrmemfunc_vbit_where_t
#define THUNK_VCALL_OFFSET(DECL) \
(DECL_LANG_SPECIFIC (DECL)->decl_flags.u2.vcall_offset)
/* Nonzero if this thunk should be generated with the vtable that
references it. */
#define THUNK_GENERATE_WITH_VTABLE_P(DECL) \
(DECL_LANG_SPECIFIC (DECL)->decl_flags.generate_with_vtable_p)
/* These macros provide convenient access to the various _STMT nodes
created when parsing template declarations. */
#define TRY_STMTS(NODE) TREE_OPERAND (TRY_BLOCK_CHECK (NODE), 0)
......@@ -3716,7 +3697,6 @@ extern tree get_vtable_decl PARAMS ((tree, int));
extern void add_method PARAMS ((tree, tree, int));
extern int currently_open_class PARAMS ((tree));
extern tree currently_open_derived_class PARAMS ((tree));
extern tree get_vfield_offset PARAMS ((tree));
extern void duplicate_tag_error PARAMS ((tree));
extern tree finish_struct PARAMS ((tree, tree));
extern void finish_struct_1 PARAMS ((tree));
......@@ -4083,7 +4063,7 @@ extern void init_method PARAMS ((void));
extern void set_mangled_name_for_decl PARAMS ((tree));
extern tree build_opfncall PARAMS ((enum tree_code, int, tree, tree, tree));
extern tree hack_identifier PARAMS ((tree, tree));
extern tree make_thunk PARAMS ((tree, tree, tree, int));
extern tree make_thunk PARAMS ((tree, tree, tree));
extern void use_thunk PARAMS ((tree, int));
extern void synthesize_method PARAMS ((tree));
extern tree implicitly_declare_fn PARAMS ((special_function_kind, tree, int));
......@@ -4202,6 +4182,7 @@ extern tree context_for_name_lookup PARAMS ((tree));
extern tree lookup_conversions PARAMS ((tree));
extern tree binfo_for_vtable PARAMS ((tree));
extern tree binfo_from_vbase PARAMS ((tree));
extern tree look_for_overrides_here PARAMS ((tree, tree));
extern tree dfs_walk PARAMS ((tree,
tree (*) (tree, void *),
tree (*) (tree, void *),
......
......@@ -2265,7 +2265,7 @@ mark_vtable_entries (decl)
we know all the thunks we'll need when we emit a virtual
function, so we emit the thunks there instead. */
if (DECL_THUNK_P (fn))
use_thunk (fn, THUNK_GENERATE_WITH_VTABLE_P (fn));
use_thunk (fn, /*emit_p=*/0);
mark_used (fn);
}
}
......@@ -2369,7 +2369,12 @@ key_method (type)
method = TREE_CHAIN (method))
if (DECL_VINDEX (method) != NULL_TREE
&& ! DECL_DECLARED_INLINE_P (method)
&& (! DECL_PURE_VIRTUAL_P (method) || DECL_DESTRUCTOR_P (method)))
&& (! DECL_PURE_VIRTUAL_P (method)
#if 0
/* This would be nice, but we didn't think of it in time. */
|| DECL_DESTRUCTOR_P (method)
#endif
))
return method;
return NULL_TREE;
......
......@@ -295,11 +295,10 @@ request for member `%D' is ambiguous in multiple inheritance lattice",
DELTA is the offset to this and VCALL_INDEX is zero. */
tree
make_thunk (function, delta, vcall_index, generate_with_vtable_p)
make_thunk (function, delta, vcall_index)
tree function;
tree delta;
tree vcall_index;
int generate_with_vtable_p;
{
tree thunk_id;
tree thunk;
......@@ -348,7 +347,6 @@ make_thunk (function, delta, vcall_index, generate_with_vtable_p)
DECL_INITIAL (thunk) = function;
THUNK_DELTA (thunk) = d;
THUNK_VCALL_OFFSET (thunk) = vcall_offset;
THUNK_GENERATE_WITH_VTABLE_P (thunk) = generate_with_vtable_p;
/* The thunk itself is not a constructor or destructor, even if
the thing it is thunking to is. */
DECL_INTERFACE_KNOWN (thunk) = 1;
......@@ -381,7 +379,6 @@ void
use_thunk (thunk_fndecl, emit_p)
tree thunk_fndecl;
int emit_p;
{
tree fnaddr;
tree function;
......
......@@ -2024,56 +2024,72 @@ look_for_overrides (type, fndecl)
return found;
}
/* Look in TYPE for virtual functions overridden by FNDECL. Check both
TYPE itself and its bases. */
/* Look in TYPE for virtual functions with the same signature as FNDECL.
This differs from get_matching_virtual in that it will only return
a function from TYPE. */
static int
look_for_overrides_r (type, fndecl)
tree
look_for_overrides_here (type, fndecl)
tree type, fndecl;
{
int ix;
if (DECL_DESTRUCTOR_P (fndecl))
if (DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fndecl))
ix = CLASSTYPE_DESTRUCTOR_SLOT;
else
ix = lookup_fnfields_1 (type, DECL_NAME (fndecl));
if (ix >= 0)
{
tree fns = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), ix);
tree dtypes = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
tree thistype = DECL_STATIC_FUNCTION_P (fndecl)
? NULL_TREE : TREE_TYPE (TREE_VALUE (dtypes));
for (; fns; fns = OVL_NEXT (fns))
{
tree fn = OVL_CURRENT (fns);
tree btypes = TYPE_ARG_TYPES (TREE_TYPE (fn));
if (!DECL_VIRTUAL_P (fn))
/* Not a virtual */;
/* Not a virtual. */;
else if (DECL_CONTEXT (fn) != type)
/* Introduced with a using declaration */;
else if (thistype == NULL_TREE)
/* Introduced with a using declaration. */;
else if (DECL_STATIC_FUNCTION_P (fndecl))
{
if (compparms (TREE_CHAIN (btypes), dtypes))
{
/* A static member function cannot match an inherited
virtual member function. */
cp_error_at ("`%#D' cannot be declared", fndecl);
cp_error_at (" since `%#D' declared in base class", fn);
return 1;
}
tree btypes = TYPE_ARG_TYPES (TREE_TYPE (fn));
tree dtypes = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
if (compparms (TREE_CHAIN (btypes), dtypes))
return fn;
}
else if (same_signature_p (fndecl, fn))
{
/* It's definitely virtual, even if not explicitly set. */
DECL_VIRTUAL_P (fndecl) = 1;
check_final_overrider (fndecl, fn);
return fn;
}
}
return NULL_TREE;
}
return 1;
}
/* Look in TYPE for virtual functions overridden by FNDECL. Check both
TYPE itself and its bases. */
static int
look_for_overrides_r (type, fndecl)
tree type, fndecl;
{
tree fn = look_for_overrides_here (type, fndecl);
if (fn)
{
if (DECL_STATIC_FUNCTION_P (fndecl))
{
/* A static member function cannot match an inherited
virtual member function. */
cp_error_at ("`%#D' cannot be declared", fndecl);
cp_error_at (" since `%#D' declared in base class", fn);
}
else
{
/* It's definitely virtual, even if not explicitly set. */
DECL_VIRTUAL_P (fndecl) = 1;
check_final_overrider (fndecl, fn);
}
return 1;
}
/* We failed to find one declared in this class. Look in its bases. */
return look_for_overrides (type, fndecl);
}
......
......@@ -2300,7 +2300,7 @@ emit_associated_thunks (fn)
for (v = BINFO_VIRTUALS (binfo); v; v = TREE_CHAIN (v))
if (BV_FN (v) == fn
&& (!integer_zerop (BV_DELTA (v))
|| BV_VCALL_INDEX (v)))
|| BV_USE_VCALL_INDEX_P (v)))
{
tree thunk;
tree vcall_index;
......@@ -2317,8 +2317,7 @@ emit_associated_thunks (fn)
vfunc_ptr_type_node,
fn),
BV_DELTA (v),
vcall_index,
/*generate_with_vtable_p=*/0);
vcall_index);
use_thunk (thunk, /*emit_p=*/1);
}
}
......
......@@ -26,4 +26,3 @@ C c;
// { dg-final { scan-assembler mangle1.C "\n_ZTT1C:" } }
// { dg-final { scan-assembler mangle1.C "\n_ZTV1A:" } }
// { dg-final { scan-assembler mangle1.C "\n_ZTV1C:" } }
// { dg-final { scan-assembler mangle1.C "\n_ZTv0_n\(12|24\)_N1A1fEv:" } }
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