public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Richard Biener <rguenther@suse.de>,
	Jason Merrill <jason@redhat.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>,
	Joseph Myers <joseph@codesourcery.com>
Subject: Re: Implement -Wduplicated-branches (PR c/64279) (v3)
Date: Thu, 19 Jan 2017 16:53:00 -0000	[thread overview]
Message-ID: <20170119165213.GG17248@redhat.com> (raw)
In-Reply-To: <20170109133930.GM8104@redhat.com>

On Mon, Jan 09, 2017 at 02:39:30PM +0100, Marek Polacek wrote:
> On Mon, Jan 09, 2017 at 12:18:01PM +0100, Jakub Jelinek wrote:
> > On Mon, Jan 09, 2017 at 10:21:47AM +0100, Marek Polacek wrote:
> > > +/* Callback function to determine whether an expression TP or one of its
> > > +   subexpressions comes from macro expansion.  Used to suppress bogus
> > > +   warnings.  */
> > > +
> > > +static tree
> > > +expr_from_macro_expansion_r (tree *tp, int *, void *)
> > > +{
> > > +  if (CAN_HAVE_LOCATION_P (*tp)
> > > +      && from_macro_expansion_at (EXPR_LOCATION (*tp)))
> > > +    return integer_zero_node;
> > > +
> > > +  return NULL_TREE;
> > > +}
> > 
> > I know this is hard issue, but won't it disable the warning way too often?
> > 
> > Perhaps it is good enough for the initial version (GCC 7), but doesn't it stop
> > whenever one uses NULL in the branches, or some other trivial macros like
> > that?  Perhaps we want to do the analysis if there is anything from macro
> > expansion side-by-side on both the expressions and if you find something
> > from a macro expansion, then still warn if both corresponding expressions
> > are from the same macro expansion (either only non-function like one, or
> > perhaps also function-like one with the same arguments, if it is possible
> > to figure out those somehow)?  And perhaps it would be nice to choose
> > warning level, whether you want to warn only under these rules (no macros
> > or something smarter if implemented) vs. some certainly non-default more
> > aggressive mode that will just warn no matter what macros there are.
> 
> I agree that not warning for 
>   if (foo)
>     return NULL;
>   else
>     return NULL;
> is bad.  But how can I compare those expressions side-by-side?  I'm not finding
> anything. :(

Seems like ENOTIME to address this; will you be ok with the patch as-is
(modulo Jeff comments), if I open a PR about the above test case?

Thanks,

	Marek

  reply	other threads:[~2017-01-19 16:52 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-19 11:07 Implement -Wduplicated-branches (PR c/64279) Marek Polacek
2016-10-20 10:28 ` Marek Polacek
2016-10-24 14:10   ` Implement -Wduplicated-branches (PR c/64279) (v2) Marek Polacek
2016-10-25 13:59     ` Implement -Wduplicated-branches (PR c/64279) (v3) Marek Polacek
2016-11-01 13:41       ` Jason Merrill
2016-11-01 13:54         ` Jakub Jelinek
2016-11-03 11:24           ` Marek Polacek
2016-11-03 13:28             ` Jason Merrill
2016-11-03 13:38               ` Jakub Jelinek
2017-01-04  6:49                 ` Eric Gallager
2017-01-05 15:39                 ` Marek Polacek
2017-01-05 15:41                   ` Jakub Jelinek
2017-01-05 16:39                     ` Richard Biener
2017-01-09  9:21                     ` Marek Polacek
2017-01-09 10:58                       ` Richard Biener
2017-01-09 11:01                         ` Marek Polacek
2017-01-09 11:18                       ` Jakub Jelinek
2017-01-09 13:39                         ` Marek Polacek
2017-01-19 16:53                           ` Marek Polacek [this message]
2017-01-19 16:58                             ` Jakub Jelinek
2017-01-16 22:33                       ` Jeff Law
2017-01-20 11:16                         ` Marek Polacek
2016-10-20 14:12 ` Implement -Wduplicated-branches (PR c/64279) Jason Merrill
2016-10-20 14:24   ` Marek Polacek
2016-10-20 14:37     ` David Malcolm
2016-10-20 18:56       ` Jeff Law
2016-10-24 14:03         ` Marek Polacek
2016-10-20 20:21 ` Martin Sebor
2016-10-24 13:59   ` Marek Polacek
2016-10-24 14:18     ` Martin Sebor
2016-10-24 14:35       ` Marek Polacek
2016-10-24 14:39         ` Jakub Jelinek
2016-10-24 14:44           ` Marek Polacek
2016-10-24 14:59             ` Martin Sebor
2017-01-20 15:07 Implement -Wduplicated-branches (PR c/64279) (v3) David Edelsohn
2017-01-20 15:17 ` Marek Polacek

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=20170119165213.GG17248@redhat.com \
    --to=polacek@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=rguenther@suse.de \
    /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).