Skip to content

Commit

Permalink
fix undefined symbol err report
Browse files Browse the repository at this point in the history
  • Loading branch information
mseminatore committed Jun 11, 2024
1 parent 0a97552 commit 9e7c4a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion as09.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// constant decls
//-----------------
#define APP_NAME "as09"
#define APP_VER "0.5.1"
#define APP_VER "0.5.2"

#define DONE 0

Expand Down Expand Up @@ -114,6 +114,7 @@ typedef enum
typedef struct
{
const char *name;
const char *filename; // file where symbols was defined
int type;
int value;
int lineno; // local file line number
Expand Down
5 changes: 3 additions & 2 deletions as09.tab.c
Original file line number Diff line number Diff line change
Expand Up @@ -4427,7 +4427,7 @@ void apply_fixups()
// check that the symbols was defined
if (symbols[f.symbol].type == ST_UNDEF)
{
fprintf(stderr, "ERROR: undefined symbol '%s' in file %s, line %d\n", symbols[f.symbol].name, CURRENT_FILE, symbols[f.symbol].lineno);
fprintf(stderr, "ERROR: undefined symbol '%s' in file %s, line %d\n", symbols[f.symbol].name, symbols[f.symbol].filename, symbols[f.symbol].lineno);
err_count++;
continue;
}
Expand Down Expand Up @@ -4504,7 +4504,8 @@ int add_symbol(const char *name, int lineno)
return -1;

symbols[symbol_count].name = strdup(name);
symbols[symbol_count].lineno = lineno;
symbols[symbol_count].lineno = CURRENT_LINENO;
symbols[symbol_count].filename = strdup(CURRENT_FILE);
symbols[symbol_count].type = ST_UNDEF;
symbols[symbol_count].value = -1;
symbols[symbol_count].refd = 0;
Expand Down
5 changes: 3 additions & 2 deletions as09.y
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ void apply_fixups()
// check that the symbols was defined
if (symbols[f.symbol].type == ST_UNDEF)
{
fprintf(stderr, "ERROR: undefined symbol '%s' in file %s, line %d\n", symbols[f.symbol].name, CURRENT_FILE, symbols[f.symbol].lineno);
fprintf(stderr, "ERROR: undefined symbol '%s' in file %s, line %d\n", symbols[f.symbol].name, symbols[f.symbol].filename, symbols[f.symbol].lineno);
err_count++;
continue;
}
Expand Down Expand Up @@ -1276,7 +1276,8 @@ int add_symbol(const char *name, int lineno)
return -1;

symbols[symbol_count].name = strdup(name);
symbols[symbol_count].lineno = lineno;
symbols[symbol_count].lineno = CURRENT_LINENO;
symbols[symbol_count].filename = strdup(CURRENT_FILE);
symbols[symbol_count].type = ST_UNDEF;
symbols[symbol_count].value = -1;
symbols[symbol_count].refd = 0;
Expand Down

0 comments on commit 9e7c4a4

Please sign in to comment.