From e35b9c0cad5de9791c80ac6dff9c4e1d5ab2b86e Mon Sep 17 00:00:00 2001 From: "Andrew V. Tischenko" Date: Fri, 26 May 2017 13:23:34 +0000 Subject: [PATCH] The fix for PR22004: X86AsmParser.cpp asserts: OperandStack.size() > 1 && "Too few operands." llvm-svn: 303985 --- lib/Target/X86/AsmParser/X86AsmParser.cpp | 5 +++-- test/MC/X86/pr22004.s | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 test/MC/X86/pr22004.s diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index 32ab475f118..e5d3209ec6a 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -1316,16 +1316,17 @@ bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End) { while (!Done) { bool UpdateLocLex = true; + AsmToken::TokenKind TK = getLexer().getKind(); // The period in the dot operator (e.g., [ebx].foo.bar) is parsed as an // identifier. Don't try an parse it as a register. - if (PrevTK != AsmToken::Error && Tok.getString().startswith(".")) + if (PrevTK != AsmToken::Error && Tok.getString().startswith(".") && + TK != AsmToken::Identifier) break; // If we're parsing an immediate expression, we don't expect a '['. if (SM.getStopOnLBrac() && getLexer().getKind() == AsmToken::LBrac) break; - AsmToken::TokenKind TK = getLexer().getKind(); switch (TK) { default: { if (SM.isValidEndState()) { diff --git a/test/MC/X86/pr22004.s b/test/MC/X86/pr22004.s new file mode 100644 index 00000000000..3ef1526e43a --- /dev/null +++ b/test/MC/X86/pr22004.s @@ -0,0 +1,3 @@ +// RUN: llvm-mc -triple x86_64-unknown-unknown -x86-asm-syntax=intel %s + +lea rax, qword ptr [rip + .L.str]