[PATCH 6/7] saner recovery from endianness errors, part 1.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 evaluate.c |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/evaluate.c b/evaluate.c
index 7f4810d..71c46d1 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -473,6 +473,7 @@ static struct symbol *usual_conversions(
 	if ((lclass | rclass) & TYPE_RESTRICT)
 		goto Restr;
 
+Normal:
 	if (!(lclass & TYPE_FLOAT)) {
 		if (!(rclass & TYPE_FLOAT))
 			ctype = bigger_int_type(ltype, rtype);
@@ -499,7 +500,15 @@ Restr:
 	if (ctype)
 		goto Convert;
 
-	return NULL;
+	if (lclass & TYPE_RESTRICT) {
+		warning((*left)->pos, "restricted degrades to integer");
+		ltype = ltype->ctype.base_type;
+	}
+	if (rclass & TYPE_RESTRICT) {
+		warning((*right)->pos, "restricted degrades to integer");
+		rtype = rtype->ctype.base_type;
+	}
+	goto Normal;
 }
 
 static struct symbol *evaluate_arith(struct expression *expr, int float_ok)
@@ -517,10 +526,8 @@ static struct symbol *evaluate_arith(str
 
 	ctype = usual_conversions(expr->op, &expr->left, &expr->right,
 				  lclass, rclass, ltype, rtype);
-	if (ctype) {
-		expr->ctype = ctype;
-		return ctype;
-	}
+	expr->ctype = ctype;
+	return ctype;
 
 Bad:
 	return bad_expr_type(expr);
@@ -1055,8 +1062,7 @@ static struct symbol *evaluate_condition
 	if (lclass & rclass & TYPE_NUM) {
 		ctype = usual_conversions('?', true, &expr->cond_false,
 					  lclass, rclass, ltype, rtype);
-		if (ctype)
-			goto out;
+		goto out;
 	}
 	ctype = compatible_ptr_type(*true, expr->cond_false);
 	if (ctype)
@@ -2670,9 +2676,11 @@ static void check_case_type(struct expre
 	if (!((sclass | cclass) & TYPE_RESTRICT))
 		return;
 
-	if (restricted_binop_type(SPECIAL_EQUAL, case_expr, switch_expr,
+	if (!restricted_binop_type(SPECIAL_EQUAL, case_expr, switch_expr,
 				   cclass, sclass, case_type, switch_type))
-		return;
+		warning(case_expr->pos, "restricted degrades to integer");
+
+	return;
 
 Bad:
 	sparse_error(case_expr->pos, "incompatible types for 'case' statement");
-- 
1.4.2.GIT


-
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux