diff --git a/decl.cpp b/decl.cpp index 0c613739..67ed419d 100644 --- a/decl.cpp +++ b/decl.cpp @@ -492,15 +492,19 @@ Declaration::GetVariableDeclarations() const { if (declarators[i] == NULL) continue; Declarator *decl = declarators[i]; - if (decl == NULL || decl->kind == DK_FUNCTION) - // Ignore earlier errors or external function declarations - // inside other functions. + if (decl == NULL) + // Ignore earlier errors continue; Symbol *sym = decl->GetSymbol(); - m->symbolTable->AddVariable(sym); - - vars.push_back(VariableDeclaration(sym, decl->initExpr)); + if (dynamic_cast(sym->type) != NULL) { + // function declaration + m->symbolTable->AddFunction(sym); + } + else { + m->symbolTable->AddVariable(sym); + vars.push_back(VariableDeclaration(sym, decl->initExpr)); + } } return vars; }