aboutsummaryrefslogtreecommitdiffstats
path: root/test/MC/AsmParser
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-04-23 16:57:46 -0700
committerStephen Hines <srhines@google.com>2014-04-24 15:53:16 -0700
commit36b56886974eae4f9c5ebc96befd3e7bfe5de338 (patch)
treee6cfb69fbbd937f450eeb83bfb83b9da3b01275a /test/MC/AsmParser
parent69a8640022b04415ae9fac62f8ab090601d8f889 (diff)
downloadexternal_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.zip
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.gz
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.bz2
Update to LLVM 3.5a.
Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
Diffstat (limited to 'test/MC/AsmParser')
-rw-r--r--test/MC/AsmParser/conditional_asm.s9
-rw-r--r--test/MC/AsmParser/directive-err-diagnostics.s17
-rw-r--r--test/MC/AsmParser/directive-err.s30
-rw-r--r--test/MC/AsmParser/directive_end-2.s14
-rw-r--r--test/MC/AsmParser/directive_end.s11
-rw-r--r--test/MC/AsmParser/directive_fill.s46
-rw-r--r--test/MC/AsmParser/directive_loc.s9
-rw-r--r--test/MC/AsmParser/directive_rept-diagnostics.s41
-rw-r--r--test/MC/AsmParser/directive_rept.s30
-rw-r--r--test/MC/AsmParser/directive_values.s12
-rw-r--r--test/MC/AsmParser/dot-symbol-assignment-backwards.s12
-rw-r--r--test/MC/AsmParser/dot-symbol-assignment.s31
-rw-r--r--test/MC/AsmParser/dot-symbol-non-absolute.s9
-rw-r--r--test/MC/AsmParser/dot-symbol.s5
-rw-r--r--test/MC/AsmParser/exprs.s2
-rw-r--r--test/MC/AsmParser/ifc.s5
-rw-r--r--test/MC/AsmParser/ifeqs-diagnostics.s22
-rw-r--r--test/MC/AsmParser/ifeqs.s20
-rw-r--r--test/MC/AsmParser/macro-def-in-instantiation.s20
-rw-r--r--test/MC/AsmParser/macro-err1.s2
-rw-r--r--test/MC/AsmParser/macro-irp.s2
-rw-r--r--test/MC/AsmParser/macro-qualifier-diagnostics.s64
-rw-r--r--test/MC/AsmParser/macro-qualifier.s16
-rw-r--r--test/MC/AsmParser/macros-argument-parsing-diagnostics.s24
-rw-r--r--test/MC/AsmParser/macros-argument-parsing.s91
-rw-r--r--test/MC/AsmParser/macros-darwin.s90
-rw-r--r--test/MC/AsmParser/macros-gas.s105
-rw-r--r--test/MC/AsmParser/macros.s93
28 files changed, 725 insertions, 107 deletions
diff --git a/test/MC/AsmParser/conditional_asm.s b/test/MC/AsmParser/conditional_asm.s
index f619ef9..b9bee33 100644
--- a/test/MC/AsmParser/conditional_asm.s
+++ b/test/MC/AsmParser/conditional_asm.s
@@ -10,3 +10,12 @@
.byte 0
.endif
.endif
+
+# CHECK: .byte 1
+# CHECK-NOT: .byte 0
+.ifne 32 - 32
+ .byte 0
+.else
+ .byte 1
+.endif
+
diff --git a/test/MC/AsmParser/directive-err-diagnostics.s b/test/MC/AsmParser/directive-err-diagnostics.s
new file mode 100644
index 0000000..ccc5450
--- /dev/null
+++ b/test/MC/AsmParser/directive-err-diagnostics.s
@@ -0,0 +1,17 @@
+// RUN: not llvm-mc -triple i386 %s 2>&1 | FileCheck %s
+
+ .error 0
+// CHECK: error: .error argument must be a string
+// CHECK: .error 0
+// CHECK: ^
+
+ .ifeqs "0", "1"
+ .ifeqs "", ""
+ .error "message"
+ .endif
+ .endif
+// CHECK-NOT: error: message
+// CHECK-NOT: error: invalid instruction mnemonic 'message'
+// CHECK-NOT: .error "message"
+// CHECK-NOT: ^
+
diff --git a/test/MC/AsmParser/directive-err.s b/test/MC/AsmParser/directive-err.s
new file mode 100644
index 0000000..63b8939
--- /dev/null
+++ b/test/MC/AsmParser/directive-err.s
@@ -0,0 +1,30 @@
+// RUN: not llvm-mc -triple i386 %s 2>&1 | FileCheck %s
+
+ .err
+// CHECK: error: .err encountered
+// CHECK-NEXT: .err
+// CHECK-NEXT: ^
+
+ .ifc a,a
+ .err
+ .endif
+// CHECK: error: .err encountered
+// CHECK-NEXT: .err
+// CHECK-NEXT: ^
+
+ .ifnc a,a
+ .err
+ .endif
+// CHECK-NOT: error: .err encountered
+
+ .error "This is my error. There are many like it, but this one is mine."
+// CHECK: error: This is my error. There are many like it, but this one is mine.
+
+ .ifc one, two
+ .error "My error is my best friend."
+ .endif
+// CHECK-NOT: error: My error is my best friend.
+
+ .error
+// CHECK: error: .error directive invoked in source file
+
diff --git a/test/MC/AsmParser/directive_end-2.s b/test/MC/AsmParser/directive_end-2.s
new file mode 100644
index 0000000..96188da
--- /dev/null
+++ b/test/MC/AsmParser/directive_end-2.s
@@ -0,0 +1,14 @@
+# RUN: llvm-mc -triple i386-unknown-unknown %s -I %p -filetype obj -o - \
+# RUN: | llvm-readobj -t | FileCheck %s
+
+rock:
+ movl $42, %eax
+
+.include "directive_end.s"
+
+hard_place:
+ movl $42, %ebx
+
+# CHECK: Symbol {
+# CHECK: Name: rock
+# CHECK-NOT: Name: hard_place
diff --git a/test/MC/AsmParser/directive_end.s b/test/MC/AsmParser/directive_end.s
new file mode 100644
index 0000000..ec43cad
--- /dev/null
+++ b/test/MC/AsmParser/directive_end.s
@@ -0,0 +1,11 @@
+# RUN: llvm-mc -triple i386-unknown-unknown %s -filetype obj -o - \
+# RUN: | llvm-readobj -t | FileCheck %s
+
+ .end
+
+its_a_tarp:
+ int $0x3
+
+# CHECK: Symbol {
+# CHECK-NOT: Name: its_a_tarp
+
diff --git a/test/MC/AsmParser/directive_fill.s b/test/MC/AsmParser/directive_fill.s
index bb3ced0..28d7fa2 100644
--- a/test/MC/AsmParser/directive_fill.s
+++ b/test/MC/AsmParser/directive_fill.s
@@ -1,4 +1,5 @@
-# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s 2> %t.err | FileCheck %s
+# RUN: FileCheck --check-prefix=CHECK-WARNINGS %s < %t.err
# CHECK: TEST0:
# CHECK: .byte 10
@@ -12,7 +13,8 @@ TEST1:
.fill 2, 2, 3
# CHECK: TEST2:
-# CHECK: .quad 4
+# CHECK: .long 4
+# CHECK: .long 0
TEST2:
.fill 1, 8, 4
@@ -31,3 +33,43 @@ TEST3:
# CHECK: .short 0
TEST4:
.fill 4, 2
+
+# CHECK: TEST5
+# CHECK: .short 2
+# CHECK: .byte 0
+# CHECK: .short 2
+# CHECK: .byte 0
+# CHECK: .short 2
+# CHECK: .byte 0
+# CHECK: .short 2
+# CHECK: .byte 0
+TEST5:
+ .fill 4, 3, 2
+
+# CHECK: TEST6
+# CHECK: .long 2
+# CHECK: .long 0
+# CHECK-WARNINGS: '.fill' directive with size greater than 8 has been truncated to 8
+TEST6:
+ .fill 1, 9, 2
+
+# CHECK: TEST7
+# CHECK: .long 0
+# CHECK: .long 0
+# CHECK-WARNINGS: '.fill' directive pattern has been truncated to 32-bits
+TEST7:
+ .fill 1, 8, 1<<32
+
+# CHECK-WARNINGS: '.fill' directive with negative repeat count has no effect
+TEST8:
+ .fill -1, 8, 1
+
+# CHECK-WARNINGS: '.fill' directive with negative size has no effect
+TEST9:
+ .fill 1, -1, 1
+
+# CHECK: TEST10
+# CHECK: .short 22136
+# CHECK: .byte 52
+TEST10:
+ .fill 1, 3, 0x12345678
diff --git a/test/MC/AsmParser/directive_loc.s b/test/MC/AsmParser/directive_loc.s
index 700a32c..cda9579 100644
--- a/test/MC/AsmParser/directive_loc.s
+++ b/test/MC/AsmParser/directive_loc.s
@@ -1,9 +1,14 @@
-# RUN: llvm-mc -triple i386-unknown-unknown %s
-# FIXME: Actually test the output.
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
.file 1 "hello"
+# CHECK: .file 1 "hello"
.loc 1
.loc 1 2
+# CHECK: .loc 1 2 0
.loc 1 2 3
+# CHECK: .loc 1 2 3
.loc 1 2 discriminator 1
+# CHECK: 1 2 0 discriminator 1
+ .loc 1 2 0 isa 3
+# CHECK: 1 2 0 isa 3
.loc 1 0
diff --git a/test/MC/AsmParser/directive_rept-diagnostics.s b/test/MC/AsmParser/directive_rept-diagnostics.s
new file mode 100644
index 0000000..cbef158
--- /dev/null
+++ b/test/MC/AsmParser/directive_rept-diagnostics.s
@@ -0,0 +1,41 @@
+# RUN: not llvm-mc -triple i686-elf -filetype asm -o /dev/null %s 2>&1 \
+# RUN: | FileCheck %s
+
+ .data
+
+ .global invalid_expression
+ .type invalid_expression,@object
+invalid_expression:
+ .rept *
+
+# CHECK: error: unknown token in expression
+# CHECK: .rept *
+# CHECK: ^
+
+ .global bad_token
+ .type bad_token,@object
+bad_token:
+ .rept bad_token
+
+# CHECK: error: unexpected token in '.rept' directive
+# CHECK: .rept bad_token
+# CHECK: ^
+
+ .global negative
+ .type negative,@object
+negative:
+ .rept -32
+
+# CHECK: error: Count is negative
+# CHECK: .rept -32
+# CHECK: ^
+
+ .global trailer
+ .type trailer,@object
+trailer:
+ .rep 0 trailer
+
+# CHECK: error: unexpected token in '.rep' directive
+# CHECK: .rep 0 trailer
+# CHECK: ^
+
diff --git a/test/MC/AsmParser/directive_rept.s b/test/MC/AsmParser/directive_rept.s
new file mode 100644
index 0000000..4f8ed7c
--- /dev/null
+++ b/test/MC/AsmParser/directive_rept.s
@@ -0,0 +1,30 @@
+# RUN: llvm-mc -triple i686-elf -filetype asm -o - %s | FileCheck %s
+
+ .data
+
+ .global two_bad_calls
+ .type two_bad_calls,@function
+two_bad_calls:
+ .rept 2
+ .long 0xbadca11
+ .endr
+
+# CHECK-LABEL: two_bad_calls
+# CHECK: .long 195938833
+# CHECK: .long 195938833
+
+ .global half_a_dozen_daffodils
+ .type half_a_dozen_daffodils,@function
+half_a_dozen_daffodils:
+ .rep 6
+ .long 0xdaff0d11
+ .endr
+
+# CHECK-LABEL: half_a_dozen_daffodils
+# CHECK: .long 3674148113
+# CHECK: .long 3674148113
+# CHECK: .long 3674148113
+# CHECK: .long 3674148113
+# CHECK: .long 3674148113
+# CHECK: .long 3674148113
+
diff --git a/test/MC/AsmParser/directive_values.s b/test/MC/AsmParser/directive_values.s
index ed932b2..6941a1a 100644
--- a/test/MC/AsmParser/directive_values.s
+++ b/test/MC/AsmParser/directive_values.s
@@ -69,3 +69,15 @@ TEST8:
.long 0x200000L+1
# CHECK: .long 2097153
# CHECK: .long 2097153
+
+TEST9:
+ .octa 0x1234567812345678abcdef, 340282366920938463463374607431768211455
+ .octa 0b00111010010110100101101001011010010110100101101001011010010110100101101001011010010110100101101001011010010110100101101001011010
+# CHECK: TEST9
+# CHECK: .quad 8652035380128501231
+# CHECK: .quad 1193046
+# CHECK: .quad -1
+# CHECK: .quad -1
+# CHECK: .quad 6510615555426900570
+# CHECK: .quad 4204772546213206618
+
diff --git a/test/MC/AsmParser/dot-symbol-assignment-backwards.s b/test/MC/AsmParser/dot-symbol-assignment-backwards.s
new file mode 100644
index 0000000..2619788
--- /dev/null
+++ b/test/MC/AsmParser/dot-symbol-assignment-backwards.s
@@ -0,0 +1,12 @@
+# RUN: not llvm-mc -filetype=obj -triple i386-unknown-unknown %s 2> %t
+# RUN: FileCheck -input-file %t %s
+
+. = 0x10
+ .byte 1
+
+. = . + 10
+ .byte 2
+
+# CHECK: LLVM ERROR: invalid .org offset '24' (at offset '28')
+. = 0x18
+ .byte 3
diff --git a/test/MC/AsmParser/dot-symbol-assignment.s b/test/MC/AsmParser/dot-symbol-assignment.s
new file mode 100644
index 0000000..65651d7
--- /dev/null
+++ b/test/MC/AsmParser/dot-symbol-assignment.s
@@ -0,0 +1,31 @@
+# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
+
+ .extern start
+
+# CHECK: .org 1024, 0
+. = 0x400
+ lgdt 0x400 + 0x100
+
+ ljmpl $0x08, $(0x400 + 0x150)
+
+
+# CHECK: .org 1280, 0
+. = 0x400 + 0x100
+ .word (3*8)-1
+ .quad (0x400 + 0x110)
+
+# CHECK: .org 1296, 0
+. = 0x400 + 0x110
+ .quad 0x0
+ .quad 0x0020980000000000
+ .quad 0x0000900000000000
+
+ .code64
+
+# CHECK: .org 1360, 0
+. = 0x400 + 0x150
+ movabsq $start, %rcx
+ jmp *%rcx
+
+
+. = 0x300
diff --git a/test/MC/AsmParser/dot-symbol-non-absolute.s b/test/MC/AsmParser/dot-symbol-non-absolute.s
new file mode 100644
index 0000000..7342365
--- /dev/null
+++ b/test/MC/AsmParser/dot-symbol-non-absolute.s
@@ -0,0 +1,9 @@
+# RUN: not llvm-mc -filetype=obj -triple i386-unknown-unknown %s 2> %t
+# RUN: FileCheck -input-file %t %s
+
+
+ .extern foo
+
+# CHECK: error: expected absolute expression
+. = foo + 10
+ .byte 1
diff --git a/test/MC/AsmParser/dot-symbol.s b/test/MC/AsmParser/dot-symbol.s
index 4a38a40..4bae323 100644
--- a/test/MC/AsmParser/dot-symbol.s
+++ b/test/MC/AsmParser/dot-symbol.s
@@ -1,12 +1,9 @@
# Historically 'as' treats '.' as a reference to the current location in
-# arbitrary contects. We don't support this in general.
+# arbitrary contexts. We don't support this in general.
# RUN: not llvm-mc -triple i386-unknown-unknown %s 2> %t
# RUN: FileCheck -input-file %t %s
-# CHECK: assignment to pseudo-symbol '.' is unsupported (use '.space' or '.org').
-. = . + 8
-
# CHECK: invalid use of pseudo-symbol '.' as a label
.:
.long 0
diff --git a/test/MC/AsmParser/exprs.s b/test/MC/AsmParser/exprs.s
index a7e1002..c5fc9b5 100644
--- a/test/MC/AsmParser/exprs.s
+++ b/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/test/MC/AsmParser/ifc.s b/test/MC/AsmParser/ifc.s
index 20e55c0..24944a2 100644
--- a/test/MC/AsmParser/ifc.s
+++ b/test/MC/AsmParser/ifc.s
@@ -63,3 +63,8 @@
.else
.byte 0
.endif
+
+# CHECK-NOT: .byte 0
+# CHECK: .byte 1
+.ifnc equal, equal ; .byte 0 ; .else ; .byte 1 ; .endif
+
diff --git a/test/MC/AsmParser/ifeqs-diagnostics.s b/test/MC/AsmParser/ifeqs-diagnostics.s
new file mode 100644
index 0000000..1e5e8c3
--- /dev/null
+++ b/test/MC/AsmParser/ifeqs-diagnostics.s
@@ -0,0 +1,22 @@
+// RUN: not llvm-mc -triple i386 %s -o /dev/null 2>&1 | FileCheck %s
+
+.ifeqs
+
+// CHECK: error: expected string parameter for '.ifeqs' directive
+// CHECK: .ifeqs
+// CHECK: ^
+
+.ifeqs "string1"
+
+// CHECK: error: expected comma after first string for '.ifeqs' directive
+// CHECK: .ifeqs "string1"
+// CHECK: ^
+
+.ifeqs "string1",
+
+// CHECK: error: expected string parameter for '.ifeqs' directive
+// CHECK: .ifeqs "string1",
+// CHECK: ^
+
+// CHECK-NOT: error: unmatched .ifs or .elses
+
diff --git a/test/MC/AsmParser/ifeqs.s b/test/MC/AsmParser/ifeqs.s
new file mode 100644
index 0000000..05a26a2
--- /dev/null
+++ b/test/MC/AsmParser/ifeqs.s
@@ -0,0 +1,20 @@
+// RUN: llvm-mc -triple i386 %s | FileCheck %s
+
+.ifeqs "alpha", "alpha"
+ .byte 1
+.else
+ .byte 0
+.endif
+
+// CHECK-NOT: .byte 0
+// CHECK: .byte 1
+
+.ifeqs "alpha", "alpha "
+ .byte 0
+.else
+ .byte 1
+.endif
+
+// CHECK-NOT: .byte 0
+// CHECK: .byte 1
+
diff --git a/test/MC/AsmParser/macro-def-in-instantiation.s b/test/MC/AsmParser/macro-def-in-instantiation.s
index b6483b3..773df70 100644
--- a/test/MC/AsmParser/macro-def-in-instantiation.s
+++ b/test/MC/AsmParser/macro-def-in-instantiation.s
@@ -11,3 +11,23 @@ $4
.data
// CHECK: .byte 10
.mybyte 10
+
+// PR18599
+.macro macro_a
+
+.macro macro_b
+.byte 10
+.macro macro_c
+.endm
+
+macro_c
+.purgem macro_c
+.endm
+
+macro_b
+.endm
+
+macro_a
+macro_b
+// CHECK: .byte 10
+// CHECK: .byte 10
diff --git a/test/MC/AsmParser/macro-err1.s b/test/MC/AsmParser/macro-err1.s
index 924deb0..bd9c837 100644
--- a/test/MC/AsmParser/macro-err1.s
+++ b/test/MC/AsmParser/macro-err1.s
@@ -7,4 +7,4 @@
foo 42, 42
-// CHECK: Too many arguments
+// CHECK: too many positional arguments
diff --git a/test/MC/AsmParser/macro-irp.s b/test/MC/AsmParser/macro-irp.s
index a368b74..2f26eab 100644
--- a/test/MC/AsmParser/macro-irp.s
+++ b/test/MC/AsmParser/macro-irp.s
@@ -1,4 +1,4 @@
-// RUN: llvm-mc -triple x86_64-unknown-unknown %s | FileCheck %s
+// RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
.irp reg,%eax,%ebx
pushl \reg
diff --git a/test/MC/AsmParser/macro-qualifier-diagnostics.s b/test/MC/AsmParser/macro-qualifier-diagnostics.s
new file mode 100644
index 0000000..4ebad2b
--- /dev/null
+++ b/test/MC/AsmParser/macro-qualifier-diagnostics.s
@@ -0,0 +1,64 @@
+# RUN: not llvm-mc -triple i386 -o /dev/null %s 2>&1 | FileCheck %s
+
+ .macro missing_qualifier parameter:
+
+# CHECK: error: missing parameter qualifier for 'parameter' in macro 'missing_qualifier'
+# CHECK: .macro missing_qualifier parameter:
+# CHECK: ^
+
+ .macro non_identifier_qualifier parameter:0
+
+# CHECK: error: missing parameter qualifier for 'parameter' in macro 'non_identifier_qualifier'
+# CHECK: .macro non_identifier_qualifier parameter:0
+# CHECK: ^
+
+ .macro invalid_qualifier parameter:invalid_qualifier
+
+# CHECK: error: invalid_qualifier is not a valid parameter qualifier for 'parameter' in macro 'invalid_qualifier'
+# CHECK: .macro invalid_qualifier parameter:invalid_qualifier
+# CHECK: ^
+
+ .macro pointless_default parameter:req=default
+ .endm
+
+# CHECK: warning: pointless default value for required parameter 'parameter' in macro 'pointless_default'
+# CHECK: .macro pointless_default parameter:req=default
+# CHECK: ^
+
+ .macro missing_required_parameter parameter:req
+ .endm
+
+ missing_required_parameter
+
+# CHECK: error: missing value for required parameter 'parameter' in macro 'missing_required_parameter'
+# CHECK: missing_required_parameter
+# CHECK: ^
+
+ .macro missing_second_required_argument first=0 second:req
+ .endm
+
+ missing_second_required_argument
+
+# CHECK: error: missing value for required parameter 'second' in macro 'missing_second_required_argument'
+# CHECK: missing_second_required_argument
+# CHECK: ^
+
+ .macro second_third_required first=0 second:req third:req
+ .endm
+
+ second_third_required 0
+
+# CHECK: error: missing value for required parameter 'second' in macro 'second_third_required'
+# CHECK: second_third_required 0
+# CHECK: ^
+
+# CHECK: error: missing value for required parameter 'third' in macro 'second_third_required'
+# CHECK: second_third_required 0
+# CHECK: ^
+
+ second_third_required third=3 first=1
+
+# CHECK: error: missing value for required parameter 'second' in macro 'second_third_required'
+# CHECK: second_third_required third=3 first=1
+# CHECK: ^
+
diff --git a/test/MC/AsmParser/macro-qualifier.s b/test/MC/AsmParser/macro-qualifier.s
new file mode 100644
index 0000000..7714e5c
--- /dev/null
+++ b/test/MC/AsmParser/macro-qualifier.s
@@ -0,0 +1,16 @@
+# RUN: llvm-mc -triple i386 -o - %s | FileCheck %s
+
+ .macro required parameter:req
+ .long \parameter
+ .endm
+
+ required 0
+# CHECK: .long 0
+
+ .macro required_with_default parameter:req=0
+ .long \parameter
+ .endm
+
+ required 1
+# CHECK: .long 1
+
diff --git a/test/MC/AsmParser/macros-argument-parsing-diagnostics.s b/test/MC/AsmParser/macros-argument-parsing-diagnostics.s
new file mode 100644
index 0000000..a1970e0
--- /dev/null
+++ b/test/MC/AsmParser/macros-argument-parsing-diagnostics.s
@@ -0,0 +1,24 @@
+# RUN: not llvm-mc -triple i386 -filetype asm -o /dev/null %s 2>&1 | FileCheck %s
+
+ .macro double first = -1, second = -1
+ # begin entry
+ .long \first
+ .long \second
+ # end entry
+ .endm
+
+ double 0, 1, 2
+# CHECK: error: too many positional arguments
+# CHECK: double 0, 1, 2
+# CHECK: ^
+
+ double second = 1, 2
+# CHECK: error: cannot mix positional and keyword arguments
+# CHECK: double second = 1, 2
+# CHECK: ^
+
+ double third = 0
+# CHECK: error: parameter named 'third' does not exist for macro 'double'
+# CHECK: double third = 0
+# CHECK: ^
+
diff --git a/test/MC/AsmParser/macros-argument-parsing.s b/test/MC/AsmParser/macros-argument-parsing.s
new file mode 100644
index 0000000..39242cf
--- /dev/null
+++ b/test/MC/AsmParser/macros-argument-parsing.s
@@ -0,0 +1,91 @@
+# RUN: llvm-mc -triple i386 -filetype asm -o - %s | FileCheck %s
+
+ .macro it, cond
+ .endm
+
+ it ne
+ .long 1
+
+# CHECK: .long 1
+
+ .macro double first = -1, second = -1
+ # begin entry
+ .long \first
+ .long \second
+ # end entry
+ .endm
+
+ double
+# CHECK: .long -1
+# CHECK: .long -1
+
+ double 1
+# CHECK: .long 1
+# CHECK: .long -1
+
+ double 2, 3
+# CHECK: .long 2
+# CHECK: .long 3
+
+ double , 4
+# CHECK: .long -1
+# CHECK: .long 4
+
+ double 5, second = 6
+# CHECK: .long 5
+# CHECK: .long 6
+
+ double first = 7
+# CHECK: .long 7
+# CHECK: .long -1
+
+ double second = 8
+# CHECK: .long -1
+# CHECK: .long 8
+
+ double second = 9, first = 10
+# CHECK: .long 10
+# CHECK: .long 9
+
+ double second + 11
+# CHECK: .long second+11
+# CHECK: .long -1
+
+ double , second + 12
+# CHECK: .long -1
+# CHECK: .long second+12
+
+ double second
+# CHECK: .long second
+# CHECK: .long -1
+
+ .macro mixed arg0 = 0, arg1 = 1 arg2 = 2, arg3 = 3
+ # begin entry
+ .long \arg0
+ .long \arg1
+ .long \arg2
+ .long \arg3
+ # end entry
+ .endm
+
+mixed 1, 2 3
+
+# CHECK: .long 1
+# CHECK: .long 2
+# CHECK: .long 3
+# CHECK: .long 3
+
+mixed 1 2, 3
+
+# CHECK: .long 1
+# CHECK: .long 2
+# CHECK: .long 3
+# CHECK: .long 3
+
+mixed 1 2, 3 4
+
+# CHECK: .long 1
+# CHECK: .long 2
+# CHECK: .long 3
+# CHECK: .long 4
+
diff --git a/test/MC/AsmParser/macros-darwin.s b/test/MC/AsmParser/macros-darwin.s
index 95965d3..e22038e 100644
--- a/test/MC/AsmParser/macros-darwin.s
+++ b/test/MC/AsmParser/macros-darwin.s
@@ -1,9 +1,93 @@
-// RUN: llvm-mc -triple i386-apple-darwin10 %s | FileCheck %s
+// RUN: not llvm-mc -triple i386-apple-darwin10 %s 2> %t.err | FileCheck %s
+// RUN: FileCheck --check-prefix=CHECK-ERRORS %s < %t.err
-.macro test1
+.macro .test0
+.macrobody0
+.endmacro
+.macro .test1
+.test0
+.endmacro
+
+.test1
+// CHECK-ERRORS: <instantiation>:1:1: error: unknown directive
+// CHECK-ERRORS-NEXT: macrobody0
+// CHECK-ERRORS-NEXT: ^
+// CHECK-ERRORS: <instantiation>:1:1: note: while in macro instantiation
+// CHECK-ERRORS-NEXT: .test0
+// CHECK-ERRORS-NEXT: ^
+// CHECK-ERRORS: 11:1: note: while in macro instantiation
+// CHECK-ERRORS-NEXT: .test1
+// CHECK-ERRORS-NEXT: ^
+
+.macro test2
+.byte $0
+.endmacro
+// CHECK: .byte 10
+test2 10
+
+.macro test3
.globl "$0 $1 $2 $$3 $n"
.endmacro
// CHECK: .globl "1 23 $3 2"
-test1 1, 2 3
+test3 1, 2 3
+
+// CHECK: .globl "1 (23) $3 2"
+test3 1, (2 3)
+
+// CHECK: .globl "12 $3 1"
+test3 1 2
+
+.macro test4
+.globl "$0 -- $1"
+.endmacro
+
+// CHECK: .globl "(ab)(,)) -- (cd)"
+test4 (a b)(,)),(cd)
+
+// CHECK: .globl "(ab)(,)) -- (cd)"
+test4 (a b)(,)),(cd)
+
+.macro test5 _a
+.globl "\_a"
+.endm
+
+// CHECK: .globl zed1
+test5 zed1
+
+.macro test6 $a
+.globl "\$a"
+.endm
+
+// CHECK: .globl zed2
+test6 zed2
+
+.macro test7 .a
+.globl "\.a"
+.endm
+
+// CHECK: .globl zed3
+test7 zed3
+
+.macro test8 _a, _b, _c
+.globl "\_a,\_b,\_c"
+.endmacro
+
+.macro test9 _a _b _c
+.globl "\_a \_b \_c"
+.endmacro
+
+// CHECK: .globl "a,b,c"
+test8 a, b, c
+// CHECK: .globl "%1,%2,%3"
+test8 %1, %2, %3 #a comment
+// CHECK: .globl "x-y,z,1"
+test8 x - y, z, 1
+// CHECK: .globl "1 2 3"
+test9 1, 2,3
+
+// CHECK: .globl "1,23,"
+test8 1,2 3
+// CHECK: .globl "12,3,"
+test8 1 2, 3
diff --git a/test/MC/AsmParser/macros-gas.s b/test/MC/AsmParser/macros-gas.s
new file mode 100644
index 0000000..d907a25
--- /dev/null
+++ b/test/MC/AsmParser/macros-gas.s
@@ -0,0 +1,105 @@
+// RUN: not llvm-mc -triple i386-linux-gnu %s 2> %t.err | FileCheck %s
+// RUN: FileCheck --check-prefix=CHECK-ERRORS %s < %t.err
+
+.macro .test0
+.macrobody0
+.endm
+.macro .test1
+.test0
+.endm
+
+.test1
+// CHECK-ERRORS: <instantiation>:1:1: error: unknown directive
+// CHECK-ERRORS-NEXT: macrobody0
+// CHECK-ERRORS-NEXT: ^
+// CHECK-ERRORS: <instantiation>:1:1: note: while in macro instantiation
+// CHECK-ERRORS-NEXT: .test0
+// CHECK-ERRORS-NEXT: ^
+// CHECK-ERRORS: 11:1: note: while in macro instantiation
+// CHECK-ERRORS-NEXT: .test1
+// CHECK-ERRORS-NEXT: ^
+
+.macro test2 _a
+.byte \_a
+.endm
+// CHECK: .byte 10
+test2 10
+
+.macro test3 _a _b _c
+.ascii "\_a \_b \_c \\_c"
+.endm
+
+// CHECK: .ascii "1 2 3 \003"
+test3 1, 2, 3
+
+// CHECK: .ascii "1 2 3 \003"
+test3 1, 2 3
+
+.macro test3_prime _a _b _c
+.ascii "\_a \_b \_c"
+.endm
+
+// CHECK: .ascii "1 (23) "
+test3_prime 1, (2 3)
+
+// CHECK: .ascii "1 (23) "
+test3_prime 1 (2 3)
+
+// CHECK: .ascii "1 2 "
+test3_prime 1 2
+
+.macro test5 _a
+.globl \_a
+.endm
+
+// CHECK: .globl zed1
+test5 zed1
+
+.macro test6 $a
+.globl \$a
+.endm
+
+// CHECK: .globl zed2
+test6 zed2
+
+.macro test7 .a
+.globl \.a
+.endm
+
+// CHECK: .globl zed3
+test7 zed3
+
+.macro test8 _a, _b, _c
+.ascii "\_a,\_b,\_c"
+.endm
+
+.macro test9 _a _b _c
+.ascii "\_a \_b \_c"
+.endm
+
+// CHECK: .ascii "a,b,c"
+test8 a, b, c
+// CHECK: .ascii "%1,%2,%3"
+test8 %1 %2 %3 #a comment
+// CHECK: .ascii "x-y,z,1"
+test8 x - y z 1
+// CHECK: .ascii "1 2 3"
+test9 1, 2,3
+
+// CHECK: .ascii "1,2,3"
+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: ^
diff --git a/test/MC/AsmParser/macros.s b/test/MC/AsmParser/macros.s
deleted file mode 100644
index b1cb851..0000000
--- a/test/MC/AsmParser/macros.s
+++ /dev/null
@@ -1,93 +0,0 @@
-// RUN: not llvm-mc -triple i386-unknown-unknown %s 2> %t.err | FileCheck %s
-// RUN: FileCheck --check-prefix=CHECK-ERRORS %s < %t.err
-
-.macro .test0
-.macrobody0
-.endmacro
-.macro .test1
-.test0
-.endmacro
-
-.test1
-// CHECK-ERRORS: <instantiation>:1:1: error: unknown directive
-// CHECK-ERRORS-NEXT: macrobody0
-// CHECK-ERRORS-NEXT: ^
-// CHECK-ERRORS: <instantiation>:1:1: note: while in macro instantiation
-// CHECK-ERRORS-NEXT: .test0
-// CHECK-ERRORS-NEXT: ^
-// CHECK-ERRORS: 11:1: note: while in macro instantiation
-// CHECK-ERRORS-NEXT: .test1
-// CHECK-ERRORS-NEXT: ^
-
-.macro test2
-.byte $0
-.endmacro
-test2 10
-
-.macro test3
-.globl "$0 $1 $2 $$3 $n"
-.endmacro
-
-// CHECK: .globl "1 (23) $3 2"
-test3 1, (2 3)
-
-// CHECK: .globl "1 2 $3 2"
-test3 1 2
-
-.macro test4
-.globl "$0 -- $1"
-.endmacro
-
-// CHECK: .globl "(ab)(,)) -- (cd)"
-test4 (a b)(,)),(cd)
-
-// CHECK: .globl "(ab)(,)) -- (cd)"
-test4 (a b)(,)),(cd)
-
-.macro test5 _a
-.globl "\_a"
-.endm
-
-// CHECK: .globl zed1
-test5 zed1
-
-.macro test6 $a
-.globl "\$a"
-.endm
-
-// CHECK: .globl zed2
-test6 zed2
-
-.macro test7 .a
-.globl "\.a"
-.endm
-
-// CHECK: .globl zed3
-test7 zed3
-
-.macro test8 _a, _b, _c
-.globl "\_a,\_b,\_c"
-.endmacro
-
-.macro test9 _a _b _c
-.globl "\_a \_b \_c"
-.endmacro
-
-// CHECK: .globl "a,b,c"
-test8 a, b, c
-// CHECK: .globl "%1,%2,%3"
-test8 %1 %2 %3 #a comment
-// CHECK: .globl "x-y,z,1"
-test8 x - y z 1
-// CHECK: .globl "1 2 3"
-test9 1, 2,3
-
-test8 1,2 3
-// CHECK-ERRORS: error: macro argument '_c' is missing
-// CHECK-ERRORS-NEXT: test8 1,2 3
-// CHECK-ERRORS-NEXT: ^
-
-test8 1 2, 3
-// CHECK-ERRORS: error: expected ' ' for macro argument separator
-// CHECK-ERRORS-NEXT:test8 1 2, 3
-// CHECK-ERRORS-NEXT: ^