ref: 46a402f7d76dd90b668bc79c9d11b0f9f0c98e44
parent: e233c5d256dd42a77612e39c5c7160aa92b4a4d4
author: ISSOtm <[email protected]>
date: Sun Mar 22 06:46:26 EDT 2020
Prevent passing assertions that RGBASM passed to RGBLINK
--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -814,7 +814,11 @@
assert : T_POP_ASSERT assert_type relocexpr
{
- if (rpn_isKnown(&$3) && $3.nVal == 0) {
+ if (!rpn_isKnown(&$3)) {
+ if (!out_CreateAssert($2, &$3, ""))
+ yyerror("Assertion creation failed: %s",
+ strerror(errno));
+ } else if ($3.nVal == 0) {
switch ($2) {
case ASSERT_FATAL:
fatalerror("Assertion failed");
@@ -826,16 +830,16 @@
"Assertion failed");
break;
}
- } else {
- if (!out_CreateAssert($2, &$3, ""))
- yyerror("Assertion creation failed: %s",
- strerror(errno));
}
rpn_Free(&$3);
}
| T_POP_ASSERT assert_type relocexpr ',' string
{
- if (rpn_isKnown(&$3) && $3.nVal == 0) {
+ if (!rpn_isKnown(&$3)) {
+ if (!out_CreateAssert($2, &$3, $5))
+ yyerror("Assertion creation failed: %s",
+ strerror(errno));
+ } else if ($3.nVal == 0) {
switch ($2) {
case ASSERT_FATAL:
fatalerror("Assertion failed: %s",
@@ -850,10 +854,6 @@
$5);
break;
}
- } else {
- if (!out_CreateAssert($2, &$3, $5))
- yyerror("Assertion creation failed: %s",
- strerror(errno));
}
rpn_Free(&$3);
}
--- /dev/null
+++ b/test/asm/assert-const.asm
@@ -1,0 +1,7 @@
+; The following link-time assertion is known by RGBASM to be okay.
+; This previously caused it to still pass the assertion to RGBLINK with an empty
+; RPN expression
+
+SECTION "rgbasm passing asserts", ROM0[0]
+ db 0
+ assert @
--- /dev/null
+++ b/test/asm/assert-const.out.bin
@@ -1,0 +1,1 @@
+
\ No newline at end of file