Skip to content

Commit 07c67a3

Browse files
committed
Improve error messages on mismatched PTR casts
1 parent e253de4 commit 07c67a3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2637,12 +2637,15 @@ bool X86AsmParser::parseIntelOperand(OperandVector &Operands, StringRef Name) {
26372637

26382638
// If we are parsing MASM, we are allowed to cast registers to their own
26392639
// sizes, but not to other types.
2640-
if (RegSizeInBits(*getContext().getRegisterInfo(), RegNo) != Size)
2640+
uint16_t RegSize =
2641+
RegSizeInBits(*getContext().getRegisterInfo(), RegNo);
2642+
if (RegSize != Size)
26412643
return Error(
26422644
Start,
2643-
"cannot cast register '" +
2645+
std::to_string(RegSize) + "-bit register '" +
26442646
StringRef(getContext().getRegisterInfo()->getName(RegNo)) +
2645-
"' to '" + SizeStr + "'; size does not match");
2647+
"' cannot be used as a " + std::to_string(Size) + "-bit " +
2648+
SizeStr.upper());
26462649
}
26472650
Operands.push_back(X86Operand::CreateReg(RegNo, Start, End));
26482651
return false;

0 commit comments

Comments
 (0)