aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/evaluate.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-01-18 14:44:29 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-02-28 21:04:20 +0100
commit7f1ea3b67e7f77f8f87340eefd71c79fe2b37614 (patch)
tree37d9708fce75df14344267756f561787a2e58929 /evaluate.c
parent8095f18a5f9e2ed69cec94f534ec56d982699581 (diff)
downloadsparse-dev-7f1ea3b67e7f77f8f87340eefd71c79fe2b37614.tar.gz
display extra info for type errors in compare & conditional
For "incompatible types in comparison expression" errors, only the kind of type difference is displayed. Displaying the types would make easier to find the cause of the problem. The same is true for ternary conditionals. So, also display the left & right types. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'evaluate.c')
-rw-r--r--evaluate.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/evaluate.c b/evaluate.c
index 2fd19ff5..0b9e208e 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -1132,7 +1132,9 @@ static struct symbol *evaluate_compare(struct expression *expr)
if (!typediff)
goto OK;
- expression_error(expr, "incompatible types in comparison expression (%s)", typediff);
+ expression_error(expr, "incompatible types in comparison expression (%s):", typediff);
+ info(expr->pos, " %s", show_typename(ltype));
+ info(expr->pos, " %s", show_typename(rtype));
return NULL;
OK:
@@ -1268,7 +1270,9 @@ static struct symbol *evaluate_conditional_expression(struct expression *expr)
typediff = "different base types";
Err:
- expression_error(expr, "incompatible types in conditional expression (%s)", typediff);
+ expression_error(expr, "incompatible types in conditional expression (%s):", typediff);
+ info(expr->pos, " %s", show_typename(ltype));
+ info(expr->pos, " %s", show_typename(rtype));
/*
* if the condition is constant, the type is in fact known
* so use it, as gcc & clang do.