From: Christopher Li <sparse@chrisli.org>
To: Josh Triplett <josh@joshtriplett.org>
Cc: Kamil Dudka <kdudka@redhat.com>, Pavel Roskin <proski@gnu.org>,
linux-sparse@vger.kernel.org
Subject: Re: Sparse crash when mixing int and enum in ternary operator
Date: Mon, 29 Mar 2010 11:05:08 -0700 [thread overview]
Message-ID: <70318cbf1003291105v44334f0et82575f62a8c187f8@mail.gmail.com> (raw)
In-Reply-To: <20100327092949.GB9548@feather>
On Sat, Mar 27, 2010 at 2:29 AM, Josh Triplett <josh@joshtriplett.org> wrote:
>> .type = (enum keyword) (KW_SPECIFIER | KW_SHORT),
>> lookup_keyword(token->ident, (enum namespace) (NS_KEYWORD | NS_TYPEDEF));
>
> That looks wrong. .type doesn't contain a value of type "enum keyword",
> it contains the bitwise or of such values, which won't represent a valid
> enum value. Thus, .type should have an integral type, not an enum type.
> The same goes for the second parameter of lookup_keyword.
According to the new "strict enum" rules which don't allow enum type to accept
value other than the enum list above, that is right.
But I argue that this strict enum rules does not make sense, after this change,
the code don't not gain any thing. In fact, it looks worse.
Sparse use a loosely define enum namespace for member "namespace". It means
it has all this basic enum value, from NS_MACRO to NS_KEYWORD. In my mind,
all combination of this value consider enum namespace as well. It is
just that I can't
list all of them in the enum list.
Using enum namespace for member "namespace" has benefit here. It is clear that
which set of value it belongs to. E.g. if you assign SYM_NODE into "namespace"
member it *looks* is obvious wrong.
It also helps people understand which set of value belongs to
"namespace" member.
Make "namespace" a plain int, that message is lost. It become very
confusing for new comer
what value was allowed in this int type.
So back to my point. It seems making the enum more strict is just make up rules
and gain nothing in real life. It makes code looks worse just to make
strict enum type
happy.
Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-03-29 18:05 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-09 1:24 Sparse crash when mixing int and enum in ternary operator Pavel Roskin
2010-03-09 5:43 ` Christopher Li
2010-03-09 13:46 ` Kamil Dudka
2010-03-09 18:26 ` Pavel Roskin
2010-03-09 18:35 ` Pavel Roskin
2010-03-09 19:06 ` Kamil Dudka
2010-03-09 19:15 ` Josh Triplett
2010-03-09 20:11 ` Pavel Roskin
2010-03-09 20:29 ` Kamil Dudka
2010-03-09 23:30 ` Kamil Dudka
2010-03-10 1:09 ` Pavel Roskin
2010-03-10 16:05 ` Kamil Dudka
2010-03-10 20:27 ` Pavel Roskin
2010-03-10 20:44 ` Kamil Dudka
2010-03-10 21:03 ` Kamil Dudka
2010-03-10 21:56 ` Christopher Li
2010-03-13 17:22 ` Kamil Dudka
2010-03-21 15:27 ` Kamil Dudka
2010-03-24 10:07 ` Christopher Li
2010-03-24 10:51 ` Kamil Dudka
2010-03-27 9:16 ` Kamil Dudka
2010-03-27 9:29 ` Josh Triplett
2010-03-27 9:53 ` [PATCH] eliminate insane conversions from int to enum Kamil Dudka
2010-03-29 18:11 ` Christopher Li
2010-03-29 18:05 ` Christopher Li [this message]
2010-03-29 18:17 ` Sparse crash when mixing int and enum in ternary operator Kamil Dudka
2010-03-29 18:48 ` Christopher Li
2010-03-29 19:23 ` Kamil Dudka
2010-03-30 5:29 ` Pavel Roskin
2010-03-29 21:26 ` Josh Triplett
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=70318cbf1003291105v44334f0et82575f62a8c187f8@mail.gmail.com \
--to=sparse@chrisli.org \
--cc=josh@joshtriplett.org \
--cc=kdudka@redhat.com \
--cc=linux-sparse@vger.kernel.org \
--cc=proski@gnu.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 NNTP newsgroup(s).