diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2016-05-09 12:05:56 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2016-05-09 12:05:56 -0700 |
commit | 69550eac55056ab1fac7bdc1b01da0e68418cd6f (patch) | |
tree | a43485c755aff0b816410d76dbe6c4295419feee | |
parent | 934f0478d409bced70ba1660512d4839cd76c571 (diff) | |
download | nasm-69550eac55056ab1fac7bdc1b01da0e68418cd6f.tar.gz |
Specifically if we encounter the PTR keyword
Issue a specific suppressible warning if we encounter the PTR keyword.
This usually indicates someone mistakenly using MASM syntax in NASM.
This introduces a generic infrastructure for issuing warnings for such
keywords.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | nasm.c | 2 | ||||
-rw-r--r-- | nasm.h | 1 | ||||
-rw-r--r-- | nasmlib.h | 3 | ||||
-rw-r--r-- | stdscan.c | 7 | ||||
-rw-r--r-- | test/ptr.asm | 4 | ||||
-rw-r--r-- | tokens.dat | 5 |
6 files changed, 18 insertions, 4 deletions
@@ -171,6 +171,7 @@ static const struct warning { {"hle", "invalid hle prefixes", true}, {"bnd", "invalid bnd prefixes", true}, {"zext-reloc", "relocation zero-extended to match output format", true}, + {"ptr", "non-NASM keyword used in other assemblers", true}, }; static bool want_usage; @@ -1958,7 +1959,6 @@ static bool skip_this_pass(int severity) if ((severity & ERR_MASK) > ERR_WARNING) return false; - /* * passn is 1 on the very first pass only. * pass0 is 2 on the code-generation (final) pass only. @@ -421,6 +421,7 @@ enum ccode { /* condition code names */ #define TFLAG_BRC_OPT (1 << 1) /* may or may not have braces. opmasks {k1} */ #define TFLAG_BRC_ANY (TFLAG_BRC | TFLAG_BRC_OPT) #define TFLAG_BRDCAST (1 << 2) /* broadcasting decorator */ +#define TFLAG_WARN (1 << 3) /* warning only, treat as ID */ static inline uint8_t get_cond_opcode(enum ccode c) { @@ -135,7 +135,8 @@ static inline vefunc nasm_set_verror(vefunc ve) #define ERR_WARN_HLE WARN(13) /* bad HLE prefixes */ #define ERR_WARN_BND WARN(14) /* bad BND prefixes */ #define ERR_WARN_ZEXTRELOC WARN(15) /* relocation zero-extended */ -#define ERR_WARN_MAX 15 /* the highest numbered one */ +#define ERR_WARN_PTR WARN(16) /* not a NASM keyword */ +#define ERR_WARN_MAX 16 /* the highest numbered one */ /* * Wrappers around malloc, realloc and free. nasm_malloc will @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2009 The NASM Authors - All Rights Reserved + * Copyright 1996-2016 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -167,6 +167,11 @@ int stdscan(void *private_data, struct tokenval *tv) * is it actually a register or instruction name, or what? */ token_type = nasm_token_hash(ourcopy, tv); + if (unlikely(tv->t_flag & TFLAG_WARN)) { + nasm_error(ERR_WARNING|ERR_PASS1|ERR_WARN_PTR, + "%s is not a NASM keyword", tv->t_charptr); + } + if (likely(!(tv->t_flag & TFLAG_BRC))) { /* most of the tokens fall into this case */ return token_type; diff --git a/test/ptr.asm b/test/ptr.asm new file mode 100644 index 00000000..bad32952 --- /dev/null +++ b/test/ptr.asm @@ -0,0 +1,4 @@ + ;; This should warn but still assemble, as the code is correct + + mov eax,dword ptr +ptr: @@ -1,6 +1,6 @@ ## -------------------------------------------------------------------------- ## -## Copyright 1996-2013 The NASM Authors - All Rights Reserved +## Copyright 1996-2016 The NASM Authors - All Rights Reserved ## See the file AUTHORS included with the NASM distribution for ## the specific copyright holders. ## @@ -76,6 +76,9 @@ word yword zword +% TOKEN_ID, 0, TFLAG_WARN, 0 +ptr + % TOKEN_FLOAT, 0, 0, 0 __infinity__ __nan__ |