From patchwork Tue Mar 9 13:46:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamil Dudka X-Patchwork-Id: 84280 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o29DmlqZ023655 for ; Tue, 9 Mar 2010 13:48:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752645Ab0CINsq (ORCPT ); Tue, 9 Mar 2010 08:48:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:24076 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751306Ab0CINsq (ORCPT ); Tue, 9 Mar 2010 08:48:46 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o29Dm7Jg017343 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 9 Mar 2010 08:48:07 -0500 Received: from dhcp-lab-205.localnet (dhcp-lab-187.englab.brq.redhat.com [10.34.33.187]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o29Dm64n024950; Tue, 9 Mar 2010 08:48:06 -0500 From: Kamil Dudka To: Christopher Li Subject: Re: Sparse crash when mixing int and enum in ternary operator Date: Tue, 9 Mar 2010 14:46:49 +0100 User-Agent: KMail/1.13.0 (Linux/2.6.31.12-174.2.22.fc12.x86_64; KDE/4.4.0; x86_64; ; ) Cc: Pavel Roskin , linux-sparse@vger.kernel.org References: <1268097872.16227.10.camel@mj> <70318cbf1003082143n15e88111haee15d2aa027c0b@mail.gmail.com> In-Reply-To: <70318cbf1003082143n15e88111haee15d2aa027c0b@mail.gmail.com> MIME-Version: 1.0 Message-Id: <201003091446.50092.kdudka@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 09 Mar 2010 13:48:47 +0000 (UTC) diff --git a/evaluate.c b/evaluate.c index d3d5e6f..214b2b7 100644 --- a/evaluate.c +++ b/evaluate.c @@ -327,13 +327,28 @@ 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) { warn_for_different_enum_types (expr, type); warn_for_enum_to_int_conversion (expr, type); warn_for_int_to_enum_conversion (expr, type); } +static void +warn_for_enum_conversions(struct expression *expr, struct symbol *type) +{ + switch (expr->type) { + case EXPR_CONDITIONAL: + case EXPR_SELECT: + do_warn_for_enum_conversions(expr->cond_true, type); + do_warn_for_enum_conversions(expr->cond_false, type); + break; + + default: + do_warn_for_enum_conversions(expr, type); + } +} + /* * This gets called for implicit casts in assignments and * integer promotion. We often want to try to move the