From 5a39da0a6fbef90d697054c6075bf5e3ef708c9d Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sun, 16 Feb 2014 04:56:31 +0000 Subject: [PATCH] MCAsmParser: relax declaration parsing 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 | 5 ++++- test/MC/AsmParser/macros-argument-parsing.s | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/MC/AsmParser/macros-argument-parsing.s diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 5f92795b49d..03b004ecfac 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -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 index 00000000000..097a2702a06 --- /dev/null +++ b/test/MC/AsmParser/macros-argument-parsing.s @@ -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 +