diff options
author | Jason Merrill <jason@redhat.com> | 2015-02-12 15:28:41 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2015-02-12 15:28:41 -0500 |
commit | f522930c8fe1554c4af6f4d87b6529be1b716ffc (patch) | |
tree | 2d3f895a3da2356f70340af326c8229b80d19433 /gcc/cp | |
parent | bc81eb3f77b27d46e25c218cfd9f32c89cc36b3c (diff) | |
download | gcc-f522930c8fe1554c4af6f4d87b6529be1b716ffc.zip gcc-f522930c8fe1554c4af6f4d87b6529be1b716ffc.tar.gz gcc-f522930c8fe1554c4af6f4d87b6529be1b716ffc.tar.bz2 |
common.opt (-flifetime-dse): New.
gcc/
* common.opt (-flifetime-dse): New.
gcc/cp/
* decl.c (begin_destructor_body): Condition clobber on
-flifetime-dse.
From-SVN: r220657
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/decl.c | 22 |
2 files changed, 18 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e460c55..4f75646 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-02-12 Jason Merrill <jason@redhat.com> + + * decl.c (begin_destructor_body): Condition clobber on + -flifetime-dse. + 2015-02-12 Andrea Azzarone <azzaronea@gmail.com> PR c++/64959 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 50b0624..810acd5 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -13936,15 +13936,19 @@ 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 btype = CLASSTYPE_AS_BASE (current_class_type); - tree clobber = build_constructor (btype, NULL); - TREE_THIS_VOLATILE (clobber) = true; - tree bref = build_nop (build_reference_type (btype), current_class_ptr); - bref = convert_from_reference (bref); - tree exprstmt = build2 (MODIFY_EXPR, btype, bref, clobber); - finish_decl_cleanup (NULL_TREE, exprstmt); + if (flag_lifetime_dse) + { + /* 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 btype = CLASSTYPE_AS_BASE (current_class_type); + tree clobber = build_constructor (btype, NULL); + TREE_THIS_VOLATILE (clobber) = true; + tree bref = build_nop (build_reference_type (btype), + current_class_ptr); + bref = convert_from_reference (bref); + tree exprstmt = build2 (MODIFY_EXPR, btype, bref, 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. */ |