https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66590
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <pins...@gcc.gnu.org>: https://gcc.gnu.org/g:971df602e0a798fe9c805c3105f4ac80d638a12b commit r12-3145-g971df602e0a798fe9c805c3105f4ac80d638a12b Author: Andrew Pinski <apin...@marvell.com> Date: Mon Aug 9 18:33:17 2021 -0700 Fix PR c++/66590: incorrect warning "reaches end of non-void function" for switch So the problem here is there is code in the C++ front-end not to add a break statement (to the IR) if the previous block does not fall through. The problem is the code which does the check to see if the block may fallthrough does not check a CLEANUP_STMT; it assumes it is always fall through. Anyways this adds the code for the case of a CLEANUP_STMT that is only for !CLEANUP_EH_ONLY (the try/finally case). OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/cp/ChangeLog: PR c++/66590 * cp-objcp-common.c (cxx_block_may_fallthru): Handle CLEANUP_STMT for the case which will be try/finally. gcc/testsuite/ChangeLog: PR c++/66590 * g++.dg/warn/Wreturn-5.C: New test.