Commit f72ab53b by Mark Mitchell Committed by Mark Mitchell

class.c (add_implicitly_declared_members): Put implicitly declared functions at…

class.c (add_implicitly_declared_members): Put implicitly declared functions at the end of TYPE_METHODs when...

	* class.c (add_implicitly_declared_members): Put implicitly
	declared functions at the end of TYPE_METHODs when -fabi-version
	is at least 2.

	* testsuite/g++.dg/abi/dtor1.C: New test.
	* testsuite/g++.dg/abi/dtor2.C: Likewise.

From-SVN: r58908
parent 0977774b
2002-11-07 Mark Mitchell <mark@codesourcery.com>
* class.c (add_implicitly_declared_members): Put implicitly
declared functions at the end of TYPE_METHODs when -fabi-version
is at least 2.
2002-11-05 Geoffrey Keating <geoffk@apple.com>
* decl2.c (finish_file): Correct spelling.
......
......@@ -125,7 +125,7 @@ static void finish_struct_methods PARAMS ((tree));
static void maybe_warn_about_overly_private_class PARAMS ((tree));
static int field_decl_cmp PARAMS ((const tree *, const tree *));
static int method_name_cmp PARAMS ((const tree *, const tree *));
static tree add_implicitly_declared_members PARAMS ((tree, int, int, int));
static void add_implicitly_declared_members PARAMS ((tree, int, int, int));
static tree fixed_type_or_null PARAMS ((tree, int *, int *));
static tree resolve_address_of_overloaded_function PARAMS ((tree, tree, int,
int, int, tree));
......@@ -2742,7 +2742,7 @@ maybe_add_class_template_decl_list (type, t, friend_p)
reference, respectively. If a virtual destructor is created, its
DECL is returned; otherwise the return value is NULL_TREE. */
static tree
static void
add_implicitly_declared_members (t, cant_have_default_ctor,
cant_have_const_cctor,
cant_have_const_assignment)
......@@ -2817,12 +2817,23 @@ add_implicitly_declared_members (t, cant_have_default_ctor,
add_method (t, *f, /*error_p=*/0);
maybe_add_class_template_decl_list (current_class_type, *f, /*friend_p=*/0);
}
*f = TYPE_METHODS (t);
TYPE_METHODS (t) = implicit_fns;
if (abi_version_at_least (2))
/* G++ 3.2 put the implicit destructor at the *beginning* of the
list, which cause the destructor to be emitted in an incorrect
location in the vtable. */
TYPE_METHODS (t) = chainon (TYPE_METHODS (t), implicit_fns);
else
{
if (warn_abi && virtual_dtor)
warning ("vtable layout for class `%T' may not be ABI-compliant "
"and may change in a future version of GCC due to implicit "
"virtual destructor",
t);
*f = TYPE_METHODS (t);
TYPE_METHODS (t) = implicit_fns;
}
--adding_implicit_members;
return virtual_dtor;
}
/* Subroutine of finish_struct_1. Recursively count the number of fields
......
2002-11-07 Mark Mitchell <mark@codesourcery.com>
* testsuite/g++.dg/abi/dtor1.C: New test.
* testsuite/g++.dg/abi/dtor2.C: Likewise.
2002-11-05 Geoffrey Keating <geoffk@apple.com>
* g++.old-deja/g++.eh/badalloc1.C: XFAIL excess errors test on
......
// { dg-do compile { target i?86-*-* } }
// { dg-options "-fabi-version=0" }
struct A {
virtual void a ();
};
struct B {
virtual ~B ();
};
struct C : public A, public B {
virtual void c ();
};
struct D : virtual public C {
virtual void d ();
};
void D::d () {}
// { dg-final { scan-assembler _ZTv0_n20_N1DD1Ev } }
// { dg-do compile }
// { dg-options "-Wabi" }
struct A {
virtual void a ();
};
struct B {
virtual ~B ();
};
struct C : public A, public B { // { dg-warning "virtual" }
virtual void c ();
};
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