2016-06-01 19:03 GMT+02:00 Martin Sebor <mse...@gmail.com>: > > On 06/01/2016 10:39 AM, Jakub Jelinek wrote: >> >> On Wed, Jun 01, 2016 at 02:44:22PM +0200, Marcin Baczyński wrote: >>> >>> On 1 Jun 2016 14:07, "Jakub Jelinek" <ja...@redhat.com> wrote: >>>> >>>> >>>> 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. >>> >>> >>> The bug is on the easyhacks list, I thought it would be a good place to >>> start digging into the GCC code base. >> >> >> First of all, I'm not the C FE maintainer, so these are just IMHO comments, >> the maintainers might have different opinion. >> >>> Do you have any suggestions for better things to start with? > > > Since you've done a lot of work on this bug already I think it > would be worthwhile to see it through to completion. Given that, > as Jakub mentioned, the absence of the warning in permissive mode > (i.e. without -Wpedantic) is a GCC extension to C, it would be > helpful to mention it in the manual (doing so would resolve the > submitter's complaint that the -Wreturn-type option doesn't work > as documented). With the documentation patch accepted, the bug > can then be closed as resolved/fixed and taken off the easy hacks > list. > > > Martin
So here's my shot at fixing this in the documentation. Does that look okay? gcc/ChangeLog: PR c/48116. * doc/invoke.texi (-Wreturn-type): Mention not warning on return with a void expression in a void function. --- gcc/doc/invoke.texi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index ce162a0..72e3f2d 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -4055,8 +4055,12 @@ Warn whenever a function is defined with a return type that defaults to @code{int}. Also warn about any @code{return} statement with no return value in a function whose return type is not @code{void} (falling off the end of the function body is considered returning -without a value), and about a @code{return} statement with an -expression in a function whose return type is @code{void}. +without a value). + +For a @code{return} statement with an expression in a function whose +return type is @code{void}, warn unless the expression type is also +@code{void}. As a GNU extension, the latter case is accepted without a +warning unless @option{-Wpedantic} is used. For C++, a function without return type always produces a diagnostic message, even when @option{-Wno-return-type} is specified. The only -- 2.8.3