Explicit z: should suppress "Suspicious address expression" warning #194

This commit is contained in:
bbbradsmith 2023-05-03 01:01:21 -04:00
parent 805e98a7aa
commit 65f773f5ee
3 changed files with 9 additions and 1 deletions

View File

@ -43,6 +43,10 @@
/*****************************************************************************/
/* EffAddr Flags */
#define EFFADDR_OVERRIDE_ZP 0x00000001UL
/* GetEA result struct */
typedef struct EffAddr EffAddr;
@ -51,6 +55,7 @@ struct EffAddr {
unsigned long AddrModeSet; /* Possible addressing modes */
struct ExprNode* Expr; /* Expression if any (NULL otherwise) */
unsigned Reg; /* Register number in sweet16 mode */
unsigned long Flags; /* Other properties */
/* The following fields are used inside instr.c */
unsigned AddrMode; /* Actual addressing mode used */

View File

@ -72,11 +72,13 @@ void GetEA (EffAddr* A)
/* Clear the output struct */
A->AddrModeSet = 0;
A->Expr = 0;
A->Flags = 0;
/* Handle an addressing size override */
switch (CurTok.Tok) {
case TOK_OVERRIDE_ZP:
Restrictions = AM65_DIR | AM65_DIR_X | AM65_DIR_Y;
A->Flags |= EFFADDR_OVERRIDE_ZP;
NextTok ();
break;

View File

@ -1269,7 +1269,8 @@ static int EvalEA (const InsDesc* Ins, EffAddr* A)
ExprNode* Left = A->Expr->Left;
if ((A->Expr->Op == EXPR_BYTE0 || A->Expr->Op == EXPR_BYTE1) &&
Left->Op == EXPR_SYMBOL &&
GetSymAddrSize (Left->V.Sym) != ADDR_SIZE_ZP) {
GetSymAddrSize (Left->V.Sym) != ADDR_SIZE_ZP &&
!(A->Flags & EFFADDR_OVERRIDE_ZP)) {
/* Output a warning */
Warning (1, "Suspicious address expression");