From be00adb75743c0946a21464a388b6e6ca325ad0b Mon Sep 17 00:00:00 2001 From: cuz Date: Tue, 13 May 2003 19:10:32 +0000 Subject: [PATCH] Add a warning for an address expression that is usually the result of a typo and almost never used in this form. git-svn-id: svn://svn.cc65.org/cc65/trunk@2158 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/error.c | 1 + src/ca65/error.h | 1 + src/ca65/instr.c | 32 +++++++++++++++++++++++++++----- src/ca65/instr.h | 18 +++++++++--------- 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/ca65/error.c b/src/ca65/error.c index fc984268b..162080d7b 100644 --- a/src/ca65/error.c +++ b/src/ca65/error.c @@ -75,6 +75,7 @@ void WarningMsg (const FilePos* Pos, unsigned WarnNum, va_list ap) { 2, "Symbol `%s' is defined but never used" }, { 2, "Symbol `%s' is imported but never used" }, { 1, "Cannot track processor status byte" }, + { 1, "Suspicious address expression" }, { 0, "User warning: %s" }, }; diff --git a/src/ca65/error.h b/src/ca65/error.h index 665664531..ca7ef370e 100644 --- a/src/ca65/error.h +++ b/src/ca65/error.h @@ -55,6 +55,7 @@ enum Warnings { WARN_SYM_NOT_REFERENCED, WARN_IMPORT_NOT_REFERENCED, WARN_CANNOT_TRACK_STATUS, + WARN_SUSPICIOUS_ADDREXPR, WARN_USER, WARN_COUNT /* Warning count */ }; diff --git a/src/ca65/instr.c b/src/ca65/instr.c index 942650816..6cd78b62c 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -48,6 +48,7 @@ #include "global.h" #include "nexttok.h" #include "objcode.h" +#include "symtab.h" #include "instr.h" @@ -606,21 +607,42 @@ static void PutAll (const InsDesc* Ins) * modes. */ if (Expr && (AddrModeSet & AM_ZP) && !IsByteExpr (Expr)) { - AddrModeSet &= ~AM_ZP; + AddrModeSet &= ~AM_ZP; } /* Check if we have any adressing modes left */ if (AddrModeSet == 0) { - Error (ERR_ILLEGAL_ADDR_MODE); - return; + Error (ERR_ILLEGAL_ADDR_MODE); + return; } AddrMode = BitFind (AddrModeSet); + /* If the instruction has a one byte operand and immediate addressing is + * allowed but not used, check for an operand expression in the form + *