Commit 21c7361e by Andreas Jaeger

c-decl.c (c_decode_option): Remove support of -Wmissing-noreturn.

	* c-decl.c (c_decode_option): Remove support of
	-Wmissing-noreturn.

	* toplev.c (documented_lang_options): Remove -Wmissing-noreturn.
	(W_options): Add -Wmissing-noreturn here.

	* flow.c: Define lang_missing_noreturn_ok_p.
	(check_function_return_warnings): Use it.

	* c-common.h: Declare lang_missing_noreturn_ok_p.

	* c-lang.c (c_missing_noreturn_ok_p): New function.
	(lang_init): Set lang_missing_noreturn_ok_p.

	* invoke.texi (Warning Options): Document this.

From-SVN: r38612
parent 42ded877
2001-01-02 Andreas Jaeger <aj@suse.de>
* c-decl.c (c_decode_option): Remove support of
-Wmissing-noreturn.
* toplev.c (documented_lang_options): Remove -Wmissing-noreturn.
(W_options): Add -Wmissing-noreturn here.
* flow.c: Define lang_missing_noreturn_ok_p.
(check_function_return_warnings): Use it.
* c-common.h: Declare lang_missing_noreturn_ok_p.
* c-lang.c (c_missing_noreturn_ok_p): New function.
(lang_init): Set lang_missing_noreturn_ok_p.
* invoke.texi (Warning Options): Document this.
2000-12-27 Phil Edwards <pme@sources.redhat.com>
* extend.texi (C++ Extensions): New node for C++ attributes;
......
/* Definitions for c-common.c.
Copyright (C) 1987, 1993, 1994, 1995, 1997, 1998,
1999, 2000 Free Software Foundation, Inc.
1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
......@@ -294,6 +294,11 @@ extern void (*lang_expand_stmt) PARAMS ((tree));
extern void (*lang_expand_decl_stmt) PARAMS ((tree));
extern void (*lang_expand_function_end) PARAMS ((void));
/* Callback that determines if it's ok for a function to have no
noreturn attribute. */
extern int (*lang_missing_noreturn_ok_p) PARAMS ((tree));
/* The type of a function that walks over tree structure. */
typedef tree (*walk_tree_fn) PARAMS ((tree *,
......@@ -807,5 +812,3 @@ struct c_fileinfo *get_fileinfo PARAMS ((const char *));
extern void dump_time_statistics PARAMS ((void));
#endif
/* Process declarations and variables for C compiler.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
Free Software Foundation, Inc.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001 Free Software Foundation, Inc.
This file is part of GNU CC.
......@@ -665,8 +665,6 @@ c_decode_option (argc, argv)
warn_bad_function_cast = 1;
else if (!strcmp (p, "-Wno-bad-function-cast"))
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, "-Wmissing-format-attribute"))
......
/* Language-specific hook definitions for C front end.
Copyright (C) 1991, 1995, 1997, 1998,
1999, 2000 Free Software Foundation, Inc.
1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
......@@ -37,6 +37,7 @@ Boston, MA 02111-1307, USA. */
#include "cpplib.h"
static int c_tree_printer PARAMS ((output_buffer *));
static int c_missing_noreturn_ok_p PARAMS ((tree));
/* Each of the functions defined here
is an alternative to a function in objc-actions.c. */
......@@ -81,6 +82,7 @@ lang_init ()
lang_safe_from_p = &c_safe_from_p;
lang_printer = &c_tree_printer;
lang_expand_decl_stmt = &c_expand_decl_stmt;
lang_missing_noreturn_ok_p = &c_missing_noreturn_ok_p;
c_parse_init ();
}
......@@ -294,3 +296,12 @@ c_tree_printer (buffer)
return 0;
}
}
static int
c_missing_noreturn_ok_p (decl)
tree decl;
{
/* A missing noreturn is not ok for freestanding implementations and
ok for the `main' function in hosted implementations. */
return flag_hosted && MAIN_NAME_P (DECL_ASSEMBLER_NAME (decl));
}
/* Data flow analysis for GNU compiler.
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000 Free Software Foundation, Inc.
1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
......@@ -251,6 +251,10 @@ regset regs_live_at_setjmp;
are another pair, etc. */
rtx regs_may_share;
/* Callback that determines if it's ok for a function to have no
noreturn attribute. */
int (*lang_missing_noreturn_ok_p) PARAMS ((tree));
/* Set of registers that may be eliminable. These are handled specially
in updating regs_ever_live. */
......@@ -530,7 +534,9 @@ check_function_return_warnings ()
{
if (warn_missing_noreturn
&& !TREE_THIS_VOLATILE (cfun->decl)
&& EXIT_BLOCK_PTR->pred == NULL)
&& EXIT_BLOCK_PTR->pred == NULL
&& (lang_missing_noreturn_ok_p
&& !lang_missing_noreturn_ok_p (cfun->decl)))
warning ("function might be possible candidate for attribute `noreturn'");
/* If we have a path to EXIT, then we do return. */
......
......@@ -5,7 +5,7 @@
@ignore
@c man begin COPYRIGHT
Copyright @copyright{} 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
1998, 1999, 2000 Free Software Foundation, Inc.
1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
......@@ -2170,7 +2170,8 @@ 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.
bugs could be introduced. You will not get a warning for @code{main} in
hosted C environments.
@item -Wmissing-format-attribute
If @samp{-Wformat} is enabled, also warn about functions which might be
......
/* Top level of GNU C compiler
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000 Free Software Foundation, Inc.
1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC.
......@@ -1210,8 +1210,6 @@ documented_lang_options[] =
{ "-Wbad-function-cast",
"Warn about casting functions to incompatible types" },
{ "-Wno-bad-function-cast", "" },
{ "-Wmissing-noreturn",
"Warn about functions which might be candidates for attribute noreturn" },
{ "-Wno-missing-noreturn", "" },
{ "-Wmissing-format-attribute",
"Warn about functions which might be candidates for format attributes" },
......@@ -1461,7 +1459,9 @@ lang_independent_options W_options[] =
{"padded", &warn_padded, 1,
"Warn when padding is required to align struct members"},
{"disabled-optimization", &warn_disabled_optimization, 1,
"Warn when an optimization pass is disabled"}
"Warn when an optimization pass is disabled"},
{"missing-noreturn", &warn_missing_noreturn, 1,
"Warn about functions which might be candidates for attribute noreturn"}
};
/* Output files for assembler code (real compiler output)
......
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