From: steven Date: Sat, 6 Sep 2003 13:34:00 +0000 (+0000) Subject: PR c/9862 X-Git-Tag: upstream/4.9.2~76883 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1bfe282341a49c8d081475780c85d712ead89bcd;p=platform%2Fupstream%2Flinaro-gcc.git 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71134 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0d57ffd..8d7e360 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2003-09-06 Steven Bosscher + + PR c/9862 + * c-decl.c (c_expand_body_1): Move return warning from here... + (finish_function): ...to here. + 2003-09-05 Geoffrey Keating * config/rs6000/darwin.h (PREFERRED_RELOAD_CLASS): Always return diff --git a/gcc/c-decl.c b/gcc/c-decl.c index f16fe7c..f4896f3 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -6129,6 +6129,13 @@ finish_function () && 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; @@ -6178,13 +6185,6 @@ c_expand_body_1 (tree fndecl, int nested_p) 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 (targetm.have_ctors_dtors) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d28f2d1..65f499d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2003-09-06 Steven Bosscher + + PR c/9862 + * gcc.dg/20030906-1.c: New test. + * gcc.dg/20030906-2.c: Likewise. + 2003-09-06 Nathan Sidwell PR c++/12167 diff --git a/gcc/testsuite/gcc.dg/20030906-1.c b/gcc/testsuite/gcc.dg/20030906-1.c new file mode 100644 index 0000000..57d80f0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20030906-1.c @@ -0,0 +1,21 @@ +/* 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" } */ diff --git a/gcc/testsuite/gcc.dg/20030906-2.c b/gcc/testsuite/gcc.dg/20030906-2.c new file mode 100644 index 0000000..8f3d378 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20030906-2.c @@ -0,0 +1,21 @@ +/* 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; +}