[mips] Stop parsing a .set assignment if the first argument is not an identifier

Before this fix the following code triggers two error messages. The
second one is at least useless:

  test.s:1:9: error: expected identifier after .set
    .set  123, $a0
          ^
  test-set.s:1:9: error: unexpected token, expected comma
    .set  123, $a0
          ^

llvm-svn: 333402
This commit is contained in:
Simon Atanasyan 2018-05-29 09:51:22 +00:00
parent 0bd19ead89
commit 3535cb1130
2 changed files with 12 additions and 3 deletions

View File

@ -6843,7 +6843,7 @@ bool MipsAsmParser::parseSetAssignment() {
MCAsmParser &Parser = getParser();
if (Parser.parseIdentifier(Name))
reportParseError("expected identifier after .set");
return reportParseError("expected identifier after .set");
if (getLexer().isNot(AsmToken::Comma))
return reportParseError("unexpected token, expected comma");
@ -7330,8 +7330,7 @@ bool MipsAsmParser::parseDirectiveSet() {
return parseSetNoGINVDirective();
} else {
// It is just an identifier, look for an assignment.
parseSetAssignment();
return false;
return parseSetAssignment();
}
return true;

View File

@ -57,3 +57,13 @@
# CHECK-NEXT: :{{[0-9]+}}:{{[0-9]+}}: error: unexpected token, expected end of statement
# CHECK-NEXT: .option pic2 pic3
# CHECK-NEXT: ^
.set 123, $a0
# CHECK-NEXT: :{{[0-9]+}}:{{[0-9]+}}: error: expected identifier after .set
# CHECK-NEXT: .set 123
# CHECK-NEXT: ^
.set reg.
# CHECK-NEXT: :{{[0-9]+}}:{{[0-9]+}}: error: unexpected token, expected comma
# CHECK-NEXT: .set reg.
# CHECK-NEXT: ^