[Bug c++/66590] switch statement: incorrect warning "reaches end of non-void function"
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 10 01:31:50 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66590
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I have a patch.
diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index beef0123b04..43888507b85 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -317,6 +317,15 @@ cxx_block_may_fallthru (const_tree stmt)
return true;
return block_may_fallthru (ELSE_CLAUSE (stmt));
+ case CLEANUP_STMT:
+ /* Just handle the try/finally cases. */
+ if (!CLEANUP_EH_ONLY (stmt))
+ {
+ return (block_may_fallthru (CLEANUP_BODY (stmt))
+ && block_may_fallthru (CLEANUP_EXPR (stmt)));
+ }
+ return true;
+
default:
return c_block_may_fallthru (stmt);
}
More information about the Gcc-bugs
mailing list