From 8ae90330f06696b7ae591f9391651223e09f749a Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 29 Jan 2014 12:13:01 -0500 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/optimize.c | 2 +- gcc/testsuite/g++.dg/warn/Wreturn-type-10.C | 13 +++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/warn/Wreturn-type-10.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f2ff37abb83..594861b34b9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2014-01-29 Jason Merrill + 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 1b3f10a11c5..b089432a305 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 00000000000..2043b6cf21a --- /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() {} -- 2.11.4.GIT