This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: bug report...
- To: Joe Buck <jbuck at Synopsys dot COM>
- Subject: Re: bug report...
- From: Branko Cibej <branko dot cibej at hermes dot si>
- Date: Wed, 10 Jun 1998 08:53:00 +0200
- Cc: bryan at terran dot org, oliva at dcc dot unicamp dot br, egcs at cygnus dot com, egcs-patches at cygnus dot com
- Organization: HERMES SoftLab
- References: <199806091651.JAA02677@atrus.synopsys.com>
Joe Buck wrote:
> > Should this really be a pedantic warning?
>
> It should not be a warning at all, if the value that is returned is itself
> void. Yet another thing that hasn't been implemented. If anyone wants
> to send a patch, this one should be easy to fix.
Well, here it is. I've also attached a better test case.
1998-06-10 Branko Cibej <branko.cibej@hermes.si>
* typeck.c (c_expand_return): Don't warn about void expressions on
return statements in functions returning void.
*** egcs-19980608/gcc/cp/typeck.c Wed Jun 10 07:57:29 1998
--- egcs-source/gcc/cp/typeck.c Wed Jun 10 08:11:37 1998
*************** c_expand_return (retval)
*** 7271,7278 ****
if (valtype == NULL_TREE || TREE_CODE (valtype) == VOID_TYPE)
{
current_function_returns_null = 1;
! if ((pedantic && ! DECL_ARTIFICIAL (current_function_decl))
! || TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
pedwarn ("`return' with a value, in function returning void");
expand_return (retval);
return;
--- 7271,7277 ----
if (valtype == NULL_TREE || TREE_CODE (valtype) == VOID_TYPE)
{
current_function_returns_null = 1;
! if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
pedwarn ("`return' with a value, in function returning void");
expand_return (retval);
return;
------void_ret.cc begins------
char charfn () { return 'A'; }
void voidfn () { }
void void_ret_voidfn () { return voidfn(); }
void void_ret_voidconst () { return static_cast<void>('A'); }
void void_ret_charfn () { return charfn(); }
void void_ret_charconst () { return 'A'; }
template <typename T>
T ret_Tfn (T (*fn) ()) { return fn(); }
int main ()
{
ret_Tfn (voidfn);
ret_Tfn (charfn);
}
------void_ret.cc ends------
$ /home/brane/eval/egcs/bin/c++ -ansi -pedantic -Wall void_ret.cc
void_ret.cc: In function `void void_ret_charfn()':
void_ret.cc:8: warning: `return' with a value, in function returning void
void_ret.cc: In function `void void_ret_charconst()':
void_ret.cc:9: warning: `return' with a value, in function returning void
--
Branko Cibej <branko.cibej@hermes.si>
HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia
phone: (++386 61) 186 53 49 fax: (++386 61) 186 52 70