From 46a402f7d76dd90b668bc79c9d11b0f9f0c98e44 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Sun, 22 Mar 2020 10:46:26 +0100 Subject: [PATCH] Prevent passing assertions that RGBASM passed to RGBLINK --- src/asm/asmy.y | 20 ++++++++++---------- test/asm/assert-const.asm | 7 +++++++ test/asm/assert-const.err | 0 test/asm/assert-const.out | 0 test/asm/assert-const.out.bin | Bin 0 -> 1 bytes 5 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 test/asm/assert-const.asm create mode 100644 test/asm/assert-const.err create mode 100644 test/asm/assert-const.out create mode 100644 test/asm/assert-const.out.bin diff --git a/src/asm/asmy.y b/src/asm/asmy.y index abc47825..3200ffd0 100644 --- a/src/asm/asmy.y +++ b/src/asm/asmy.y @@ -814,7 +814,11 @@ assert_type : /* empty */ { $$ = ASSERT_ERROR; } 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 @@ assert : T_POP_ASSERT assert_type relocexpr "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 @@ assert : T_POP_ASSERT assert_type relocexpr $5); break; } - } else { - if (!out_CreateAssert($2, &$3, $5)) - yyerror("Assertion creation failed: %s", - strerror(errno)); } rpn_Free(&$3); } diff --git a/test/asm/assert-const.asm b/test/asm/assert-const.asm new file mode 100644 index 00000000..f86d93e9 --- /dev/null +++ b/test/asm/assert-const.asm @@ -0,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 @ diff --git a/test/asm/assert-const.err b/test/asm/assert-const.err new file mode 100644 index 00000000..e69de29b diff --git a/test/asm/assert-const.out b/test/asm/assert-const.out new file mode 100644 index 00000000..e69de29b diff --git a/test/asm/assert-const.out.bin b/test/asm/assert-const.out.bin new file mode 100644 index 0000000000000000000000000000000000000000..f76dd238ade08917e6712764a16a22005a50573d GIT binary patch literal 1 IcmZPo000310RR91 literal 0 HcmV?d00001