[PATCH] warning: explain restrictness difference in error messages

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

 



For sparse, a difference of restrictness (__bitwise) is reported
as a difference of base types. That's correct but for the user it
may be more informative to know if teh error is one concerning
the normal C rules or one related to sparse's extensions.

Change this by using "different restrictness" or "different
restricted types", depending if one or both types is a concerned.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 evaluate.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/evaluate.c b/evaluate.c
index 0ff617b1f..5fd0edce7 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -714,8 +714,11 @@ const char *type_difference(struct ctype *c1, struct ctype *c2,
 
 		move1 = move2 = 1;
 		type = t1->type;
-		if (type != t2->type)
+		if (type != t2->type) {
+			if (type == SYM_RESTRICT || t2->type == SYM_RESTRICT)
+				return "different restrictness";
 			return "different base types";
+		}
 
 		switch (type) {
 		default:
@@ -724,7 +727,7 @@ const char *type_difference(struct ctype *c1, struct ctype *c2,
 				     type);
 			return "bad types";
 		case SYM_RESTRICT:
-			return "different base types";
+			return "different restricted types";
 		case SYM_UNION:
 		case SYM_STRUCT:
 			/* allow definition of incomplete structs and unions */
@@ -1404,6 +1407,8 @@ static int check_assignment_types(struct symbol *target, struct expression **rp,
                         goto Cast;
                 }
 		*typediff = "different base types";
+		if ((tclass ^ sclass) & TYPE_RESTRICT)
+			*typediff = "different restrictness";
 		return 0;
 	}
 
-- 
2.17.1

--
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