Please review the second version of a patch to add clang's invalid-noreturn flag to toggle noreturn warnings. This patch keeps the old behaviour of always warning on every noreturn violation, but unlike clang also adds an extra layer of fine tuning by turning invalid-noreturn into a warning with levels, where level 1 warns about noreturn functions that do return, level 2 warns about noreturn functions that explicitly have return statements, and level 3, which is the default to match old behaviour, warns for both instances. Fixed from the first version is a malformed table in invoke.texi.
Tested on Windows with the MinGW 64 Runtime. gcc/doc/ChangeLog: * invoke.texi (-Wno-invalid-noreturn, -Winvalid-noreturn=): Document new options. gcc/ChangeLog: * tree-cfg.cc (pass_warn_function_return::execute): Use new warning option. gcc/c-family/ChangeLog: * c.opt (Winvalid-noreturn, Winvalid-noreturn=): New options. gcc/c/ChangeLog: * c-typeck.cc (c_finish_return): Use new warning option. * gimple-parser.cc (c_finish_gimple_return): Likewise. gcc/cp/ChangeLog: * coroutines.cc (finish_co_return_stmt): Use new warning option. * typeck.cc (check_return_expr): Likewise. gcc/c-family/c.opt | 8 ++++++++ gcc/c/c-typeck.cc | 9 ++++++--- gcc/c/gimple-parser.cc | 9 ++++++--- gcc/cp/coroutines.cc | 11 +++++++---- gcc/cp/typeck.cc | 7 +++++-- gcc/doc/invoke.texi | 27 +++++++++++++++++++++++++++ gcc/tree-cfg.cc | 5 ++++- 7 files changed, 63 insertions(+), 13 deletions(-)
0001-Add-the-invalid-noreturn-warning-to-match-clang.patch
Description: Binary data