Commit 0ca3fb0a by Kaveh R. Ghazi Committed by Kaveh Ghazi

New warning, `missing-noreturn':

        * c-decl.c (warn_missing_noreturn): New global variable.
        (c_decode_option): Check for new flags -W{no-}missing-noreturn.
        (finish_function): Implement missing noreturn warning.
        * c-tree.h (warn_missing_noreturn): Declare extern.
        * invoke.texi: Document new flags.
        * toplev.c (documented_lang_options): Add description.

From-SVN: r23197
parent f1c374cb
Tue Oct 20 10:12:17 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* c-decl.c (warn_missing_noreturn): New global variable.
(c_decode_option): Check for new flags -W{no-}missing-noreturn.
(finish_function): Implement missing noreturn warning.
* c-tree.h (warn_missing_noreturn): Declare extern.
* invoke.texi: Document new flags.
* toplev.c (documented_lang_options): Add description.
Tue Oct 20 22:16:11 1998 Michael Hayes <m.hayes@elec.canterbury.ac.nz> Tue Oct 20 22:16:11 1998 Michael Hayes <m.hayes@elec.canterbury.ac.nz>
* config/c4x/c4x.c (c4x_parallel_process): Disable until BCT * config/c4x/c4x.c (c4x_parallel_process): Disable until BCT
......
...@@ -515,6 +515,10 @@ int warn_cast_qual; ...@@ -515,6 +515,10 @@ int warn_cast_qual;
int warn_bad_function_cast; int warn_bad_function_cast;
/* Warn about functions which might be candidates for attribute noreturn. */
int warn_missing_noreturn;
/* Warn about traditional constructs whose meanings changed in ANSI C. */ /* Warn about traditional constructs whose meanings changed in ANSI C. */
int warn_traditional; int warn_traditional;
...@@ -728,6 +732,10 @@ c_decode_option (argc, argv) ...@@ -728,6 +732,10 @@ c_decode_option (argc, argv)
warn_bad_function_cast = 1; warn_bad_function_cast = 1;
else if (!strcmp (p, "-Wno-bad-function-cast")) else if (!strcmp (p, "-Wno-bad-function-cast"))
warn_bad_function_cast = 0; warn_bad_function_cast = 0;
else if (!strcmp (p, "-Wmissing-noreturn"))
warn_missing_noreturn = 1;
else if (!strcmp (p, "-Wno-missing-noreturn"))
warn_missing_noreturn = 0;
else if (!strcmp (p, "-Wpointer-arith")) else if (!strcmp (p, "-Wpointer-arith"))
warn_pointer_arith = 1; warn_pointer_arith = 1;
else if (!strcmp (p, "-Wno-pointer-arith")) else if (!strcmp (p, "-Wno-pointer-arith"))
...@@ -7192,6 +7200,12 @@ finish_function (nested) ...@@ -7192,6 +7200,12 @@ finish_function (nested)
current_function_returns_null |= can_reach_end; current_function_returns_null |= can_reach_end;
if (warn_missing_noreturn
&& !TREE_THIS_VOLATILE (fndecl)
&& !current_function_returns_null
&& !current_function_returns_value)
warning ("function might be possible candidate for attribute `noreturn'");
if (TREE_THIS_VOLATILE (fndecl) && current_function_returns_null) if (TREE_THIS_VOLATILE (fndecl) && current_function_returns_null)
warning ("`noreturn' function does return"); warning ("`noreturn' function does return");
else if (warn_return_type && can_reach_end else if (warn_return_type && can_reach_end
......
...@@ -469,6 +469,10 @@ extern int warn_cast_qual; ...@@ -469,6 +469,10 @@ extern int warn_cast_qual;
extern int warn_bad_function_cast; extern int warn_bad_function_cast;
/* Warn about functions which might be candidates for attribute noreturn. */
extern int warn_missing_noreturn;
/* Warn about traditional constructs whose meanings changed in ANSI C. */ /* Warn about traditional constructs whose meanings changed in ANSI C. */
extern int warn_traditional; extern int warn_traditional;
......
...@@ -123,7 +123,7 @@ in the following sections. ...@@ -123,7 +123,7 @@ in the following sections.
-Wimplicit-function-declaration -Wimport -Wimplicit-function-declaration -Wimport
-Werror-implicit-function-declaration -Winline -Werror-implicit-function-declaration -Winline
-Wlarger-than-@var{len} -Wlong-long -Wlarger-than-@var{len} -Wlong-long
-Wmain -Wmissing-declarations -Wmain -Wmissing-declarations -Wmissing-noreturn
-Wmissing-prototypes -Wmultichar -Wnested-externs -Wno-import -Wmissing-prototypes -Wmultichar -Wnested-externs -Wno-import
-Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual -Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual
-Wparentheses -Wpointer-arith -Wredundant-decls -Wreorder -Wparentheses -Wpointer-arith -Wredundant-decls -Wreorder
...@@ -1617,6 +1617,13 @@ Do so even if the definition itself provides a prototype. ...@@ -1617,6 +1617,13 @@ Do so even if the definition itself provides a prototype.
Use this option to detect global functions that are not declared in Use this option to detect global functions that are not declared in
header files. header files.
@item -Wmissing-noreturn
Warn about functions which might be candidates for attribute @code{noreturn}.
Note these are only possible candidates, not absolute ones. Care should
be taken to manually verify functions actually do not ever return before
adding the @code{noreturn} attribute, otherwise subtle code generation
bugs could be introduced.
@item -Wredundant-decls @item -Wredundant-decls
Warn if anything is declared more than once in the same scope, even in Warn if anything is declared more than once in the same scope, even in
cases where multiple declaration is valid and changes nothing. cases where multiple declaration is valid and changes nothing.
......
...@@ -974,6 +974,9 @@ documented_lang_options[] = ...@@ -974,6 +974,9 @@ documented_lang_options[] =
{ "-Wbad-function-cast", { "-Wbad-function-cast",
"Warn about casting functions to incompatible types" }, "Warn about casting functions to incompatible types" },
{ "-Wno-bad-function-cast", "" }, { "-Wno-bad-function-cast", "" },
{ "-Wmissing-noreturn",
"Warn about functions which might be candidates for attribute noreturn" },
{ "-Wno-missing-noreturn", "" },
{ "-Wcast-qual", "Warn about casts which discard qualifiers"}, { "-Wcast-qual", "Warn about casts which discard qualifiers"},
{ "-Wno-cast-qual", "" }, { "-Wno-cast-qual", "" },
{ "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"}, { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment