On Thu, 5 Jun 2014, Sylvestre Ledru wrote:
> > Some of those patches appear to be addressing cases where control appears
> > to reach the end of a function returning non-void, as opposed to cases
> > where the return type defaults to int.
> Do you have an example of the patches you are talking about?
In 0004-Update-gcc-tests-with-warning-return-type-enabled-by.patch the
very first change is adding such a "return 0;" (as are lots of others).
> You are talking about code like this one (from Jonathan Wakely) ?
>
> int f(int c)
> {
> if (c)
> return 0;
> function_that_never_returns();
> }
Yes.
> Initially, I implemented -Wmissing-return to manage this case (
> https://gcc.gnu.org/ml/gcc-patches/2014-01/msg00820.html ) but Jason
> suggested to remove that:
> https://gcc.gnu.org/ml/gcc-patches/2014-01/msg01033.html
> (I don't have a strong opinion on the subject).
I think splitting the option like that makes sense. Compatibility
indicates that -Wreturn-type and -Wall should still enable
-Wmissing-return, but only the other pieces of -Wreturn-type should be
enabled by default, at least for C. (Enabling -Wimplicit-int by default
might be a good starting point.)
Also, at least one testsuite change in your patch is wrong. You add an
"int" return type to c90-impl-int-1.c, which is explicitly checking the
implicit int functionality for C90; use of dg-warning there would be more
appropriate (since the point is that it doesn't give an error with
-pedantic-errors). It would probably also be best not to add
-Wno-return-type in c99-impl-int-1.c. (Any places where /* { dg-bogus
"warning" "warning in place of error" } */ in tests causes problems
because you get a new warning *in addition* to the existing error can have
that dg-bogus removed and a dg-warning directive for the warning added -
dg-warning/dg-error used not to distinguish properly between warnings and
errors, so requiring such dg-bogus directives if you wanted to test the
difference, but that was fixed a long time ago.)
--
Joseph S. Myers
[email protected]