This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Your patch for PR 9862
- From: Steven Bosscher <s dot bosscher at student dot tudelft dot nl>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 06 Sep 2003 15:30:24 +0200
- Subject: Re: Your patch for PR 9862
- References: <1062744783.11445.15.camel@doubledemon.codesourcery.com>
Op vr 05-09-2003, om 08:53 schreef Mark Mitchell:
> This patch is fine; please check it in on branch and mainline and close
> the PR.
>
> Thanks,
The two month old patch didn't apply anymore to the trunk, of course.
So I commited this. I'll commit the original patch to the branch.
Bootstrapped and tested on i686-pc-linux-gnu.
Gr.
Steven
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.
/* 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;
}
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.442
diff -c -3 -p -r1.442 c-decl.c
*** c-decl.c 4 Sep 2003 03:17:45 -0000 1.442
--- c-decl.c 6 Sep 2003 11:51:42 -0000
*************** finish_function ()
*** 6129,6134 ****
--- 6129,6141 ----
&& DECL_INLINE (fndecl))
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
DECL_SAVED_INSNS, and we'll restore it in tree_rest_of_compilation. */
cfun = NULL;
*************** c_expand_body_1 (tree fndecl, int nested
*** 6177,6189 ****
}
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))
{
--- 6184,6189 ----