MCAsmParser: relax declaration parsing
authorSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 16 Feb 2014 04:56:31 +0000 (04:56 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 16 Feb 2014 04:56:31 +0000 (04:56 +0000)
The Linux kernel defines empty macros for compatibility with ARM UAL syntax.
The comma after the name is optional, and if present can be safely lexed.  This
improves compatibility with the GNU assembler.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201474 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCParser/AsmParser.cpp
test/MC/AsmParser/macros-argument-parsing.s [new file with mode: 0644]

index 5f92795b49dc5b574237e7c6070b7db547a20446..03b004ecfac62ba0520a55a62c251ada94680494 100644 (file)
@@ -3152,12 +3152,15 @@ bool AsmParser::parseDirectiveMacrosOnOff(StringRef Directive) {
 }
 
 /// parseDirectiveMacro
-/// ::= .macro name [parameters]
+/// ::= .macro name[,] [parameters]
 bool AsmParser::parseDirectiveMacro(SMLoc DirectiveLoc) {
   StringRef Name;
   if (parseIdentifier(Name))
     return TokError("expected identifier in '.macro' directive");
 
+  if (getLexer().is(AsmToken::Comma))
+    Lex();
+
   MCAsmMacroParameters Parameters;
   while (getLexer().isNot(AsmToken::EndOfStatement)) {
     MCAsmMacroParameter Parameter;
diff --git a/test/MC/AsmParser/macros-argument-parsing.s b/test/MC/AsmParser/macros-argument-parsing.s
new file mode 100644 (file)
index 0000000..097a270
--- /dev/null
@@ -0,0 +1,10 @@
+# RUN: llvm-mc -triple i386 -filetype asm -o - %s | FileCheck %s
+
+       .macro  it, cond
+       .endm
+
+       it ne
+       .long 1
+
+# CHECK: .long 1
+