From 4407d49d66a9b6a44f0d24ba4944d2e6815eca74 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 11 May 2002 01:50:11 +0000 Subject: [PATCH] During the first pass of basic optimization, continue reporting errors, don't stop at the first error. To help prevent spurios errors, make bytecodes with errors 0 length in bc_resolve(). svn path=/trunk/yasm/; revision=621 --- libyasm/bytecode.c | 4 ++++ modules/optimizers/basic/basic-optimizer.c | 8 +++++++- src/bytecode.c | 4 ++++ src/optimizers/basic/basic-optimizer.c | 8 +++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/libyasm/bytecode.c b/libyasm/bytecode.c index 261b4913..b17448cc 100644 --- a/libyasm/bytecode.c +++ b/libyasm/bytecode.c @@ -493,6 +493,10 @@ bc_resolve(bytecode *bc, int save, const section *sect, expr_delete(temp); } + /* If we got an error somewhere along the line, clear out any calc len */ + if (retval < 0) + bc->len = 0; + return retval; } diff --git a/modules/optimizers/basic/basic-optimizer.c b/modules/optimizers/basic/basic-optimizer.c index 52336a24..a7bb9a88 100644 --- a/modules/optimizers/basic/basic-optimizer.c +++ b/modules/optimizers/basic/basic-optimizer.c @@ -143,6 +143,7 @@ basic_optimize_resolve_label_2(symrec *sym, int withstart) typedef struct basic_optimize_data { /*@observer@*/ bytecode *precbc; /*@observer@*/ const section *sect; + int saw_unknown; } basic_optimize_data; static int @@ -170,7 +171,8 @@ basic_optimize_bytecode_1(/*@observer@*/ bytecode *bc, void *d) */ if (bc_resolve(bc, 0, data->sect, basic_optimize_resolve_label) < 0) { ErrorAt(bc->line, _("Circular reference detected.")); - return -1; + data->saw_unknown = -1; + return 0; } bc->opt_flags = BCFLAG_DONE; @@ -187,6 +189,7 @@ basic_optimize_section_1(section *sect, /*@unused@*/ /*@null@*/ void *d) data.precbc = NULL; data.sect = sect; + data.saw_unknown = 0; /* Don't even bother if we're in-progress or done. */ flags = section_get_opt_flags(sect); @@ -202,6 +205,9 @@ basic_optimize_section_1(section *sect, /*@unused@*/ /*@null@*/ void *d) if (retval != 0) return retval; + if (data.saw_unknown != 0) + return data.saw_unknown; + section_set_opt_flags(sect, SECTFLAG_DONE); return 0; diff --git a/src/bytecode.c b/src/bytecode.c index 261b4913..b17448cc 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -493,6 +493,10 @@ bc_resolve(bytecode *bc, int save, const section *sect, expr_delete(temp); } + /* If we got an error somewhere along the line, clear out any calc len */ + if (retval < 0) + bc->len = 0; + return retval; } diff --git a/src/optimizers/basic/basic-optimizer.c b/src/optimizers/basic/basic-optimizer.c index 52336a24..a7bb9a88 100644 --- a/src/optimizers/basic/basic-optimizer.c +++ b/src/optimizers/basic/basic-optimizer.c @@ -143,6 +143,7 @@ basic_optimize_resolve_label_2(symrec *sym, int withstart) typedef struct basic_optimize_data { /*@observer@*/ bytecode *precbc; /*@observer@*/ const section *sect; + int saw_unknown; } basic_optimize_data; static int @@ -170,7 +171,8 @@ basic_optimize_bytecode_1(/*@observer@*/ bytecode *bc, void *d) */ if (bc_resolve(bc, 0, data->sect, basic_optimize_resolve_label) < 0) { ErrorAt(bc->line, _("Circular reference detected.")); - return -1; + data->saw_unknown = -1; + return 0; } bc->opt_flags = BCFLAG_DONE; @@ -187,6 +189,7 @@ basic_optimize_section_1(section *sect, /*@unused@*/ /*@null@*/ void *d) data.precbc = NULL; data.sect = sect; + data.saw_unknown = 0; /* Don't even bother if we're in-progress or done. */ flags = section_get_opt_flags(sect); @@ -202,6 +205,9 @@ basic_optimize_section_1(section *sect, /*@unused@*/ /*@null@*/ void *d) if (retval != 0) return retval; + if (data.saw_unknown != 0) + return data.saw_unknown; + section_set_opt_flags(sect, SECTFLAG_DONE); return 0; -- 2.40.0