Message ID | CALvMQwTU0eNPP+=E+jo4uE4Znq+5_GE0N=aTBY7imZj5Lu=QEg@mail.gmail.com |
---|---|
State | New |
Headers | show |
> So here's my shot at fixing this in the documentation. Does that look okay? > It looks good to me. Just one minor point below. > @@ -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. I would suggest to add that this only applies to C. Otherwise it's valid C++ so G++ accepts it without a pedantic warning. As a disclaimer, someone else endowed with those special powers will need to approve your final patch. If you don't get a timely approval please ping the patch weekly. Martin
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