diff options
author | Peter Johnson <peter@tortall.net> | 2008-09-30 03:56:37 +0000 |
---|---|---|
committer | Peter Johnson <peter@tortall.net> | 2008-09-30 03:56:37 +0000 |
commit | 457170f54ef06c79df5d64a60ba267b03ecd9b48 (patch) | |
tree | 80ddc49506b9a02b4f490092e4dd7d2901967f59 /libyasm | |
parent | 1b1c9ba0ad674c47292137a8f2519d97a0f0a964 (diff) | |
download | yasm-457170f54ef06c79df5d64a60ba267b03ecd9b48.tar.gz |
Fix expr simplification bug.
If an expression of the form INT+(a+b)+INT was simplified, constant folding
would combine the ints, but then the level stage (to make INT+a+b) would
start reading from the second (deleted due to folding) INT rather than the
new end of the expression.
Reported by: Samuel Thibault (on yasm-devel@)
svn path=/trunk/yasm/; revision=2123
Diffstat (limited to 'libyasm')
-rw-r--r-- | libyasm/expr.c | 2 | ||||
-rw-r--r-- | libyasm/tests/Makefile.inc | 2 | ||||
-rw-r--r-- | libyasm/tests/expr-fold-level.asm | 4 | ||||
-rw-r--r-- | libyasm/tests/expr-fold-level.hex | 4 |
4 files changed, 11 insertions, 1 deletions
diff --git a/libyasm/expr.c b/libyasm/expr.c index 14a52264..20e52473 100644 --- a/libyasm/expr.c +++ b/libyasm/expr.c @@ -741,7 +741,7 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const, * ordering as was present originally. * Combine integer terms as necessary. */ - for (i=e->numterms-1, o=level_numterms-1; i>=0; i--) { + for (i=fold_numterms-1, o=level_numterms-1; i>=0; i--) { if (e->terms[i].type == YASM_EXPR_EXPR && e->terms[i].data.expn->op == e->op) { /* bring up subexpression */ diff --git a/libyasm/tests/Makefile.inc b/libyasm/tests/Makefile.inc index ad65464a..23f422bf 100644 --- a/libyasm/tests/Makefile.inc +++ b/libyasm/tests/Makefile.inc @@ -23,6 +23,8 @@ EXTRA_DIST += libyasm/tests/emptydata.asm EXTRA_DIST += libyasm/tests/emptydata.hex EXTRA_DIST += libyasm/tests/equ-expand.asm EXTRA_DIST += libyasm/tests/equ-expand.hex +EXTRA_DIST += libyasm/tests/expr-fold-level.asm +EXTRA_DIST += libyasm/tests/expr-fold-level.hex EXTRA_DIST += libyasm/tests/expr-wide-ident.asm EXTRA_DIST += libyasm/tests/expr-wide-ident.hex EXTRA_DIST += libyasm/tests/externdef.asm diff --git a/libyasm/tests/expr-fold-level.asm b/libyasm/tests/expr-fold-level.asm new file mode 100644 index 00000000..814a62c5 --- /dev/null +++ b/libyasm/tests/expr-fold-level.asm @@ -0,0 +1,4 @@ +begin +A equ 09000h +a dd (A+(end-begin)+3) +end diff --git a/libyasm/tests/expr-fold-level.hex b/libyasm/tests/expr-fold-level.hex new file mode 100644 index 00000000..aba10f6d --- /dev/null +++ b/libyasm/tests/expr-fold-level.hex @@ -0,0 +1,4 @@ +07 +90 +00 +00 |