mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Improve error message for negative shift arguments
This commit is contained in:
@@ -130,9 +130,11 @@ uint32_t macro_UseNewUniqueID(void)
|
|||||||
|
|
||||||
void macro_ShiftCurrentArgs(int32_t count)
|
void macro_ShiftCurrentArgs(int32_t count)
|
||||||
{
|
{
|
||||||
if (!macroArgs)
|
if (!macroArgs) {
|
||||||
error("Cannot shift macro arguments outside of a macro\n");
|
error("Cannot shift macro arguments outside of a macro\n");
|
||||||
else if (macroArgs->shift < macroArgs->nbArgs) {
|
} else if (count < 0) {
|
||||||
|
error("Cannot shift arguments by negative amount %" PRId32 "\n", count);
|
||||||
|
} else if (macroArgs->shift < macroArgs->nbArgs) {
|
||||||
macroArgs->shift += count;
|
macroArgs->shift += count;
|
||||||
if (macroArgs->shift > macroArgs->nbArgs)
|
if (macroArgs->shift > macroArgs->nbArgs)
|
||||||
macroArgs->shift = macroArgs->nbArgs;
|
macroArgs->shift = macroArgs->nbArgs;
|
||||||
|
|||||||
@@ -580,7 +580,7 @@ assert : T_POP_ASSERT assert_type relocexpr
|
|||||||
;
|
;
|
||||||
|
|
||||||
shift : T_POP_SHIFT { macro_ShiftCurrentArgs(1); }
|
shift : T_POP_SHIFT { macro_ShiftCurrentArgs(1); }
|
||||||
| T_POP_SHIFT uconst { macro_ShiftCurrentArgs($2); }
|
| T_POP_SHIFT const { macro_ShiftCurrentArgs($2); }
|
||||||
;
|
;
|
||||||
|
|
||||||
load : T_POP_LOAD string ',' sectiontype sectorg sectattrs {
|
load : T_POP_LOAD string ',' sectiontype sectorg sectattrs {
|
||||||
|
|||||||
4
test/asm/shift-negative.asm
Normal file
4
test/asm/shift-negative.asm
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
m: MACRO
|
||||||
|
shift -3
|
||||||
|
ENDM
|
||||||
|
m
|
||||||
3
test/asm/shift-negative.err
Normal file
3
test/asm/shift-negative.err
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ERROR: shift-negative.asm(4) -> shift-negative.asm::m(2):
|
||||||
|
Cannot shift arguments by negative amount -3
|
||||||
|
error: Assembly aborted (1 errors)!
|
||||||
0
test/asm/shift-negative.out
Normal file
0
test/asm/shift-negative.out
Normal file
Reference in New Issue
Block a user