diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-05-07 17:46:04 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-05-21 17:27:45 +0200 |
commit | 62596fe4efb13a41cdc05b931792122f9d855d14 (patch) | |
tree | 459a4c1cbbe437dfec5bbd765f1bbb90cb83a7b0 | |
parent | efda1a044c7ce014f38c3225ec79b2befd0a0620 (diff) | |
download | sparse-62596fe4efb13a41cdc05b931792122f9d855d14.tar.gz |
misc: s/fntype/rettype/
In evaluate_return_expression(), it's checked if the type of
the return statement match the function return type.
But, the variable used to hold this type is named 'fntype'
which is slightly confusing.
So, rename the variable holding the return type to 'rettype'
and only use 'fntype' for the one holding the full function type.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | evaluate.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -3450,13 +3450,14 @@ void evaluate_symbol_list(struct symbol_list *list) static struct symbol *evaluate_return_expression(struct statement *stmt) { struct expression *expr = stmt->expression; - struct symbol *fntype; + struct symbol *fntype, *rettype; evaluate_expression(expr); - fntype = current_fn->ctype.base_type; - if (!fntype || fntype == &void_ctype) { + fntype = current_fn; + rettype = fntype->ctype.base_type; + if (!rettype || rettype == &void_ctype) { if (expr && expr->ctype != &void_ctype) - expression_error(expr, "return expression in %s function", fntype?"void":"typeless"); + expression_error(expr, "return expression in %s function", rettype?"void":"typeless"); if (expr && Wreturn_void) warning(stmt->pos, "returning void-valued expression"); return NULL; @@ -3468,7 +3469,7 @@ static struct symbol *evaluate_return_expression(struct statement *stmt) } if (!expr->ctype) return NULL; - compatible_assignment_types(expr, fntype, &stmt->expression, "return expression"); + compatible_assignment_types(expr, rettype, &stmt->expression, "return expression"); return NULL; } |