re PR c++/51620 ([c++0x] [4.6/4.7 Regression] ICE with private destructor)

PR c++/51620
	* class.c (build_vtbl_initializer): Use __cxa_deleted_virtual.

From-SVN: r183155
This commit is contained in:
Jason Merrill 2012-01-13 10:49:29 -05:00 committed by Jason Merrill
parent 8395e28bbf
commit 4ce7d589fe
5 changed files with 44 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2012-01-13 Jason Merrill <jason@redhat.com>
PR c++/51620
* class.c (build_vtbl_initializer): Use __cxa_deleted_virtual.
2012-01-12 Jason Merrill <jason@redhat.com>
PR c++/51714

View File

@ -8352,6 +8352,18 @@ build_vtbl_initializer (tree binfo,
init = abort_fndecl_addr;
}
}
/* Likewise for deleted virtuals. */
else if (DECL_DELETED_FN (fn_original))
{
fn = get_identifier ("__cxa_deleted_virtual");
if (!get_global_value_if_present (fn, &fn))
fn = push_library_fn (fn, (build_function_type_list
(void_type_node, NULL_TREE)),
NULL_TREE);
if (!TARGET_VTABLE_USES_DESCRIPTORS)
init = fold_convert (vfunc_ptr_type_node,
build_fold_addr_expr (fn));
}
else
{
if (!integer_zerop (delta) || vcall_index)

View File

@ -1,3 +1,9 @@
2012-01-13 Jason Merrill <jason@redhat.com>
PR c++/51620
* g++.dg/cpp0x/defaulted34.C: New.
* g++.dg/template/virtual3.C: New.
2012-01-13 Richard Guenther <rguenther@suse.de>
PR middle-end/8081

View File

@ -0,0 +1,10 @@
// { dg-options -std=c++0x }
// { dg-final { scan-assembler "__cxa_deleted_virtual" } }
struct A
{
virtual void f();
virtual ~A() = delete;
};
void A::f() {}

View File

@ -0,0 +1,11 @@
// PR c++/51620
template<int> class A
{
virtual ~A(); // { dg-error "non-deleted|private" }
};
struct B : A<0>, A<1> // { dg-error "deleted|context" }
{
B() {} // { dg-error "context" }
};