aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-04-02 17:09:38 -0400
committerJason Merrill <jason@gcc.gnu.org>2013-04-02 17:09:38 -0400
commit8b00b643987c8b2fe8a2d90253be58ce98a040ce (patch)
tree5d007408f4fe3731f7c28e6619d6e9e116feb7f3 /gcc/cp
parent622849c9371e14fcec645c22b87adedaa16e34e4 (diff)
downloadgcc-8b00b643987c8b2fe8a2d90253be58ce98a040ce.zip
gcc-8b00b643987c8b2fe8a2d90253be58ce98a040ce.tar.gz
gcc-8b00b643987c8b2fe8a2d90253be58ce98a040ce.tar.bz2
re PR c++/34949 (Dead code in empty destructors.)
PR c++/34949 * decl.c (begin_destructor_body): Clobber the object in a cleanup. From-SVN: r197375
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c8
2 files changed, 13 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7b73e03..1b847a9 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-02 Jason Merrill <jason@redhat.com>
+
+ PR c++/34949
+ * decl.c (begin_destructor_body): Clobber the object in a cleanup.
+
2013-04-02 Paolo Carlini <paolo.carlini@oracle.com>
* friend.c (do_friend): Use COMPLETE_OR_OPEN_TYPE_P.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 40200b0..70137f4 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -13555,6 +13555,14 @@ begin_destructor_body (void)
initialize_vtbl_ptrs (current_class_ptr);
finish_compound_stmt (compound_stmt);
+ /* Insert a cleanup to let the back end know that the object is dead
+ when we exit the destructor, either normally or via exception. */
+ tree clobber = build_constructor (current_class_type, NULL);
+ TREE_THIS_VOLATILE (clobber) = true;
+ tree exprstmt = build2 (MODIFY_EXPR, current_class_type,
+ current_class_ref, clobber);
+ finish_decl_cleanup (NULL_TREE, exprstmt);
+
/* And insert cleanups for our bases and members so that they
will be properly destroyed if we throw. */
push_base_cleanups ();