diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-07-04 15:53:26 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-02-01 18:15:50 +0100 |
commit | bc112432796021623ca6d4efa7efa3a183196a09 (patch) | |
tree | 0b9cadf4dcfc76ce5b73aa5e9ae40634abde2317 /evaluate.c | |
parent | 0b30cce1e5fa30a7e7c0272a3e5adde303baad1a (diff) | |
download | sparse-bc112432796021623ca6d4efa7efa3a183196a09.tar.gz |
always evaluate both operands
When evaluating a binary expression, the evaluation
already stop if the left operand is found erroneous.
The right one is thus not evaluated but it may contain
another error which will only be diagnosticated after the
first one is corrected and the file rechecked.
This is especially annoying when there are several independent
errors in some complex expression since it will need several
cycles of check-edit-recheck to get all errrors out.
Fix this by always evaluating both left & right operands
(and returning NULL if one of them is erroneous).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'evaluate.c')
-rw-r--r-- | evaluate.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -3205,9 +3205,9 @@ struct symbol *evaluate_expression(struct expression *expr) case EXPR_SYMBOL: return evaluate_symbol_expression(expr); case EXPR_BINOP: - if (!evaluate_expression(expr->left)) - return NULL; - if (!evaluate_expression(expr->right)) + evaluate_expression(expr->left); + evaluate_expression(expr->right); + if (!valid_subexpr_type(expr)) return NULL; return evaluate_binop(expr); case EXPR_LOGICAL: @@ -3218,15 +3218,15 @@ struct symbol *evaluate_expression(struct expression *expr) return NULL; return evaluate_comma(expr); case EXPR_COMPARE: - if (!evaluate_expression(expr->left)) - return NULL; - if (!evaluate_expression(expr->right)) + evaluate_expression(expr->left); + evaluate_expression(expr->right); + if (!valid_subexpr_type(expr)) return NULL; return evaluate_compare(expr); case EXPR_ASSIGNMENT: - if (!evaluate_expression(expr->left)) - return NULL; - if (!evaluate_expression(expr->right)) + evaluate_expression(expr->left); + evaluate_expression(expr->right); + if (!valid_subexpr_type(expr)) return NULL; return evaluate_assignment(expr); case EXPR_PREOP: |