diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0f91517b38b..a25d814af35 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2007-02-13 Manuel Lopez-Ibanez + + PR c/29521 + * c-typeck.c (c_finish_return): Improve warning message. + 2007-02-12 Manuel Lopez-Ibanez * alias.c (find_symbolic_term): Delete unused function. diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 013a206015f..c807a7edfe9 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -6935,8 +6935,10 @@ c_finish_return (tree retval) else if (valtype == 0 || TREE_CODE (valtype) == VOID_TYPE) { current_function_returns_null = 1; - if (pedantic || TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE) + if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE) pedwarn ("% with a value, in function returning void"); + else if (pedantic) + pedwarn ("ISO C forbids % with expression, in function returning void"); } else { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 12555562b89..7245d64e25d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-02-13 Manuel Lopez-Ibanez + + PR c/29521 + * gcc.dg/c90-return-1.c: Update output. + * gcc.dg/c99-return-1.c: Likewise. + 2007-02-13 Paul Thomas PR fortran/30554 diff --git a/gcc/testsuite/gcc.dg/pr29521-2.c b/gcc/testsuite/gcc.dg/pr29521-2.c new file mode 100644 index 00000000000..734652c90ca --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr29521-2.c @@ -0,0 +1,15 @@ +/* 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" } */ +} diff --git a/gcc/testsuite/gcc.dg/pr29521.c b/gcc/testsuite/gcc.dg/pr29521.c new file mode 100644 index 00000000000..b6fb535fab7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr29521.c @@ -0,0 +1,15 @@ +/* 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" } */ +}