aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-04-21 03:46:21 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-05-21 17:27:45 +0200
commit154278d4e26d9d48fbb5f2668533a4c4e598b564 (patch)
treea4eb234ac76e0c0ee817edbb5c2d5fe4dec97870
parent62596fe4efb13a41cdc05b931792122f9d855d14 (diff)
downloadsparse-154278d4e26d9d48fbb5f2668533a4c4e598b564.tar.gz
misc: always use the node for current_fn
At evaluation time and at expansion time, current_fn is set to the function's base type (SYM_FN) but at parse time it's set to its parent type (SYM_NODE). Since current_fn is used to access the corresponding ident, it should be set to the node type, not the base. So, always set current_fn to the node type. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--evaluate.c4
-rw-r--r--expand.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/evaluate.c b/evaluate.c
index 54cd5fa1..c18ae81d 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -3422,7 +3422,7 @@ static struct symbol *evaluate_symbol(struct symbol *sym)
if (sym->definition && sym->definition != sym)
return evaluate_symbol(sym->definition);
- current_fn = base_type;
+ current_fn = sym;
examine_fn_arguments(base_type);
if (!base_type->stmt && base_type->inline_stmt)
@@ -3453,7 +3453,7 @@ static struct symbol *evaluate_return_expression(struct statement *stmt)
struct symbol *fntype, *rettype;
evaluate_expression(expr);
- fntype = current_fn;
+ fntype = current_fn->ctype.base_type;
rettype = fntype->ctype.base_type;
if (!rettype || rettype == &void_ctype) {
if (expr && expr->ctype != &void_ctype)
diff --git a/expand.c b/expand.c
index e7559878..ab296c73 100644
--- a/expand.c
+++ b/expand.c
@@ -918,7 +918,7 @@ static int expand_symbol_call(struct expression *expr, int cost)
struct symbol *fn = def->ctype.base_type;
struct symbol *curr = current_fn;
- current_fn = fn;
+ current_fn = def;
evaluate_statement(expr->statement);
current_fn = curr;