public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Joseph S. Myers" <joseph@codesourcery.com>
To: Sylvestre Ledru <sylvestre@debian.org>
Cc: <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com>
Subject: Re: [Patch] PR55189 enable -Wreturn-type by default
Date: Thu, 05 Jun 2014 18:01:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.64.1406051749260.2819@digraph.polyomino.org.uk> (raw)
In-Reply-To: <53903961.9030501@debian.org>

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
joseph@codesourcery.com

  reply	other threads:[~2014-06-05 18:01 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-04 19:49 Sylvestre Ledru
2014-06-04 22:35 ` Mike Stump
2014-06-04 23:31 ` Joseph S. Myers
2014-06-05  9:33   ` Sylvestre Ledru
2014-06-05 18:01     ` Joseph S. Myers [this message]
2014-06-17 16:52       ` Sylvestre Ledru
2014-06-17 17:15         ` Joseph S. Myers
2014-06-17 17:37           ` Sylvestre Ledru
2014-06-17 17:41             ` Joseph S. Myers
2014-07-07 17:18               ` Sylvestre Ledru
2014-07-20 19:20                 ` Sylvestre Ledru
2014-07-30 22:10                 ` Joseph S. Myers
2014-08-11  7:44                   ` Sylvestre Ledru
2014-08-12 17:49                     ` Joseph S. Myers
2014-08-12 17:53                       ` Sylvestre Ledru
2014-08-14 17:01                       ` Sylvestre Ledru
  -- strict thread matches above, loose matches on Subject: below --
2014-08-14 18:49 Manuel López-Ibáñez
2014-08-15 16:28 ` Sylvestre Ledru
2014-08-19 22:03   ` Joseph S. Myers
2014-08-20 21:42     ` Sylvestre Ledru
2014-08-20 21:58       ` Joseph S. Myers
2013-12-20 17:54 Sylvestre Ledru
2013-12-27  5:26 ` Chung-Ju Wu
2013-12-27  5:32   ` Yury Gribov
2014-01-14 17:49     ` Sylvestre Ledru
2014-01-16 19:44 ` Jason Merrill
2014-01-23  6:44   ` Sylvestre Ledru
2014-01-23 18:48   ` Jason Merrill
2014-01-23 18:57     ` Sylvestre Ledru

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.1406051749260.2819@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=sylvestre@debian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).