aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-01-19 00:39:28 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-09-26 18:08:56 +0200
commitf60446f2ea3a8fa3442ac5c33a718798fec41ed2 (patch)
treeffddf8ae3a018c5894a8ae4e00880dc9d152ce94
parent53179dd438d65fdd8297f485ffa64fb28b6cab8e (diff)
downloadsparse-f60446f2ea3a8fa3442ac5c33a718798fec41ed2.tar.gz
more consistent type info in error messages
Some error messages are displayed with auxillary information about the concerned type(s). However, this type information is displayed in various way: just the type, "[left/right] side has type ...", "got ...", ... Make these more consistent and simpler by just displaying types when the error message is unambigous about the fact that the problem is a type problem (and/or make the message unambiguous when possible). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--evaluate.c20
-rw-r--r--validation/bad-type-twice0.c4
-rw-r--r--validation/bad-type-twice1.c6
-rw-r--r--validation/compare-null-to-int.c6
-rw-r--r--validation/cond_expr.c4
-rw-r--r--validation/conditional-type.c32
-rw-r--r--validation/enum-mismatch.c6
7 files changed, 39 insertions, 39 deletions
diff --git a/evaluate.c b/evaluate.c
index cedd1330..3821bb3d 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -283,9 +283,9 @@ warn_for_different_enum_types (struct position pos,
return;
if (typea->type == SYM_ENUM && typeb->type == SYM_ENUM) {
- warning(pos, "mixing different enum types");
- info(pos, " %s versus", show_typename(typea));
- info(pos, " %s", show_typename(typeb));
+ warning(pos, "mixing different enum types:");
+ info(pos, " %s", show_typename(typea));
+ info(pos, " %s", show_typename(typeb));
}
}
@@ -413,16 +413,16 @@ static struct symbol *bad_expr_type(struct expression *expr)
case EXPR_COMPARE:
if (!valid_subexpr_type(expr))
break;
- sparse_error(expr->pos, "incompatible types for operation (%s)", show_special(expr->op));
- info(expr->pos, " left side has type %s", show_typename(expr->left->ctype));
- info(expr->pos, " right side has type %s", show_typename(expr->right->ctype));
+ sparse_error(expr->pos, "incompatible types for operation (%s):", show_special(expr->op));
+ info(expr->pos, " %s", show_typename(expr->left->ctype));
+ info(expr->pos, " %s", show_typename(expr->right->ctype));
break;
case EXPR_PREOP:
case EXPR_POSTOP:
if (!valid_expr_type(expr->unop))
break;
- sparse_error(expr->pos, "incompatible types for operation (%s)", show_special(expr->op));
- info(expr->pos, " argument has type %s", show_typename(expr->unop->ctype));
+ sparse_error(expr->pos, "incompatible type for operation (%s):", show_special(expr->op));
+ info(expr->pos, " %s", show_typename(expr->unop->ctype));
break;
default:
break;
@@ -910,8 +910,8 @@ static struct symbol *evaluate_conditional(struct expression *expr, int iterator
if (Waddress)
warning(expr->pos, "the address of %s will always evaluate as true", "an array");
} else if (!is_scalar_type(ctype)) {
- sparse_error(expr->pos, "incorrect type in conditional (non-scalar type)");
- info(expr->pos, " got %s", show_typename(ctype));
+ sparse_error(expr->pos, "incorrect type in conditional (non-scalar type):");
+ info(expr->pos, " %s", show_typename(ctype));
return NULL;
}
diff --git a/validation/bad-type-twice0.c b/validation/bad-type-twice0.c
index 5d107a62..45234699 100644
--- a/validation/bad-type-twice0.c
+++ b/validation/bad-type-twice0.c
@@ -7,7 +7,7 @@ static int foo(a)
* check-name: bad-type-twice0
*
* check-error-start
-bad-type-twice0.c:3:16: error: incorrect type in conditional (non-scalar type)
-bad-type-twice0.c:3:16: got incomplete type a
+bad-type-twice0.c:3:16: error: incorrect type in conditional (non-scalar type):
+bad-type-twice0.c:3:16: incomplete type a
* check-error-end
*/
diff --git a/validation/bad-type-twice1.c b/validation/bad-type-twice1.c
index cc81662a..a9ba182c 100644
--- a/validation/bad-type-twice1.c
+++ b/validation/bad-type-twice1.c
@@ -9,8 +9,8 @@ static unsigned long foo(unsigned long val, void *ref)
* check-name: bad-type-twice1
*
* check-error-start
-bad-type-twice1.c:3:17: error: incompatible types for operation (>=)
-bad-type-twice1.c:3:17: left side has type unsigned long val
-bad-type-twice1.c:3:17: right side has type void *ref
+bad-type-twice1.c:3:17: error: incompatible types for operation (>=):
+bad-type-twice1.c:3:17: unsigned long val
+bad-type-twice1.c:3:17: void *ref
* check-error-end
*/
diff --git a/validation/compare-null-to-int.c b/validation/compare-null-to-int.c
index 08e556b3..336c724d 100644
--- a/validation/compare-null-to-int.c
+++ b/validation/compare-null-to-int.c
@@ -4,8 +4,8 @@ static unsigned int comparison = (void *)0 == 1;
* check-description: Sparse used to allow this.
*
* check-error-start
-compare-null-to-int.c:1:44: error: incompatible types for operation (==)
-compare-null-to-int.c:1:44: left side has type void *
-compare-null-to-int.c:1:44: right side has type int
+compare-null-to-int.c:1:44: error: incompatible types for operation (==):
+compare-null-to-int.c:1:44: void *
+compare-null-to-int.c:1:44: int
* check-error-end
*/
diff --git a/validation/cond_expr.c b/validation/cond_expr.c
index e55711cc..9b8105c1 100644
--- a/validation/cond_expr.c
+++ b/validation/cond_expr.c
@@ -13,7 +13,7 @@ int a(void)
* check-name: Two-argument conditional expression types
*
* check-error-start
-cond_expr.c:10:16: error: incompatible types for operation (~)
-cond_expr.c:10:16: argument has type double
+cond_expr.c:10:16: error: incompatible type for operation (~):
+cond_expr.c:10:16: double
* check-error-end
*/
diff --git a/validation/conditional-type.c b/validation/conditional-type.c
index 91267212..34cfcc68 100644
--- a/validation/conditional-type.c
+++ b/validation/conditional-type.c
@@ -79,21 +79,21 @@ static int good_if_ptr(void *ptr)
* check-name: conditional-type
*
* check-error-start
-conditional-type.c:18:18: error: incorrect type in conditional (non-scalar type)
-conditional-type.c:18:18: got void
-conditional-type.c:19:13: error: incorrect type in conditional (non-scalar type)
-conditional-type.c:19:13: got struct state s
-conditional-type.c:24:18: error: incorrect type in conditional (non-scalar type)
-conditional-type.c:24:18: got void
-conditional-type.c:29:21: error: incorrect type in conditional (non-scalar type)
-conditional-type.c:29:21: got void
-conditional-type.c:30:16: error: incorrect type in conditional (non-scalar type)
-conditional-type.c:30:16: got struct state s
-conditional-type.c:34:21: error: incorrect type in conditional (non-scalar type)
-conditional-type.c:34:21: got void
-conditional-type.c:36:20: error: incorrect type in conditional (non-scalar type)
-conditional-type.c:36:20: got void
-conditional-type.c:40:21: error: incorrect type in conditional (non-scalar type)
-conditional-type.c:40:21: got void
+conditional-type.c:18:18: error: incorrect type in conditional (non-scalar type):
+conditional-type.c:18:18: void
+conditional-type.c:19:13: error: incorrect type in conditional (non-scalar type):
+conditional-type.c:19:13: struct state s
+conditional-type.c:24:18: error: incorrect type in conditional (non-scalar type):
+conditional-type.c:24:18: void
+conditional-type.c:29:21: error: incorrect type in conditional (non-scalar type):
+conditional-type.c:29:21: void
+conditional-type.c:30:16: error: incorrect type in conditional (non-scalar type):
+conditional-type.c:30:16: struct state s
+conditional-type.c:34:21: error: incorrect type in conditional (non-scalar type):
+conditional-type.c:34:21: void
+conditional-type.c:36:20: error: incorrect type in conditional (non-scalar type):
+conditional-type.c:36:20: void
+conditional-type.c:40:21: error: incorrect type in conditional (non-scalar type):
+conditional-type.c:40:21: void
* check-error-end
*/
diff --git a/validation/enum-mismatch.c b/validation/enum-mismatch.c
index 1bdb1d6c..a6e5d72d 100644
--- a/validation/enum-mismatch.c
+++ b/validation/enum-mismatch.c
@@ -12,8 +12,8 @@ static enum eb foo(enum ea a)
* check-command: sparse -Wenum-mismatch $file
*
* check-error-start
-enum-mismatch.c:7:16: warning: mixing different enum types
-enum-mismatch.c:7:16: unsigned int enum ea versus
-enum-mismatch.c:7:16: unsigned int enum eb
+enum-mismatch.c:7:16: warning: mixing different enum types:
+enum-mismatch.c:7:16: unsigned int enum ea
+enum-mismatch.c:7:16: unsigned int enum eb
* check-error-end
*/