diff mbox

Sparse crash when mixing int and enum in ternary operator

Message ID 201003100030.50165.kdudka@redhat.com (mailing list archive)
State Rejected, archived
Headers show

Commit Message

Kamil Dudka March 9, 2010, 11:30 p.m. UTC
None
diff mbox

Patch

From 50a39380f5f97e5c379c6464eff609916175640c Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
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 <kdudka@redhat.com>
---
 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