diff options
author | Jason Merrill <jason@redhat.com> | 2014-01-29 12:13:01 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2014-01-29 12:13:01 -0500 |
commit | 8ae90330f06696b7ae591f9391651223e09f749a (patch) | |
tree | e0f98d2c3992a14e7100fdfc1fcc2f24d5e2550d | |
parent | 4f7c83caa328ea011365f786c19953af274bb0c8 (diff) | |
download | gcc-8ae90330f06696b7ae591f9391651223e09f749a.zip gcc-8ae90330f06696b7ae591f9391651223e09f749a.tar.gz gcc-8ae90330f06696b7ae591f9391651223e09f749a.tar.bz2 |
re PR c++/59916 (constructors and destructors can cause "control reaches end of non-void function" warnings with -Os)
PR c++/59916
* optimize.c (maybe_thunk_body): Build a RETURN_EXPR for
cdtor_returns_this case.
From-SVN: r207271
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/optimize.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wreturn-type-10.C | 13 |
3 files changed, 18 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f2ff37a..594861b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2014-01-29 Jason Merrill <jason@redhat.com> + PR c++/59916 + * optimize.c (maybe_thunk_body): Build a RETURN_EXPR for + cdtor_returns_this case. + PR c++/59315 * decl.c (cxx_maybe_build_cleanup): Call mark_used. diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 1b3f10a..b089432 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -405,8 +405,8 @@ maybe_thunk_body (tree fn, bool force) clone_result = DECL_RESULT (clone); modify = build2 (MODIFY_EXPR, TREE_TYPE (clone_result), clone_result, call); + modify = build1 (RETURN_EXPR, void_type_node, modify); add_stmt (modify); - BLOCK_VARS (block) = clone_result; } else { diff --git a/gcc/testsuite/g++.dg/warn/Wreturn-type-10.C b/gcc/testsuite/g++.dg/warn/Wreturn-type-10.C new file mode 100644 index 0000000..2043b6c --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wreturn-type-10.C @@ -0,0 +1,13 @@ +// PR c++/59916 +// { dg-options "-Os -Wreturn-type" } + +class A {}; + +struct B : virtual public A +{ + B(); + virtual ~B(); +}; + +B::B() {} +B::~B() {} |