[08/20] Allow comparison operators in macro arguments as well

Message ID 1395664691-60544-8-git-send-email-martin@martin.st
State Committed
Commit d48bbf2da822083dd9421775bfd227cc3401ed94
Headers show

Commit Message

Martin Storsjö March 24, 2014, 12:37 p.m.
Also add test cases that show that macros can use commas
or omit them.
---
 gas-preprocessor.pl |  2 +-
 test.S              | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

Comments

Janne Grunau March 24, 2014, 3:01 p.m. | #1
On 2014-03-24 14:37:59 +0200, Martin Storsjö wrote:
> Also add test cases that show that macros can use commas
> or omit them.
> ---
>  gas-preprocessor.pl |  2 +-
>  test.S              | 18 ++++++++++++++++++
>  2 files changed, 19 insertions(+), 1 deletion(-)

ok

Janne

Patch

diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
index 24977a7..5498b7c 100755
--- a/gas-preprocessor.pl
+++ b/gas-preprocessor.pl
@@ -497,7 +497,7 @@  sub expand_macros {
         my $comma_sep_required = 0;
         foreach (@arglist) {
             # allow arithmetic/shift operators in macro arguments
-            $_ =~ s/\s*(\+|-|\*|\/|<<|>>)\s*/$1/g;
+            $_ =~ s/\s*(\+|-|\*|\/|<<|>>|<|>)\s*/$1/g;
 
             my @whitespace_split = split(/\s+/, $_);
             if (!@whitespace_split) {
diff --git a/test.S b/test.S
index f8372d5..f6ec894 100644
--- a/test.S
+++ b/test.S
@@ -48,3 +48,21 @@  m 0
 .if 2 > 1
     outer
 .endif
+
+.macro argtest1 first, second, third
+    mov r0, #\first
+    mov r0, #\second
+    mov r0, #\third
+.endm
+.macro argtest2 first second third
+    mov r1, #\first
+    mov r1, #\second
+    mov r1, #\third
+.endm
+
+argtest1 1, 2, 3
+argtest1 1 2 3
+argtest2 1, 2, 3
+argtest2 1 2 3
+argtest1 1 2 3 + 1
+argtest2 1 2 < 1 3