From 52e28a6e0bce498a0db6da4f941d4cea9fc62b7e Mon Sep 17 00:00:00 2001 From: Andy Valencia Date: Sun, 17 Jul 2016 18:03:14 -0700 Subject: [PATCH] Issue 377: broken calling of function in expressions --- Applications/SmallC/.gitignore | 6 ++++++ Applications/SmallC/primary.c | 21 ++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 Applications/SmallC/.gitignore diff --git a/Applications/SmallC/.gitignore b/Applications/SmallC/.gitignore new file mode 100644 index 00000000..5d899c1a --- /dev/null +++ b/Applications/SmallC/.gitignore @@ -0,0 +1,6 @@ +copt +lscc6801 +lscc6809 +lscc8080 +lsccgeneric +lsccz80 diff --git a/Applications/SmallC/primary.c b/Applications/SmallC/primary.c index 3c802dda..1b443fe8 100644 --- a/Applications/SmallC/primary.c +++ b/Applications/SmallC/primary.c @@ -87,10 +87,13 @@ int primary(LVALUE *lval) { } return FETCH | reg; } - /* Globals and anything we can directly access */ + + /* Globals, function names */ + lval->symbol = symbol; + lval->indirect = 0; if (symbol->identity != FUNCTION) { - lval->symbol = symbol; - lval->indirect = 0; + + /* Globals and anything we can directly access */ if (symbol->type == STRUCT) { lval->tagsym = &tag_table[symbol->tagidx]; } @@ -102,17 +105,21 @@ int primary(LVALUE *lval) { return FETCH | HL_REG; } - if (symbol->storage == LSTATIC) + if (symbol->storage == LSTATIC) { gen_get_locale(symbol); - else { + } else { gen_immediate(); output_string(symbol->name); newline(); } lval->indirect = symbol->type; lval->ptr_type = symbol->type; - return 0; - } + } else { + + /* Function call */ + lval->ptr_type = symbol->type; + } + return 0; } lval->symbol = 0; lval->indirect = 0; -- 2.34.1