]> granicus.if.org Git - yasm/commitdiff
Fix #98. Fix implemented by merging any reserve multiple into the main
authorPeter Johnson <peter@tortall.net>
Sun, 4 Feb 2007 00:41:42 +0000 (00:41 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 4 Feb 2007 00:41:42 +0000 (00:41 -0000)
bytecode multiple.

strucsize.asm tests both creation and instantiation of a nested structure.
[1751] and [1752] fix bugs found during the testing of the instantiation
portion of this testcase.

A side effect of this change is that some errors are found in different
phases, and the error messages are slightly different.  Split
reserve-error.asm testcase into two parts to still get full coverage.

svn path=/trunk/yasm/; revision=1753

12 files changed:
libyasm/bc-reserve.c
libyasm/tests/Makefile.inc
libyasm/tests/reserve-err1.asm [moved from modules/objfmts/bin/tests/reserve-err.asm with 100% similarity]
libyasm/tests/reserve-err1.errwarn [new file with mode: 0644]
libyasm/tests/reserve-err2.asm [new file with mode: 0644]
libyasm/tests/reserve-err2.errwarn [moved from modules/objfmts/bin/tests/reserve-err.errwarn with 74% similarity]
libyasm/tests/strucsize.asm [new file with mode: 0644]
libyasm/tests/strucsize.hex [new file with mode: 0644]
libyasm/tests/times-res.asm [new file with mode: 0644]
libyasm/tests/times-res.errwarn [new file with mode: 0644]
libyasm/tests/times-res.hex [new file with mode: 0644]
modules/objfmts/bin/tests/Makefile.inc

index 86be7b86b09f509ca638e4247a6db3e450f96adb..c8ec7aa0098622d8e0a15002b36f99bbaa019cb8 100644 (file)
@@ -90,18 +90,13 @@ static void
 bc_reserve_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc)
 {
     bytecode_reserve *reserve = (bytecode_reserve *)bc->contents;
-    yasm_value val;
-
-    if (yasm_value_finalize_expr(&val, reserve->numitems, prev_bc, 0))
-       yasm_error_set(YASM_ERROR_TOO_COMPLEX,
-                      N_("reserve expression too complex"));
-    else if (val.rel)
-       yasm_error_set(YASM_ERROR_NOT_ABSOLUTE,
-                      N_("reserve expression not absolute"));
-    else if (val.abs && yasm_expr__contains(val.abs, YASM_EXPR_FLOAT))
-       yasm_error_set(YASM_ERROR_VALUE,
-                      N_("expression must not contain floating point value"));
-    reserve->numitems = val.abs;
+    /* multiply reserve expression into multiple */
+    if (!bc->multiple)
+       bc->multiple = reserve->numitems;
+    else
+       bc->multiple = yasm_expr_create_tree(bc->multiple, YASM_EXPR_MUL,
+                                            reserve->numitems, bc->line);
+    reserve->numitems = NULL;
 }
 
 static int
@@ -109,27 +104,7 @@ bc_reserve_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span,
                    void *add_span_data)
 {
     bytecode_reserve *reserve = (bytecode_reserve *)bc->contents;
-    /*@dependent@*/ /*@null@*/ const yasm_intnum *num;
-
-    if (!reserve->numitems)
-       return 0;
-
-    num = yasm_expr_get_intnum(&reserve->numitems, 0);
-    if (!num) {
-       /* Check for use of floats first. */
-       if (reserve->numitems &&
-           yasm_expr__contains(reserve->numitems, YASM_EXPR_FLOAT)) {
-           yasm_error_set(YASM_ERROR_VALUE,
-               N_("expression must not contain floating point value"));
-           return -1;
-       }
-       /* FIXME: Non-constant currently not allowed. */
-       yasm_error_set(YASM_ERROR_NOT_CONSTANT,
-                      N_("attempt to reserve non-constant quantity of space"));
-       return -1;
-    }
-    
-    bc->len += yasm_intnum_get_uint(num)*reserve->itemsize;
+    bc->len += reserve->itemsize;
     return 0;
 }
 
index 13431f42cf5d1ac2e7d48de451841aa325df7eb7..1528ef68fe4daefdf4f16ee0ae2397bff5c59e01 100644 (file)
@@ -54,10 +54,21 @@ EXTRA_DIST += libyasm/tests/opt-oldalign.asm
 EXTRA_DIST += libyasm/tests/opt-oldalign.hex
 EXTRA_DIST += libyasm/tests/opt-struc.asm
 EXTRA_DIST += libyasm/tests/opt-struc.hex
