mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-22 03:02:06 +00:00
Add more tests for RGBASM code coverage (#1257)
* Add more tests for RGBASM code coverage * Use C++ unnamed parameters, not `(void)` casting * Fix crash in `sect_AlignPC` from #1253
This commit is contained in:
@@ -130,9 +130,8 @@ void out_RegisterNode(struct FileStackNode *node)
|
||||
}
|
||||
}
|
||||
|
||||
void out_ReplaceNode(struct FileStackNode *node)
|
||||
void out_ReplaceNode(struct FileStackNode * /* node */)
|
||||
{
|
||||
(void)node;
|
||||
#if 0
|
||||
This is code intended to replace a node, which is pretty useless until ref counting is added...
|
||||
|
||||
@@ -469,10 +468,8 @@ static void writeFileStackNode(struct FileStackNode const *node, FILE *f)
|
||||
}
|
||||
}
|
||||
|
||||
static void registerUnregisteredSymbol(struct Symbol *symbol, void *arg)
|
||||
static void registerUnregisteredSymbol(struct Symbol *symbol, void *)
|
||||
{
|
||||
(void)arg; // sym_ForEach requires a void* parameter, but we are not using it.
|
||||
|
||||
// Check for symbol->src, to skip any built-in symbol from rgbasm
|
||||
if (symbol->src && symbol->ID == (uint32_t)-1) {
|
||||
registerSymbol(symbol);
|
||||
|
||||
@@ -1021,6 +1021,7 @@ align : T_OP_ALIGN align_spec { sect_AlignPC($2.alignment, $2.alignOfs); }
|
||||
align_spec : uconst {
|
||||
if ($1 > 16) {
|
||||
error("Alignment must be between 0 and 16, not %u\n", $1);
|
||||
$$.alignment = $$.alignOfs = 0;
|
||||
} else {
|
||||
$$.alignment = $1;
|
||||
$$.alignOfs = 0;
|
||||
@@ -1029,10 +1030,12 @@ align_spec : uconst {
|
||||
| uconst T_COMMA const {
|
||||
if ($1 > 16) {
|
||||
error("Alignment must be between 0 and 16, not %u\n", $1);
|
||||
$$.alignment = $$.alignOfs = 0;
|
||||
} else if ($3 <= -(1 << $1) || $3 >= 1 << $1) {
|
||||
error("The absolute alignment offset (%" PRIu32
|
||||
") must be less than alignment size (%d)\n",
|
||||
(uint32_t)($3 < 0 ? -$3 : $3), 1 << $1);
|
||||
$$.alignment = $$.alignOfs = 0;
|
||||
} else {
|
||||
$$.alignment = $1;
|
||||
$$.alignOfs = $3 < 0 ? (1 << $1) + $3 : $3;
|
||||
|
||||
@@ -512,10 +512,7 @@ void rpn_BinaryOp(enum RPNCommand op, struct Expression *expr,
|
||||
if (src2->val < 0)
|
||||
fatalerror("Exponentiation by negative power\n");
|
||||
|
||||
if (src1->val == INT32_MIN && src2->val == -1)
|
||||
expr->val = 0;
|
||||
else
|
||||
expr->val = op_exponent(src1->val, src2->val);
|
||||
expr->val = op_exponent(src1->val, src2->val);
|
||||
break;
|
||||
|
||||
case RPN_NEG:
|
||||
|
||||
@@ -167,10 +167,9 @@ static unsigned int mergeSectUnion(struct Section *sect, enum SectionType type,
|
||||
return nbSectErrors;
|
||||
}
|
||||
|
||||
static unsigned int mergeFragments(struct Section *sect, enum SectionType type, uint32_t org,
|
||||
uint8_t alignment, uint16_t alignOffset)
|
||||
static unsigned int mergeFragments(struct Section *sect, uint32_t org, uint8_t alignment,
|
||||
uint16_t alignOffset)
|
||||
{
|
||||
(void)type;
|
||||
assert(alignment < 16); // Should be ensured by the caller
|
||||
unsigned int nbSectErrors = 0;
|
||||
|
||||
@@ -183,8 +182,7 @@ static unsigned int mergeFragments(struct Section *sect, enum SectionType type,
|
||||
// If both are fixed, they must be the same
|
||||
if (sect->org != (uint32_t)-1 && sect->org != curOrg)
|
||||
fail("Section already declared as fixed at incompatible address $%04"
|
||||
PRIx32 " (cur addr = %04" PRIx32 ")\n",
|
||||
sect->org, sect->org + sect->size);
|
||||
PRIx32 "\n", sect->org);
|
||||
else if (sect->align != 0 && (mask(sect->align) & (curOrg - sect->alignOfs)))
|
||||
fail("Section already declared as aligned to %u bytes (offset %"
|
||||
PRIu16 ")\n", 1U << sect->align, sect->alignOfs);
|
||||
@@ -232,8 +230,9 @@ static void mergeSections(struct Section *sect, enum SectionType type, uint32_t
|
||||
switch (mod) {
|
||||
case SECTION_UNION:
|
||||
case SECTION_FRAGMENT:
|
||||
nbSectErrors += (mod == SECTION_UNION ? mergeSectUnion : mergeFragments)
|
||||
(sect, type, org, alignment, alignOffset);
|
||||
nbSectErrors += mod == SECTION_UNION ?
|
||||
mergeSectUnion(sect, type, org, alignment, alignOffset) :
|
||||
mergeFragments(sect, org, alignment, alignOffset);
|
||||
|
||||
// Common checks
|
||||
|
||||
@@ -499,7 +498,7 @@ void sect_AlignPC(uint8_t alignment, uint16_t offset)
|
||||
return;
|
||||
|
||||
struct Section *sect = sect_GetSymbolSection();
|
||||
uint16_t alignSize = 1 << alignment; // Size of an aligned "block"
|
||||
uint32_t alignSize = 1 << alignment; // Size of an aligned "block"
|
||||
|
||||
if (sect->org != (uint32_t)-1) {
|
||||
if ((sect->org + curOffset - offset) % alignSize)
|
||||
|
||||
Reference in New Issue
Block a user