diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-02-20 13:36:32 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-02-20 13:36:32 +0000 |
| commit | 513e744d9b42117c2b9b9d4d72d494a44572548d (patch) | |
| tree | f298cd8ac299e6e1d32370cba1fc379d9a586971 | |
| parent | b106f2c0ac58eaa90af1cd761287e8c21b0a35e6 (diff) | |
| download | bcm5719-llvm-513e744d9b42117c2b9b9d4d72d494a44572548d.tar.gz bcm5719-llvm-513e744d9b42117c2b9b9d4d72d494a44572548d.zip | |
AsmParser: Disable Darwin-style macro argument expansion on non-darwin targets.
There is code in the wild that relies on $0 not being expanded.
llvm-svn: 201784
| -rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 6 | ||||
| -rw-r--r-- | llvm/test/MC/AsmParser/exprs.s | 2 | ||||
| -rw-r--r-- | llvm/test/MC/AsmParser/macros-gas.s | 12 |
3 files changed, 16 insertions, 4 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index f73e56ade2d..c4dfc75c6d2 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -1730,7 +1730,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &OS, StringRef Body, ArrayRef<MCAsmMacroParameter> Parameters, ArrayRef<MCAsmMacroArgument> A, const SMLoc &L) { unsigned NParameters = Parameters.size(); - if (NParameters != 0 && NParameters != A.size()) + if ((!IsDarwin || NParameters != 0) && NParameters != A.size()) return Error(L, "Wrong number of arguments"); // A macro without parameters is handled differently on Darwin: @@ -1740,7 +1740,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &OS, StringRef Body, std::size_t End = Body.size(), Pos = 0; for (; Pos != End; ++Pos) { // Check for a substitution or escape. - if (!NParameters) { + if (IsDarwin && !NParameters) { // This macro has no parameters, look for $0, $1, etc. if (Body[Pos] != '$' || Pos + 1 == End) continue; @@ -1763,7 +1763,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &OS, StringRef Body, if (Pos == End) break; - if (!NParameters) { + if (IsDarwin && !NParameters) { switch (Body[Pos + 1]) { // $$ => $ case '$': diff --git a/llvm/test/MC/AsmParser/exprs.s b/llvm/test/MC/AsmParser/exprs.s index a7e10020b67..c5fc9b594a0 100644 --- a/llvm/test/MC/AsmParser/exprs.s +++ b/llvm/test/MC/AsmParser/exprs.s @@ -1,4 +1,4 @@ -// RUN: llvm-mc -triple i386-unknown-unknown %s > %t +// RUN: llvm-mc -triple i386-apple-darwin %s .macro check_expr .if ($0) != ($1) diff --git a/llvm/test/MC/AsmParser/macros-gas.s b/llvm/test/MC/AsmParser/macros-gas.s index 6c75363b5e3..d907a2517f8 100644 --- a/llvm/test/MC/AsmParser/macros-gas.s +++ b/llvm/test/MC/AsmParser/macros-gas.s @@ -91,3 +91,15 @@ test8 1,2 3 // CHECK: .ascii "1,2,3" test8 1 2, 3 + +.macro test10 +.ascii "$20" +.endm + +test10 +// CHECK: .ascii "$20" + +test10 42 +// CHECK-ERRORS: 102:10: error: Wrong number of arguments +// CHECK-ERRORS-NEXT: test10 42 +// CHECK-ERRORS-NEXT: ^ |

