From: Kamil Dudka <kdudka@redhat.com>
To: Pavel Roskin <proski@gnu.org>
Cc: Josh Triplett <josh@joshtriplett.org>,
Christopher Li <sparse@chrisli.org>,
linux-sparse@vger.kernel.org
Subject: Re: Sparse crash when mixing int and enum in ternary operator
Date: Tue, 9 Mar 2010 21:29:15 +0100 [thread overview]
Message-ID: <201003092129.16118.kdudka@redhat.com> (raw)
In-Reply-To: <1268165517.23196.22.camel@mj>
On Tuesday 09 of March 2010 21:11:57 Pavel Roskin wrote:
> Ironically, the fix for :? may benefit from that operator:
>
> do_warn_for_enum_conversions(expr->cond_true ?: expr->conditional, type);
Yeah, that's exactly what I've tried ;-)
> do_warn_for_enum_conversions(expr->cond_false ?: expr->conditional, type);
Does it mean the cond_false may be also omitted? I can't image how the enum
conversion analysis can be useful in that case. I've ensured the optional
analysis would no more crash on another corner case in the first place:
--- a/evaluate.c
+++ b/evaluate.c
@@ -327,13 +327,35 @@ warn_for_int_to_enum_conversion (struct expression
*expr, struct symbol *typeb)
}
static void
-warn_for_enum_conversions(struct expression *expr, struct symbol *type)
+do_warn_for_enum_conversions(struct expression *expr, struct symbol *type)
{
+ if (!expr || !type)
+ /* do not crash when there is nothing to check */
+ return;
+
warn_for_different_enum_types (expr, type);
warn_for_enum_to_int_conversion (expr, type);
warn_for_int_to_enum_conversion (expr, type);
}
> At least I was able to run sparse on the whole kernel (wireless-testing,
> which is based on 2.6.34-rc1) without crashing or reporting anything
> strange.
>
> Actually, omitting the false conditional appears to be invalid.
Unfortunately it's not that easy. I am still getting a non-sense warning for:
static void foo(void)
{
enum { VAL } y, x = VAL;
y = x ?: VAL;
}
$ ./sparse enum.c
enum.c:4:9: warning: conversion of
enum.c:4:9: int to
enum.c:4:9: int enum <noident>
I need to somehow get over the EXPR_IMPLIED_CAST to dig the original enum_type
from there...
Kamil
next prev parent reply other threads:[~2010-03-09 20:31 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 [this message]
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 ` Sparse crash when mixing int and enum in ternary operator Christopher Li
2010-03-29 18:17 ` 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=201003092129.16118.kdudka@redhat.com \
--to=kdudka@redhat.com \
--cc=josh@joshtriplett.org \
--cc=linux-sparse@vger.kernel.org \
--cc=proski@gnu.org \
--cc=sparse@chrisli.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.