aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/evaluate.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-05-07 17:46:04 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-05-21 17:27:45 +0200
commit62596fe4efb13a41cdc05b931792122f9d855d14 (patch)
tree459a4c1cbbe437dfec5bbd765f1bbb90cb83a7b0 /evaluate.c
parentefda1a044c7ce014f38c3225ec79b2befd0a0620 (diff)
downloadsparse-dev-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>
Diffstat (limited to 'evaluate.c')
-rw-r--r--evaluate.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/evaluate.c b/evaluate.c
index b7bb1f52..54cd5fa1 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -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;
}