mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-22 03:02:06 +00:00
Fix segfaults when using PC outside a section
This commit is contained in:
@@ -106,7 +106,10 @@ void rpn_Symbol(struct Expression *expr, char *tzSym)
|
|||||||
{
|
{
|
||||||
struct sSymbol *sym = sym_FindSymbol(tzSym);
|
struct sSymbol *sym = sym_FindSymbol(tzSym);
|
||||||
|
|
||||||
if (!sym || !sym_IsConstant(sym)) {
|
if (sym == pPCSymbol && !pPCSymbol->pSection) {
|
||||||
|
yyerror("PC has no value outside a section");
|
||||||
|
rpn_Number(expr, 0);
|
||||||
|
} else if (!sym || !sym_IsConstant(sym)) {
|
||||||
rpn_Init(expr);
|
rpn_Init(expr);
|
||||||
expr->isSymbol = true;
|
expr->isSymbol = true;
|
||||||
|
|
||||||
|
|||||||
@@ -230,7 +230,9 @@ uint32_t sym_GetConstantValue(char const *s)
|
|||||||
struct sSymbol const *psym = sym_FindSymbol(s);
|
struct sSymbol const *psym = sym_FindSymbol(s);
|
||||||
|
|
||||||
if (psym == pPCSymbol) {
|
if (psym == pPCSymbol) {
|
||||||
if (pCurrentSection->nOrg == -1)
|
if (!pCurrentSection)
|
||||||
|
yyerror("PC has no value outside a section");
|
||||||
|
else if (pCurrentSection->nOrg == -1)
|
||||||
yyerror("Expected constant PC but section is not fixed");
|
yyerror("Expected constant PC but section is not fixed");
|
||||||
else
|
else
|
||||||
return sym_GetValue(psym);
|
return sym_GetValue(psym);
|
||||||
|
|||||||
1
test/asm/assert@-no-sect.asm
Normal file
1
test/asm/assert@-no-sect.asm
Normal file
@@ -0,0 +1 @@
|
|||||||
|
assert @ || 1
|
||||||
3
test/asm/assert@-no-sect.err
Normal file
3
test/asm/assert@-no-sect.err
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ERROR: assert@-no-sect.asm(1):
|
||||||
|
PC has no value outside a section
|
||||||
|
error: Assembly aborted (1 errors)!
|
||||||
0
test/asm/assert@-no-sect.out
Normal file
0
test/asm/assert@-no-sect.out
Normal file
2
test/asm/if@-no-sect.asm
Normal file
2
test/asm/if@-no-sect.asm
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
if {@}
|
||||||
|
endc
|
||||||
3
test/asm/if@-no-sect.err
Normal file
3
test/asm/if@-no-sect.err
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ERROR: if@-no-sect.asm(1):
|
||||||
|
PC has no value outside a section
|
||||||
|
error: Assembly aborted (1 errors)!
|
||||||
0
test/asm/if@-no-sect.out
Normal file
0
test/asm/if@-no-sect.out
Normal file
Reference in New Issue
Block a user