xref: /llvm-project/llvm/test/MC/AsmParser/assembler-expressions.s (revision 507efbcce03d8c2c5dbea3028bc39f02c88fea79)
1# RUN: not llvm-mc -triple x86_64-unknown-unknown %s 2>&1 | FileCheck %s --check-prefix=ASM-ERR --implicit-check-not=error:
2# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -j .data  -s - | FileCheck %s --check-prefix=OBJDATA
3# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s | llvm-objdump -j .text -s - | FileCheck %s --check-prefix=OBJTEXT
4.data
5
6# OBJDATA: Contents of section .data
7# OBJDATA-NEXT: 0000 aa01aa05 06000000 08ff
8
9foo1:
10# ASM-ERR: :[[#@LINE+1]]:5: error: expected absolute expression
11.if . - foo1 == 0
12    .byte 0xaa
13.else
14    .byte 0x00
15.endif
16
17foo2:
18    .byte 1
19# ASM-ERR: :[[#@LINE+1]]:5: error: expected absolute expression
20.if foo2 - . == -1
21    .byte 0xaa
22.else
23    .byte 0x00
24.endif
25
26foo3:
27    .byte 5
28# ASM-ERR: [[@LINE+1]]:5: error: expected absolute expression
29.if . - foo3 == 1
30   .byte 6
31.else
32   .byte 7
33.endif
34
35foo4:
36.byte 0
37.space 2
38# ASM-ERR: :[[#@LINE+1]]:5: error: expected absolute expression
39.if . - foo4 == 3
40    .byte 8
41.else
42    .byte 9
43.endif
44
45.byte 0xff
46
47# nop is a fixed size instruction so this should pass.
48
49# OBJTEXT: Contents of section .text
50# OBJTEXT-NEXT: 0000 909090ff 34250000 00009090 90785634
51# OBJTEXT-NEXT: 0010 12785634 1290
52
53.text
54text1:
55# ASM-ERR: [[@LINE+1]]:5: error: expected absolute expression
56.if . - text1 == 0
57	nop
58.endif
59
60text2:
61        nop
62# ASM-ERR: [[@LINE+1]]:5: error: expected absolute expression
63.if . - text2 == 1
64	nop
65.else
66	ret
67.endif
68	push gs
69	nop
70	nop
71	nop
72# No additional errors.
73#
74# ASM-ERR-NOT: {{[0-9]+}}:{{[0-9]+}}: error:
75
76
77text3:
78	.long 0x12345678
79text4:
80	.fill (text4-text3)/4, 4, 0x12345678
81	nop
82
83
84
85
86
87
88