Commit 03845b47 by Steven Bosscher

re PR c/9862 (spurious warnings with -W -finline-functions)

	PR c/9862
	* c-decl.c (c_expand_body_1): Move return warning from here...
	(finish_function): ...to here.

	* gcc.dg/20030906-1.c: New test.
	* gcc.dg/20030906-2.c: Likewise.

From-SVN: r71134
parent b92bc2a0
2003-09-06 Steven Bosscher <steven@gcc.gnu.org>
PR c/9862
* c-decl.c (c_expand_body_1): Move return warning from here...
(finish_function): ...to here.
2003-09-05 Geoffrey Keating <geoffk@apple.com> 2003-09-05 Geoffrey Keating <geoffk@apple.com>
* config/rs6000/darwin.h (PREFERRED_RELOAD_CLASS): Always return * config/rs6000/darwin.h (PREFERRED_RELOAD_CLASS): Always return
......
...@@ -6129,6 +6129,13 @@ finish_function () ...@@ -6129,6 +6129,13 @@ finish_function ()
&& DECL_INLINE (fndecl)) && DECL_INLINE (fndecl))
warning ("no return statement in function returning non-void"); warning ("no return statement in function returning non-void");
/* With just -Wextra, complain only if function returns both with
and without a value. */
if (extra_warnings
&& current_function_returns_value
&& current_function_returns_null)
warning ("this function may return with or without a value");
/* We're leaving the context of this function, so zap cfun. It's still in /* We're leaving the context of this function, so zap cfun. It's still in
DECL_SAVED_INSNS, and we'll restore it in tree_rest_of_compilation. */ DECL_SAVED_INSNS, and we'll restore it in tree_rest_of_compilation. */
cfun = NULL; cfun = NULL;
...@@ -6178,13 +6185,6 @@ c_expand_body_1 (tree fndecl, int nested_p) ...@@ -6178,13 +6185,6 @@ c_expand_body_1 (tree fndecl, int nested_p)
tree_rest_of_compilation (fndecl); tree_rest_of_compilation (fndecl);
/* With just -Wextra, complain only if function returns both with
and without a value. */
if (extra_warnings
&& current_function_returns_value
&& current_function_returns_null)
warning ("this function may return with or without a value");
if (DECL_STATIC_CONSTRUCTOR (fndecl)) if (DECL_STATIC_CONSTRUCTOR (fndecl))
{ {
if (targetm.have_ctors_dtors) if (targetm.have_ctors_dtors)
......
2003-09-06 Steven Bosscher <steven@gcc.gnu.org>
PR c/9862
* gcc.dg/20030906-1.c: New test.
* gcc.dg/20030906-2.c: Likewise.
2003-09-06 Nathan Sidwell <nathan@codesourcery.com> 2003-09-06 Nathan Sidwell <nathan@codesourcery.com>
PR c++/12167 PR c++/12167
......
/* Bug 9862 -- Spurious warnings with -finline-functions.
Copyright (C) 2003 Free Software Foundation Inc. */
/* { dg-do compile } */
/* { dg-options "-O -finline-functions -Wextra" } */
extern int i;
extern int foo (void);
extern int bar (void);
int foo (void)
{
if( i ) return 0;
else return 1;
} /* { dg-bogus "may return with or without a value" } */
int bar (void)
{
if( i ) return;
else return 1;
} /* { dg-warning "may return with or without a value" } */
/* Bug 9862 -- Spurious warnings with -finline-functions.
Copyright (C) 2003 Free Software Foundation Inc. */
/* { dg-do compile } */
/* { dg-options "-O -finline-functions -Wextra" } */
extern int i;
extern int foo (void);
extern int bar (void);
int foo (void)
{
if( i ) return;
else return 1;
} /* { dg-warning "may return with or without a value" } */
int bar (void)
{
if( i ) return 0;
else return 1;
}
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