action(YASM_WARN_ORPHAN_LABEL);
else if (strcmp(cmd, "uninit-contents") == 0)
action(YASM_WARN_UNINIT_CONTENTS);
+ else if (strcmp(cmd, "size-override") == 0)
+ action(YASM_WARN_SIZE_OVERRIDE);
else
return 1;
uintptr_t targetmod; /**< Arch target modifier, 0 if none. */
- /** Specified size of the operand, in bytes. 0 if not user-specified. */
+ /** Specified size of the operand, in bits. 0 if not user-specified. */
unsigned int size:8;
/** Nonzero if dereference. Used for "*foo" in GAS.
YASM_WARN_UNREC_CHAR, /**< Unrecognized characters (while tokenizing) */
YASM_WARN_PREPROC, /**< Preprocessor warnings */
YASM_WARN_ORPHAN_LABEL, /**< Label alone on a line without a colon */
- YASM_WARN_UNINIT_CONTENTS /**< Uninitialized space in code/data section */
+ YASM_WARN_UNINIT_CONTENTS, /**< Uninitialized space in code/data section */
+ YASM_WARN_SIZE_OVERRIDE /**< Double size override */
} yasm_warn_class;
/** Error classes. Bitmask-based to support limited subclassing. */
yasm_arch_get_reg_size(parser_nasm->arch, op->data.reg) != size)
yasm_error_set(YASM_ERROR_TYPE,
N_("cannot override register size"));
- else
+ else {
+ /* Silently override others unless a warning is turned on.
+ * This is to allow overrides such as:
+ * %define arg1 dword [bp+4]
+ * cmp word arg1, 2
+ * Which expands to:
+ * cmp word dword [bp+4], 2
+ */
+ if (op->size != 0) {
+ if (op->size != size)
+ yasm_warn_set(YASM_WARN_SIZE_OVERRIDE,
+ N_("overriding operand size from %u-bit to %u-bit"),
+ op->size, size);
+ else
+ yasm_warn_set(YASM_WARN_SIZE_OVERRIDE,
+ N_("double operand size override"));
+ }
op->size = size;
+ }
return op;
}
case TARGETMOD: