On Wed, Jun 01, 2016 at 01:55:04PM +0200, Marcin Baczyński wrote: > PR c/48116. > > Botstrapped and tested on x86_64-pc-linux-gnu. > > gcc/ChangeLog: > > * c/c-typeck.c (c_finish_return): emit warning about return with a > void expression in a function returning void if warn_return_type.
This is a GNU extension, so I fail to see why you should warn. Furthermore, the way you've done it, you would still warn instead of emit error e.g. with -pedantic-errors on it. Also, c/ prefixes don't belong to ChangeLog entries, gcc/c/ChangeLog is -separate, and after : the first letter should be capitalized. > > gcc/testsuite/ChangeLog: > > * gcc.dg/Wreturn-type3.c: new test. > --- > gcc/c/c-typeck.c | 4 ++++ > gcc/testsuite/gcc.dg/Wreturn-type3.c | 6 ++++++ > 2 files changed, 10 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/Wreturn-type3.c > > diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c > index 1520c20..8ac6cd4 100644 > --- a/gcc/c/c-typeck.c > +++ b/gcc/c/c-typeck.c > @@ -9700,6 +9700,10 @@ c_finish_return (location_t loc, tree retval, tree > origtype) > warned_here = pedwarn > (xloc, 0, > "%<return%> with a value, in function returning void"); > + else if (warn_return_type) > + warned_here = warning_at > + (loc, OPT_Wreturn_type, > + "%<return%> with expression, in function returning void"); > else > warned_here = pedwarn > (xloc, OPT_Wpedantic, "ISO C forbids " > diff --git a/gcc/testsuite/gcc.dg/Wreturn-type3.c > b/gcc/testsuite/gcc.dg/Wreturn-type3.c > new file mode 100644 > index 0000000..e83c94b > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/Wreturn-type3.c > @@ -0,0 +1,6 @@ > +/* PR c/48116 */ > +/* { dg-do compile } */ > +/* { dg-options "-Wreturn-type" } */ > + > +void a() {} > +void b() { return a(); } /* { dg-warning "return" "returning void" } */ > -- > 2.8.3 Jakub