From patchwork Tue Mar 9 23:30: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: 84435 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 o29NWUS6027808 for ; Tue, 9 Mar 2010 23:32:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754710Ab0CIXca (ORCPT ); Tue, 9 Mar 2010 18:32:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34711 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753647Ab0CIXc3 (ORCPT ); Tue, 9 Mar 2010 18:32:29 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o29NVd51018633 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 9 Mar 2010 18:31:40 -0500 Received: from vpn1-5-47.ams2.redhat.com (vpn1-5-47.ams2.redhat.com [10.36.5.47]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o29NVb9v023164; Tue, 9 Mar 2010 18:31:38 -0500 From: Kamil Dudka To: Pavel Roskin Subject: Re: Sparse crash when mixing int and enum in ternary operator Date: Wed, 10 Mar 2010 00:30:49 +0100 User-Agent: KMail/1.9.10 Cc: Josh Triplett , Christopher Li , linux-sparse@vger.kernel.org References: <1268097872.16227.10.camel@mj> <1268165517.23196.22.camel@mj> <201003092129.16118.kdudka@redhat.com> In-Reply-To: <201003092129.16118.kdudka@redhat.com> MIME-Version: 1.0 Message-Id: <201003100030.50165.kdudka@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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 23:32:31 +0000 (UTC) From 50a39380f5f97e5c379c6464eff609916175640c Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Wed, 10 Mar 2010 00:15:08 +0100 Subject: [PATCH 2/2] -Wenum-to-int is now emitted only for = and switch Signed-off-by: Kamil Dudka --- evaluate.c | 3 +- validation/enum-to-int.c | 69 ---------------------------------------------- 2 files changed, 2 insertions(+), 70 deletions(-) diff --git a/evaluate.c b/evaluate.c index b4c2758..9e5f28e 100644 --- a/evaluate.c +++ b/evaluate.c @@ -338,7 +338,6 @@ do_warn_for_enum_conversions(struct expression *expr, struct symbol *type) return; warn_for_different_enum_types (expr, type); - warn_for_enum_to_int_conversion (expr, type); warn_for_int_to_enum_conversion (expr, type); } @@ -1473,6 +1472,7 @@ Err: *rp = cast_to(*rp, target); return 0; Cast: + warn_for_enum_to_int_conversion (*rp, target); *rp = cast_to(*rp, target); return 1; } @@ -3352,6 +3352,7 @@ static void check_case_type(struct expression *switch_expr, if (!switch_type || !case_type) goto Bad; + warn_for_enum_to_int_conversion (case_expr, switch_type); warn_for_enum_conversions(case_expr, switch_type); sclass = classify_type(switch_type, &switch_type); diff --git a/validation/enum-to-int.c b/validation/enum-to-int.c index 33fdeeb..134a34d 100644 --- a/validation/enum-to-int.c +++ b/validation/enum-to-int.c @@ -5,75 +5,6 @@ * check-command: sparse -Wenum-to-int -Wno-enum-mismatch -Wno-int-to-enum $file * * check-error-start -enum-common.c:50:25: warning: conversion of -enum-common.c:50:25: int enum ENUM_TYPE_A to -enum-common.c:50:25: int -enum-common.c:50:25: warning: conversion of -enum-common.c:50:25: int enum ENUM_TYPE_A to -enum-common.c:50:25: int -enum-common.c:50:33: warning: conversion of -enum-common.c:50:33: int enum ENUM_TYPE_A to -enum-common.c:50:33: int -enum-common.c:51:27: warning: conversion of -enum-common.c:51:27: int enum ENUM_TYPE_B to -enum-common.c:51:27: int -enum-common.c:51:37: warning: conversion of -enum-common.c:51:37: int enum ENUM_TYPE_B to -enum-common.c:51:37: int -enum-common.c:52:29: warning: conversion of -enum-common.c:52:29: int enum ENUM_TYPE_A to -enum-common.c:52:29: int -enum-common.c:52:38: warning: conversion of -enum-common.c:52:38: int enum ENUM_TYPE_A to -enum-common.c:52:38: int -enum-common.c:83:29: warning: conversion of -enum-common.c:83:29: int enum ENUM_TYPE_A to -enum-common.c:83:29: int -enum-common.c:83:29: warning: conversion of -enum-common.c:83:29: int enum ENUM_TYPE_A to -enum-common.c:83:29: int -enum-common.c:83:39: warning: conversion of -enum-common.c:83:39: int enum ENUM_TYPE_B to -enum-common.c:83:39: int -enum-common.c:84:33: warning: conversion of -enum-common.c:84:33: int enum ENUM_TYPE_A to -enum-common.c:84:33: int -enum-common.c:84:33: warning: conversion of -enum-common.c:84:33: int enum ENUM_TYPE_A to -enum-common.c:84:33: int -enum-common.c:84:43: warning: conversion of -enum-common.c:84:43: int enum ENUM_TYPE_B to -enum-common.c:84:43: int -enum-common.c:85:33: warning: conversion of -enum-common.c:85:33: int enum ENUM_TYPE_A to -enum-common.c:85:33: int -enum-common.c:85:33: warning: conversion of -enum-common.c:85:33: int enum ENUM_TYPE_A to -enum-common.c:85:33: int -enum-common.c:85:43: warning: conversion of -enum-common.c:85:43: int enum ENUM_TYPE_B to -enum-common.c:85:43: int -enum-common.c:86:29: warning: conversion of -enum-common.c:86:29: int enum ENUM_TYPE_A to -enum-common.c:86:29: int -enum-common.c:86:38: warning: conversion of -enum-common.c:86:38: int enum ENUM_TYPE_B to -enum-common.c:86:38: int -enum-common.c:87:29: warning: conversion of -enum-common.c:87:29: int enum ENUM_TYPE_B to -enum-common.c:87:29: int -enum-common.c:87:38: warning: conversion of -enum-common.c:87:38: int enum ENUM_TYPE_A to -enum-common.c:87:38: int -enum-common.c:106:29: warning: conversion of -enum-common.c:106:29: int enum ENUM_TYPE_A to -enum-common.c:106:29: int -enum-common.c:106:29: warning: conversion of -enum-common.c:106:29: int enum ENUM_TYPE_A to -enum-common.c:106:29: int -enum-common.c:107:34: warning: conversion of -enum-common.c:107:34: int enum ENUM_TYPE_A to -enum-common.c:107:34: int enum-common.c:112:13: warning: conversion of enum-common.c:112:13: int enum ENUM_TYPE_A to enum-common.c:112:13: int -- 1.6.1.2