1@ RUN: not llvm-mc %s -triple thumbv7-linux-gnueabi -filetype=obj -o /dev/null 2>&1 | FileCheck %s
2
3// Thumb2 unconditional branch has a range of +- 16 Megabytes. The
4// conditional branch has a range of +- 1 Megabyte. We should give
5// an error message if we evaluate the expression at assembly
6// time and it is out of range.
7
8        .syntax unified
9        .thumb
10        b.w end
11        .space 0xfffffe
12end:
13        b.w end2
14        .space 0xfffffe
15        .global end2
16end2:
17
18// branch to arm function uses relocation
19        b.w end3
20        .space 0x1000000
21        .global end3
22        .type end3, %function
23        .arm
24end3:   bx lr
25        .thumb
26
27// branch to thumb function is resolved at assembly time
28// CHECK-NOT: error
29// CHECK: [[@LINE+2]]:{{[0-9]}}: error: Relocation out of range
30// CHECK-LABEL: b.w end4
31        b.w end4
32        .space 0x1000000
33        .thumb_func
34end4:
35
36        beq.w end5
37        .space 0xffffc
38end5:
39
40// conditional branch to arm function uses relocation
41        beq.w end6
42        .arm
43        .type end6, %function
44        .space 0x100000
45end6:   bx lr
46        .thumb
47
48// conditional branch to thumb function resolved at assembly time
49// CHECK-NOT: error
50// CHECK: [[@LINE+2]]:{{[0-9]}}: error: Relocation out of range
51// CHECK-LABEL: beq.w end7
52        beq.w end7
53        .space 0x100000
54end7:
55
56start:
57        .space 0xfffffc
58        b.w start
59
60        .arm
61        .global start2
62        .type start2, %function
63start2:
64        .space 0x1000000
65        .thumb
66// branch to arm function uses relocation
67        b.w start2
68
69start3:
70        .space 0x1000000
71// branch to thumb function resolved at assembly time
72// CHECK-NOT: error
73// CHECK: [[@LINE+2]]:{{[0-9]}}: error: Relocation out of range
74// CHECK-LABEL: b.w start3
75        b.w start3
76
77start4:
78        .space 0xffffc
79        b.w start4
80
81        .arm
82        .global start5
83        .type start5, %function
84start5:
85        .space 0x100000
86        .thumb
87// conditional branch to arm function uses relocation
88        beq.w start5
89
90start6:
91        .space 0x100000
92// branch to thumb function resolved at assembly time
93// CHECK-NOT: error
94// CHECK: [[@LINE+2]]:{{[0-9]}}: error: Relocation out of range
95// CHECK-LABEL: beq.w start6
96        beq.w start6
97
98start7:
99// branch to thumb function resolved at assembly time
100// CHECK: [[#@LINE+1]]:{{[0-9]}}: error: Relocation out of range
101        b.w start8 - start7 + 0x1000000
102start8:
103