+EXTRA_DIST += libyasm/tests/reserve-err1.asm
+EXTRA_DIST += libyasm/tests/reserve-err1.errwarn
+EXTRA_DIST += libyasm/tests/reserve-err2.asm
+EXTRA_DIST += libyasm/tests/reserve-err2.errwarn
+EXTRA_DIST += libyasm/tests/strucsize.asm
+EXTRA_DIST += libyasm/tests/strucsize.hex
+EXTRA_DIST += libyasm/tests/times0.asm
+EXTRA_DIST += libyasm/tests/times0.hex
 EXTRA_DIST += libyasm/tests/timesover-err.asm
 EXTRA_DIST += libyasm/tests/timesover-err.errwarn
 EXTRA_DIST += libyasm/tests/timesunder.asm
 EXTRA_DIST += libyasm/tests/timesunder.hex
+EXTRA_DIST += libyasm/tests/times-res.asm
+EXTRA_DIST += libyasm/tests/times-res.errwarn
+EXTRA_DIST += libyasm/tests/times-res.hex
 EXTRA_DIST += libyasm/tests/unary.asm
 EXTRA_DIST += libyasm/tests/unary.hex
 EXTRA_DIST += libyasm/tests/value-err.asm
diff --git a/libyasm/tests/reserve-err1.errwarn b/libyasm/tests/reserve-err1.errwarn
new file mode 100644 (file)
index 0000000..e3da650
--- /dev/null
@@ -0,0 +1,2 @@
+-:7: multiple expression not absolute
+-:14: multiple expression not absolute
diff --git a/libyasm/tests/reserve-err2.asm b/libyasm/tests/reserve-err2.asm
new file mode 100644 (file)
index 0000000..190f66b
--- /dev/null
@@ -0,0 +1,15 @@
+; Test res* family errors
+a:
+resb -5
+resw 1.2
+resd -1.2
+resq 0xffffffff
+;rest a
+
+[section .bss]
+resb -5
+resw 1.2
+resd -1.2
+resq 0xffffffff
+;rest a
+
similarity index 74%
rename from modules/objfmts/bin/tests/reserve-err.errwarn
rename to libyasm/tests/reserve-err2.errwarn
index 814b3a3e9a99493d7fd644e5998d9f58f7047929..44c5efa984538d561043237367da28f7704724d7 100644 (file)
@@ -1,6 +1,6 @@
+-:3: multiple is negative
 -:4: expression must not contain floating point value
 -:5: expression must not contain floating point value
--:7: reserve expression not absolute
+-:10: multiple is negative
 -:11: expression must not contain floating point value
 -:12: expression must not contain floating point value
--:14: reserve expression not absolute
diff --git a/libyasm/tests/strucsize.asm b/libyasm/tests/strucsize.asm
new file mode 100644 (file)
index 0000000..5f5fc24
--- /dev/null
@@ -0,0 +1,23 @@
+struc TST1
+    .a resd 2
+endstruc
+
+struc TST2
+    .b resb TST1_size
+endstruc
+
+tst2:
+istruc TST2
+at TST2.b
+
+       istruc TST1
+
+       at TST1.a
+               dd 1, 2
+
+       iend
+
+iend
+
+dw TST1_size
+dw TST2_size
diff --git a/libyasm/tests/strucsize.hex b/libyasm/tests/strucsize.hex
new file mode 100644 (file)
index 0000000..448779e
--- /dev/null
@@ -0,0 +1,12 @@
+01 
+00 
+00 
+00 
+02 
+00 
+00 
+00 
+08 
+00 
+08 
+00 
diff --git a/libyasm/tests/times-res.asm b/libyasm/tests/times-res.asm
new file mode 100644 (file)
index 0000000..307a826
--- /dev/null
@@ -0,0 +1,3 @@
+times 5 resb 4
+times 0 resb 2
+times 1 resb 0
diff --git a/libyasm/tests/times-res.errwarn b/libyasm/tests/times-res.errwarn
new file mode 100644 (file)
index 0000000..ceb76cf
--- /dev/null
@@ -0,0 +1 @@
+-:1: warning: uninitialized space declared in code/data section: zeroing
diff --git a/libyasm/tests/times-res.hex b/libyasm/tests/times-res.hex
new file mode 100644 (file)
index 0000000..b1c8b27
--- /dev/null
@@ -0,0 +1,20 @@
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
+00 
index 368831df427bfea1128951be80e0d71b747681b8..70070b005602144aef11b6fb31060b4744083ccf 100644 (file)
@@ -26,7 +26,5 @@ EXTRA_DIST += modules/objfmts/bin/tests/levelop.hex
 EXTRA_DIST += modules/objfmts/bin/tests/reserve.asm
 EXTRA_DIST += modules/objfmts/bin/tests/reserve.hex
 EXTRA_DIST += modules/objfmts/bin/tests/reserve.errwarn
-EXTRA_DIST += modules/objfmts/bin/tests/reserve-err.asm
-EXTRA_DIST += modules/objfmts/bin/tests/reserve-err.errwarn
 EXTRA_DIST += modules/objfmts/bin/tests/shr.asm
 EXTRA_DIST += modules/objfmts/bin/tests/shr.hex