diff mbox

Sparse crash when mixing int and enum in ternary operator

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

Commit Message

Kamil Dudka March 9, 2010, 1:46 p.m. UTC
None
diff mbox

Patch

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