re PR c/29521 (Confusing warning for return with expression in function returning void)

2007-02-13  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	PR c/29521
	* c-typeck.c (c_finish_return): Improve warning message.

testsuite/
	* gcc.dg/c90-return-1.c: Update output.
	* gcc.dg/c99-return-1.c: Likewise.

From-SVN: r121876
parent bad333ff
2007-02-13 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c/29521
* c-typeck.c (c_finish_return): Improve warning message.
2007-02-12 Manuel Lopez-Ibanez <manu@gcc.gnu.org> 2007-02-12 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
* alias.c (find_symbolic_term): Delete unused function. * alias.c (find_symbolic_term): Delete unused function.
......
...@@ -6935,8 +6935,10 @@ c_finish_return (tree retval) ...@@ -6935,8 +6935,10 @@ c_finish_return (tree retval)
else if (valtype == 0 || TREE_CODE (valtype) == VOID_TYPE) else if (valtype == 0 || TREE_CODE (valtype) == VOID_TYPE)
{ {
current_function_returns_null = 1; current_function_returns_null = 1;
if (pedantic || TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE) if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
pedwarn ("%<return%> with a value, in function returning void"); pedwarn ("%<return%> with a value, in function returning void");
else if (pedantic)
pedwarn ("ISO C forbids %<return%> with expression, in function returning void");
} }
else else
{ {
......
2007-02-13 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c/29521
* gcc.dg/c90-return-1.c: Update output.
* gcc.dg/c99-return-1.c: Likewise.
2007-02-13 Paul Thomas <pault@gcc.gnu.org> 2007-02-13 Paul Thomas <pault@gcc.gnu.org>
PR fortran/30554 PR fortran/30554
/* PR 29521 : warning for return with expression in function returning void */
/* { dg-do compile } */
/* { dg-options "-pedantic-errors" } */
void func (void) { }
void func2 (void)
{
return func (); /* { dg-error "ISO C forbids 'return' with expression" } */
}
void func3 (void)
{
return 1; /* { dg-error "'return' with a value" } */
}
/* PR 29521 : warning for return with expression in function returning void */
/* { dg-do compile } */
/* { dg-options "" } */
void func (void) { }
void func2 (void)
{
return func ();
}
void func3 (void)
{
return 1; /* { dg-warning "'return' with a value" } */
}
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