[AArch64][AsmParser] Fix segfault on illegal fpimm.

Floating point immediate combining a negative sign and
a hexadecimal number, e.g. #-0x0  caused the compiler to crash.

Reviewers: rengolin, fhahn, samparker, SjoerdMeijer, javed.absar

Reviewed By: javed.absar

Differential Revision: https://reviews.llvm.org/D47483

llvm-svn: 333524
This commit is contained in:
Sander de Smalen 2018-05-30 09:54:19 +00:00
parent 51f7d78f33
commit df7e091147
2 changed files with 7 additions and 2 deletions

View File

@ -2283,9 +2283,9 @@ AArch64AsmParser::tryParseFPImm(OperandVector &Operands) {
const AsmToken &Tok = Parser.getTok();
if (Tok.is(AsmToken::Real) || Tok.is(AsmToken::Integer)) {
int64_t Val;
if (Tok.is(AsmToken::Integer) && !isNegative && Tok.getString().startswith("0x")) {
if (Tok.is(AsmToken::Integer) && Tok.getString().startswith("0x")) {
Val = Tok.getIntVal();
if (Val > 255 || Val < 0) {
if (Val > 255 || isNegative) {
TokError("encoded floating point value out of range");
return MatchOperand_ParseFail;
}

View File

@ -279,10 +279,15 @@
//----------------------------------------------------------------------
// invalid vector type (2s, 4s, 2d)
fmov v0.4h, #1.0
// invalid immediate (negative hexadecimal encoding)
fmov v0.4s, #-0x0
// CHECK:ERROR: error: invalid operand for instruction
// CHECK:ERROR: fmov v0.4h, #1.0
// CHECK:ERROR: ^
// CHECK-ERROR: error: encoded floating point value out of range
// CHECK-ERROR: fmov v0.4s, #-0x0
// CHECK-ERROR: ^
//----------------------------------------------------------------------
// Vector Move - register