From: Josh Triplett <josh@joshtriplett.org>
To: Kamil Dudka <kdudka@redhat.com>
Cc: Stephen Hemminger <shemminger@vyatta.com>, linux-sparse@vger.kernel.org
Subject: Re: [PATCH] add warnings enum-to-int and int-to-enum
Date: Wed, 2 Sep 2009 12:03:41 -0700 [thread overview]
Message-ID: <20090902190337.GB5148@josh-work.beaverton.ibm.com> (raw)
In-Reply-To: <200909021823.36662.kdudka@redhat.com>
On Wed, Sep 02, 2009 at 06:23:36PM +0200, Kamil Dudka wrote:
> On Wednesday 02 of September 2009 17:21:46 Josh Triplett wrote:
> > Typo. I meant ENUM_TYPE_A:
> >
> > var_a = (enum ENUM_TYPE_A) 0;
> >
> > Hopefully that makes more sense as an "always OK" test. :)
> >
> > Another crazy test for the "always OK" section:
> >
> > anon_enum_var = (__typeof__(anon_enum_var)) 0;
> > anon_enum_var = (__typeof__(anon_enum_var)) VALUE_A;
>
> All three cases pass for me, even with -Wenum-to-int. No problem here.
Great. I didn't expect any of them to fail with your patch; I primarily
suggested them to cover strange corner cases that might occur in future
regressions.
> > > - warn_for_different_enum_types (old->pos, old->ctype, type);
> > > + warn_for_different_enum_types (old->pos, old->ctype, type,
> > > + old->enum_type);
> >
> > At this point, it might make more sense to just pass old, rather than
> > three of its fields. Would that work for the other callers of this
> > function? In any case, that change can wait until after this patch.
>
> At first glance the only change would be in usual_conversions() in reporting
> slightly different location in some rear cases -- no big deal I think.
>
> But in fact I haven't investigated yet how to trigger all the particular
> possibilities of warn_for_different_enum_types() invocation to test this
> properly. I'll give it a try later today.
Don't worry about this change. I only suggested it as a potential
simplification, but it doesn't need to happen as part of this patch.
I'd rather see the patch get merged in its current form (plus the test
suite additions), rather than poking at simplifications like this that
don't immediately prove trivial. Those can always happen later. :)
> > > + warn_for_enum_to_int_cast (old, type);
> > > + warn_for_int_to_enum_cast (old, type);
> >
> > I just realized that both of these functions need renaming as well:
> > s/cast/conversion/ or similar. As with the manpage changes before,
> > "cast" describes the case it *doesn't* warn about.
>
> My line of thinking was "implied vs. explicit cast" ... but I am fine with
> the rename. It'll be more obvious.
To me, "cast" always suggests "explicit cast".
> > You could include this test case in the patch, as an addition to the
> > test suite.
>
> No problem I think. We have generally two choices:
>
> 1) The whole current test-enum.c as a test-case running with all three
> warnings enabled.
>
> 2) Split the test to three parts, each for one separate -W option, and
> then run it as three separate test-cases.
>
> I think the second choice has better coverage. What's your opinion?
Either one seems fine; I don't think splitting the test case helps
coverage, and keeping it together lets you use the same declarations for
the entire test case as you did in the previously attached version.
However, I wonder if it would make sense to have the same test case run
multiple times with different warning options and correspondingly
different output, to make sure the warnings stay associated with the
right flag? Given the current test framework, that would unfortunately
involve some duplication, but it still seems worth doing.
- Josh Triplett
next prev parent reply other threads:[~2009-09-02 19:03 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-30 22:32 sparse segv with simple test Stephen Hemminger
2009-08-30 22:53 ` Kamil Dudka
2009-08-31 15:57 ` Stephen Hemminger
2009-08-31 18:12 ` Kamil Dudka
2009-08-31 18:49 ` Stephen Hemminger
2009-08-31 19:04 ` Kamil Dudka
2009-08-31 20:53 ` Josh Triplett
2009-09-01 21:59 ` [PATCH] add warnings enum-to-int and int-to-enum Kamil Dudka
2009-09-01 23:24 ` Josh Triplett
2009-09-02 0:27 ` Stephen Hemminger
2009-09-02 17:56 ` Daniel Barkalow
2009-09-02 18:04 ` Kamil Dudka
2009-09-02 18:43 ` Daniel Barkalow
2009-09-02 18:56 ` Josh Triplett
2009-09-02 19:19 ` Daniel Barkalow
2009-09-02 19:58 ` Kamil Dudka
2009-09-02 11:53 ` Kamil Dudka
2009-09-02 15:21 ` Josh Triplett
2009-09-02 16:23 ` Kamil Dudka
2009-09-02 16:38 ` Christopher Li
2009-09-02 19:03 ` Josh Triplett [this message]
2009-09-02 19:19 ` Kamil Dudka
2009-09-02 22:35 ` Kamil Dudka
2009-09-03 9:42 ` Christopher Li
2009-09-03 11:47 ` Kamil Dudka
2009-09-03 18:38 ` Christopher Li
2009-09-03 18:54 ` Kamil Dudka
2009-09-03 20:02 ` Christopher Li
2009-09-13 19:28 ` Kamil Dudka
2009-09-13 19:55 ` Christopher Li
2009-09-13 20:09 ` Kamil Dudka
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=20090902190337.GB5148@josh-work.beaverton.ibm.com \
--to=josh@joshtriplett.org \
--cc=kdudka@redhat.com \
--cc=linux-sparse@vger.kernel.org \
--cc=shemminger@vyatta.com \
/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 NNTP newsgroup(s).