summaryrefslogtreecommitdiff
path: root/gcc/cp/search.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2014-03-14 19:06:54 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2014-03-14 19:06:54 +0000
commit27ea311dce42a5df5ec4772cdb0e2b365b891016 (patch)
treeb0eec92fff85e3e1e0053ea49ba468b4ea9a3644 /gcc/cp/search.c
parentb7985449a3309ab7d96a7fccd4bb72c13897fb46 (diff)
downloadgcc-27ea311dce42a5df5ec4772cdb0e2b365b891016.tar.gz
PR c++/58678
* search.c (dfs_get_pure_virtuals): Treat the destructor of an abstract class as pure. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@208573 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/search.c')
-rw-r--r--gcc/cp/search.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index c3eed90f6c3..66c6df5215e 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -2096,6 +2096,22 @@ dfs_get_pure_virtuals (tree binfo, void *data)
if (DECL_PURE_VIRTUAL_P (BV_FN (virtuals)))
vec_safe_push (CLASSTYPE_PURE_VIRTUALS (type), BV_FN (virtuals));
}
+ /* Treat a virtual destructor in an abstract class as pure even if it
+ isn't declared as pure; there is no way it would be called through the
+ vtable except during construction, which causes undefined behavior. */
+ if (binfo == TYPE_BINFO (type)
+ && CLASSTYPE_PURE_VIRTUALS (type)
+ && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type))
+ {
+ tree dtor = CLASSTYPE_DESTRUCTORS (type);
+ if (DECL_VIRTUAL_P (dtor) && !DECL_PURE_VIRTUAL_P (dtor))
+ {
+ tree clone;
+ DECL_PURE_VIRTUAL_P (dtor) = true;
+ FOR_EACH_CLONE (clone, dtor)
+ DECL_PURE_VIRTUAL_P (clone) = true;
+ }
+ }
return NULL_TREE;
}