1RUN: FileCheck --input-file %s %s
2
3; We use CHECK-NEXT directives to force a match on all lines with digits.
4
5; Numeric variable definition without spaces.
6DEF NO SPC
711
8CHECK-LABEL: DEF NO SPC
9CHECK-NEXT: [[#VAR1:]]
10
11; Numeric variable definition with different spacing.
12DEF SPC
1311
1411
1511
16CHECK-LABEL: DEF SPC
17CHECK-NEXT: [[# VAR1a:]]
18CHECK-NEXT: [[# VAR1b :]]
19CHECK-NEXT: [[# VAR1c : ]]
20
21; Numeric expressions using variables defined on other lines without spaces.
22USE NO SPC
2311
2412
2510
2611
2711
2811
29CHECK-LABEL: USE
30CHECK-NEXT: [[#VAR1]]
31CHECK-NEXT: [[#VAR1+1]]
32CHECK-NEXT: [[#VAR1-1]]
33CHECK-NEXT: [[#VAR1a]]
34CHECK-NEXT: [[#VAR1b]]
35CHECK-NEXT: [[#VAR1c]]
36
37; Numeric expressions using variables defined on other lines with different
38; spacing.
39USE SPC
4011
4111
4212
4312
4412
4512
4610
4710
4810
4910
50CHECK-LABEL: USE SPC
51CHECK-NEXT: [[# VAR1]]
52CHECK-NEXT: [[# VAR1 ]]
53CHECK-NEXT: [[# VAR1+1]]
54CHECK-NEXT: [[# VAR1 +1]]
55CHECK-NEXT: [[# VAR1 + 1]]
56CHECK-NEXT: [[# VAR1 + 1 ]]
57CHECK-NEXT: [[# VAR1-1]]
58CHECK-NEXT: [[# VAR1 -1]]
59CHECK-NEXT: [[# VAR1 - 1]]
60CHECK-NEXT: [[# VAR1 - 1 ]]
61
62; Numeric expressions using variables defined on the command-line and an
63; immediate interpreted as an unsigned value.
64; Note: 9223372036854775819 = 0x8000000000000000 + 11
65;       9223372036854775808 = 0x8000000000000000
66USE UNSIGNED IMM
679223372036854775819
68CHECK-LABEL: USE UNSIGNED IMM
69CHECK-NEXT: [[#VAR1+9223372036854775808]]
70
71; Numeric expression using undefined variable.
72RUN: not FileCheck --check-prefix UNDEF-USE --input-file %s %s 2>&1 \
73RUN:   | FileCheck --strict-whitespace --check-prefix UNDEF-USE-MSG %s
74
75UNDEF VAR USE
76UNDEFVAR: 11
77UNDEF-USE-LABEL: UNDEF VAR USE
78UNDEF-USE-NEXT: UNDEFVAR: [[#UNDEFVAR]]
79UNDEF-USE-MSG: numeric-expression.txt:[[#@LINE-1]]:17: error: {{U}}NDEF-USE-NEXT: expected string not found in input
80UNDEF-USE-MSG-NEXT: {{U}}NDEF-USE-NEXT: UNDEFVAR: {{\[\[#UNDEFVAR\]\]}}
81UNDEF-USE-MSG-NEXT: {{^                \^$}}
82UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-6]]:1: note: scanning from here
83UNDEF-USE-MSG-NEXT: UNDEFVAR: 11
84UNDEF-USE-MSG-NEXT: {{^\^$}}
85UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-9]]:1: note: uses undefined variable "UNDEFVAR"
86UNDEF-USE-MSG-NEXT: UNDEFVAR: 11
87UNDEF-USE-MSG-NEXT: {{^\^$}}
88
89; Numeric expression with unsupported operator.
90RUN: not FileCheck -D#NUMVAR=10 --check-prefix INVAL-OP --input-file %s %s 2>&1 \
91RUN:   | FileCheck --strict-whitespace --check-prefix INVAL-OP-MSG %s
92
93INVALID OPERATOR
94NUMVAR*2: 22
95INVAL-OP-LABEL: INVALID OPERATOR
96INVAL-OP-NEXT: NUMVAR*2: [[#NUMVAR*2]]
97INVAL-OP-MSG: numeric-expression.txt:[[#@LINE-1]]:35: error: unsupported operation '*'
98INVAL-OP-MSG-NEXT: {{I}}NVAL-OP-NEXT: NUMVAR*2: {{\[\[#NUMVAR\*2\]\]}}
99INVAL-OP-MSG-NEXT: {{^                                  \^$}}
100
101; Name conflict between Numeric variable definition and string variable
102; definition whether from the command-line or input text.
103RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT1,CONFLICT2 --input-file %s %s 2>&1 \
104RUN:   | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s
105RUN: not FileCheck -D#NUMVAR=42 --check-prefixes CONFLICT,CONFLICT2 --input-file %s %s 2>&1 \
106RUN:   | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s
107RUN: not FileCheck -D#NUMVAR=42 -DNUMVAR=foobar --check-prefix CONFLICT --input-file %s %s 2>&1 \
108RUN:   | FileCheck --strict-whitespace --check-prefix CLI-STR-CONFLICT %s
109RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT3,CONFLICT4 --input-file %s %s 2>&1 \
110RUN:   | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s
111RUN: not FileCheck -DSTRVAR=foobar --check-prefixes CONFLICT,CONFLICT4 --input-file %s %s 2>&1 \
112RUN:   | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s
113RUN: not FileCheck -DSTRVAR=foobar -D#STRVAR=42 --check-prefix CONFLICT --input-file %s %s 2>&1 \
114RUN:   | FileCheck --strict-whitespace --check-prefix CLI-NUM-CONFLICT %s
115
116STRVAR NUMVAR CONFLICT
117redef1 42
118foobar
119redef2 42
120CONFLICT-LABEL: STRVAR NUMVAR CONFLICT
121CONFLICT1-NEXT: redef1 [[#NUMVAR:]]
122CONFLICT2: [[NUMVAR:foo.*]]
123CONFLICT3: [[STRVAR:foo.*]]
124CONFLICT4: redef2 [[#STRVAR:]]
125INPUT-STR-CONFLICT: numeric-expression.txt:[[#@LINE-3]]:14: error: numeric variable with name 'NUMVAR' already exists
126INPUT-STR-CONFLICT-NEXT: {{C}}ONFLICT2: {{\[\[NUMVAR:foo\.\*\]\]}}
127INPUT-STR-CONFLICT-NEXT: {{^             \^$}}
128CLI-STR-CONFLICT: Global defines:2:19: error: numeric variable with name 'NUMVAR' already exists
129CLI-STR-CONFLICT-NEXT: Global define #2: NUMVAR=foobar
130CLI-STR-CONFLICT-NEXT: {{^                  \^$}}
131INPUT-NUM-CONFLICT: numeric-expression.txt:[[#@LINE-7]]:22: error: string variable with name 'STRVAR' already exists
132INPUT-NUM-CONFLICT-NEXT: CONFLICT4: redef2 {{\[\[#STRVAR:\]\]}}
133INPUT-NUM-CONFLICT-NEXT: {{^                     \^$}}
134CLI-NUM-CONFLICT: Global defines:2:20: error: string variable with name 'STRVAR' already exists
135CLI-NUM-CONFLICT-NEXT: Global define #2: #STRVAR=42
136CLI-NUM-CONFLICT-NEXT: {{^                   \^$}}
137
138; Numeric variable definition with too big value.
139RUN: not FileCheck --check-prefix BIGVAL --input-file %s %s 2>&1 \
140RUN:   | FileCheck --strict-whitespace --check-prefix BIGVAL-MSG %s
141
142BIG VALUE
143NUMVAR: 10000000000000000000000
144BIGVAL-LABEL: BIG VALUE
145BIGVAL-NEXT: NUMVAR: [[#NUMVAR:]]
146BIGVAL-MSG: numeric-expression.txt:[[#@LINE-3]]:9: error: Unable to represent numeric value
147BIGVAL-MSG-NEXT: {{N}}UMVAR: 10000000000000000000000
148BIGVAL-MSG-NEXT: {{^        \^$}}
149