diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index c60bbb40033..78b56b744f8 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -1632,6 +1632,9 @@ std::unique_ptr X86AsmParser::ParseATTOperand() { if (getLexer().isNot(AsmToken::Colon)) return X86Operand::CreateReg(RegNo, Start, End); + if (!X86MCRegisterClasses[X86::SEGMENT_REGRegClassID].contains(RegNo)) + return ErrorOperand(Start, "invalid segment register"); + getParser().Lex(); // Eat the colon. return ParseMemOperand(RegNo, Start); } diff --git a/test/MC/X86/x86_errors.s b/test/MC/X86/x86_errors.s index 51f2e8e1468..0b3bc7f4350 100644 --- a/test/MC/X86/x86_errors.s +++ b/test/MC/X86/x86_errors.s @@ -46,3 +46,7 @@ movl %eax,(,%bx) // 32: error: invalid operand for instruction outb al, 4 + +// 32: error: invalid segment register +// 64: error: invalid segment register +movl %eax:0x00, %ebx