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 simply dipslaying type(s) 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@xxxxxxxxx> --- evaluate.c | 20 ++++++++++---------- validation/bad-type-twice0.c | 4 ++-- validation/bad-type-twice1.c | 6 +++--- validation/compare-null-to-int.c | 6 +++--- validation/cond_expr.c | 4 ++-- validation/conditional-type.c | 32 ++++++++++++++++---------------- validation/enum-mismatch.c | 6 +++--- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/evaluate.c b/evaluate.c index efe6d28b8..4d5748562 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"); - info(expr->pos, " got %s", show_typename(ctype)); + sparse_error(expr->pos, "incorrect type in conditional:"); + info(expr->pos, " %s", show_typename(ctype)); return NULL; } diff --git a/validation/bad-type-twice0.c b/validation/bad-type-twice0.c index 7a9073c52..84e0f25a4 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 -bad-type-twice0.c:3:16: got incomplete type a +bad-type-twice0.c:3:16: error: incorrect type in conditional: +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 cc81662af..a9ba182cb 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 08e556b32..336c724de 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 e55711cce..9b8105c1c 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 a14c05ec1..7cd5672dc 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 -conditional-type.c:18:18: got void -conditional-type.c:19:13: error: incorrect type in conditional -conditional-type.c:19:13: got struct state s -conditional-type.c:24:18: error: incorrect type in conditional -conditional-type.c:24:18: got void -conditional-type.c:29:21: error: incorrect type in conditional -conditional-type.c:29:21: got void -conditional-type.c:30:16: error: incorrect type in conditional -conditional-type.c:30:16: got struct state s -conditional-type.c:34:21: error: incorrect type in conditional -conditional-type.c:34:21: got void -conditional-type.c:36:20: error: incorrect type in conditional -conditional-type.c:36:20: got void -conditional-type.c:40:21: error: incorrect type in conditional -conditional-type.c:40:21: got void +conditional-type.c:18:18: error: incorrect type in conditional: +conditional-type.c:18:18: void +conditional-type.c:19:13: error: incorrect type in conditional: +conditional-type.c:19:13: struct state s +conditional-type.c:24:18: error: incorrect type in conditional: +conditional-type.c:24:18: void +conditional-type.c:29:21: error: incorrect type in conditional: +conditional-type.c:29:21: void +conditional-type.c:30:16: error: incorrect type in conditional: +conditional-type.c:30:16: struct state s +conditional-type.c:34:21: error: incorrect type in conditional: +conditional-type.c:34:21: void +conditional-type.c:36:20: error: incorrect type in conditional: +conditional-type.c:36:20: void +conditional-type.c:40:21: error: incorrect type in conditional: +conditional-type.c:40:21: void * check-error-end */ diff --git a/validation/enum-mismatch.c b/validation/enum-mismatch.c index 1bdb1d6c2..a6e5d72db 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 */ -- 2.20.0