1 RUN: FileCheck --input-file %s %s
3 ; We use CHECK-NEXT directives to force a match on all lines with digits.
5 ; Numeric variable definition without spaces.
8 CHECK-LABEL: DEF NO SPC
11 ; Numeric variable definition with different spacing.
17 CHECK-NEXT: [[# VAR1a:]]
18 CHECK-NEXT: [[# VAR1b :]]
19 CHECK-NEXT: [[# VAR1c : ]]
21 ; Numeric variable redefinition.
25 CHECK-NEXT: [[#VAR1:]]
27 ; Numeric expressions using variables defined on other lines without spaces.
37 CHECK-NEXT: [[#VAR1+1]]
38 CHECK-NEXT: [[#VAR1-1]]
39 CHECK-NEXT: [[#VAR1a]]
40 CHECK-NEXT: [[#VAR1b]]
41 CHECK-NEXT: [[#VAR1c]]
43 ; Numeric expressions using variables defined on other lines with different
57 CHECK-NEXT: [[# VAR1]]
58 CHECK-NEXT: [[# VAR1 ]]
59 CHECK-NEXT: [[# VAR1+1]]
60 CHECK-NEXT: [[# VAR1 +1]]
61 CHECK-NEXT: [[# VAR1 + 1]]
62 CHECK-NEXT: [[# VAR1 + 1 ]]
63 CHECK-NEXT: [[# VAR1-1]]
64 CHECK-NEXT: [[# VAR1 -1]]
65 CHECK-NEXT: [[# VAR1 - 1]]
66 CHECK-NEXT: [[# VAR1 - 1 ]]
68 ; Numeric expressions using variables defined on other lines and an immediate
69 ; interpreted as an unsigned value.
70 ; Note: 9223372036854775819 = 0x8000000000000000 + 11
71 ; 9223372036854775808 = 0x8000000000000000
74 CHECK-LABEL: USE UNSIGNED IMM
75 CHECK-NEXT: [[#VAR1+9223372036854775808]]
77 ; Numeric expressions using more than one variable defined on other lines.
81 CHECK-LABEL: USE MULTI VAR
82 CHECK-NEXT: [[#VAR2:]]
83 CHECK-NEXT: [[#VAR1+VAR2]]
85 ; Numeric expression using a variable defined from a numeric expression.
89 ; CHECK-LABEL: DEF EXPR GOOD MATCH
90 ; CHECK-NEXT: [[# VAR42:VAR1+31]]
91 ; CHECK-NEXT: [[# VAR42-1]]
93 ; Empty numeric expression.
96 ; CHECK-LABEL: EMPTY NUM EXPR
97 ; CHECK-NEXT: foo [[#]] bar
99 ; Numeric expression using undefined variables.
100 RUN: not FileCheck --check-prefix UNDEF-USE --input-file %s %s 2>&1 \
101 RUN: | FileCheck --strict-whitespace --check-prefix UNDEF-USE-MSG %s
105 UNDEF-USE-LABEL: UNDEF VAR USE
106 UNDEF-USE-NEXT: UNDEFVAR: [[#UNDEFVAR1+UNDEFVAR2]]
107 UNDEF-USE-MSG: numeric-expression.txt:[[#@LINE-1]]:17: error: {{U}}NDEF-USE-NEXT: expected string not found in input
108 UNDEF-USE-MSG-NEXT: {{U}}NDEF-USE-NEXT: UNDEFVAR: {{\[\[#UNDEFVAR1\+UNDEFVAR2\]\]}}
109 UNDEF-USE-MSG-NEXT: {{^}} ^{{$}}
110 UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-6]]:1: note: scanning from here
111 UNDEF-USE-MSG-NEXT: UNDEFVAR: 11
112 UNDEF-USE-MSG-NEXT: {{^}}^{{$}}
113 UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-9]]:1: note: uses undefined variable(s): "UNDEFVAR1" "UNDEFVAR2"
114 UNDEF-USE-MSG-NEXT: UNDEFVAR: 11
115 UNDEF-USE-MSG-NEXT: {{^}}^{{$}}
117 ; Numeric expression with unsupported operator.
118 RUN: not FileCheck -D#NUMVAR=10 --check-prefix INVAL-OP --input-file %s %s 2>&1 \
119 RUN: | FileCheck --strict-whitespace --check-prefix INVAL-OP-MSG %s
123 INVAL-OP-LABEL: INVALID OPERATOR
124 INVAL-OP-NEXT: NUMVAR*2: [[#NUMVAR*2]]
125 INVAL-OP-MSG: numeric-expression.txt:[[#@LINE-1]]:35: error: unsupported operation '*'
126 INVAL-OP-MSG-NEXT: {{I}}NVAL-OP-NEXT: NUMVAR*2: {{\[\[#NUMVAR\*2\]\]}}
127 INVAL-OP-MSG-NEXT: {{^}} ^{{$}}
129 ; Name conflict between Numeric variable definition and string variable
130 ; definition whether from the command-line or input text.
131 RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT1,CONFLICT2 --input-file %s %s 2>&1 \
132 RUN: | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s
133 RUN: not FileCheck -D#NUMVAR=42 --check-prefixes CONFLICT,CONFLICT2 --input-file %s %s 2>&1 \
134 RUN: | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s
135 RUN: not FileCheck -D#NUMVAR=42 -DNUMVAR=foobar --check-prefix CONFLICT --input-file %s %s 2>&1 \
136 RUN: | FileCheck --strict-whitespace --check-prefix CLI-STR-CONFLICT %s
137 RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT3,CONFLICT4 --input-file %s %s 2>&1 \
138 RUN: | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s
139 RUN: not FileCheck -DSTRVAR=foobar --check-prefixes CONFLICT,CONFLICT4 --input-file %s %s 2>&1 \
140 RUN: | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s
141 RUN: not FileCheck -DSTRVAR=foobar -D#STRVAR=42 --check-prefix CONFLICT --input-file %s %s 2>&1 \
142 RUN: | FileCheck --strict-whitespace --check-prefix CLI-NUM-CONFLICT %s
144 STRVAR NUMVAR CONFLICT
148 CONFLICT-LABEL: STRVAR NUMVAR CONFLICT
149 CONFLICT1-NEXT: redef1 [[#NUMVAR:]]
150 CONFLICT2: [[NUMVAR:foo.*]]
151 CONFLICT3: [[STRVAR:foo.*]]
152 CONFLICT4: redef2 [[#STRVAR:]]
153 INPUT-STR-CONFLICT: numeric-expression.txt:[[#@LINE-3]]:14: error: numeric variable with name 'NUMVAR' already exists
154 INPUT-STR-CONFLICT-NEXT: {{C}}ONFLICT2: {{\[\[NUMVAR:foo\.\*\]\]}}
155 INPUT-STR-CONFLICT-NEXT: {{^}} ^{{$}}
156 CLI-STR-CONFLICT: Global defines:2:19: error: numeric variable with name 'NUMVAR' already exists
157 CLI-STR-CONFLICT-NEXT: Global define #2: NUMVAR=foobar
158 CLI-STR-CONFLICT-NEXT: {{^}} ^{{$}}
159 INPUT-NUM-CONFLICT: numeric-expression.txt:[[#@LINE-7]]:22: error: string variable with name 'STRVAR' already exists
160 INPUT-NUM-CONFLICT-NEXT: CONFLICT4: redef2 {{\[\[#STRVAR:\]\]}}
161 INPUT-NUM-CONFLICT-NEXT: {{^}} ^{{$}}
162 CLI-NUM-CONFLICT: Global defines:2:45: error: string variable with name 'STRVAR' already exists
163 CLI-NUM-CONFLICT-NEXT: Global define #2: #STRVAR=42 (parsed as: {{\[\[#STRVAR:42\]\]}})
164 CLI-NUM-CONFLICT-NEXT: {{^}} ^{{$}}
166 ; Numeric variable definition with too big value.
167 RUN: not FileCheck --check-prefix BIGVAL --input-file %s %s 2>&1 \
168 RUN: | FileCheck --strict-whitespace --check-prefix BIGVAL-MSG %s
171 NUMVAR: 10000000000000000000000
172 BIGVAL-LABEL: BIG VALUE
173 BIGVAL-NEXT: NUMVAR: [[#NUMVAR:]]
174 BIGVAL-MSG: numeric-expression.txt:[[#@LINE-3]]:9: error: Unable to represent numeric value
175 BIGVAL-MSG-NEXT: {{N}}UMVAR: 10000000000000000000000
176 BIGVAL-MSG-NEXT: {{^}} ^{{$}}
178 ; Verify that when a variable is set to an expression the expression is still
180 RUN: not FileCheck --check-prefix DEF-EXPR-FAIL --input-file %s %s 2>&1 \
181 RUN: | FileCheck --strict-whitespace --check-prefix DEF-EXPR-FAIL-MSG %s
186 DEF-EXPR-FAIL-LABEL: DEF EXPR WRONG MATCH
187 DEF-EXPR-FAIL-NEXT: [[# VAR20:]]
188 DEF-EXPR-FAIL-NEXT: [[# VAR42: VAR20+22]]
189 DEF-EXPR-FAIL-MSG: numeric-expression.txt:[[#@LINE-1]]:21: error: {{D}}EF-EXPR-FAIL-NEXT: is not on the line after the previous match
190 DEF-EXPR-FAIL-MSG-NEXT: {{D}}EF-EXPR-FAIL-NEXT: {{\[\[# VAR42: VAR20\+22\]\]}}
191 DEF-EXPR-FAIL-MSG-NEXT: {{^}} ^{{$}}
193 ; Verify that using a numeric variable defined on the same line (whether from
194 ; input or from an expression) is rejected.
195 RUN: not FileCheck --check-prefix SAME-LINE-USE1 --input-file %s %s 2>&1 \
196 RUN: | FileCheck --strict-whitespace --check-prefix SAME-LINE-USE-MSG1 %s
197 RUN: not FileCheck --check-prefix SAME-LINE-USE2 --input-file %s %s 2>&1 \
198 RUN: | FileCheck --strict-whitespace --check-prefix SAME-LINE-USE-MSG2 %s
203 SAME-LINE-USE1-LABEL: SAME LINE USE
204 SAME-LINE-USE1-NEXT: [[#]]
205 SAME-LINE-USE1-NEXT: [[#VAR1:]] [[#VAR1+1]]
206 SAME-LINE-USE-MSG1: numeric-expression.txt:[[#@LINE-1]]:36: error: numeric variable 'VAR1' defined earlier in the same CHECK directive
207 SAME-LINE-USE-MSG1-NEXT: {{S}}AME-LINE-USE1-NEXT: {{\[\[#VAR1:\]\] \[\[#VAR1\+1\]\]}}
208 SAME-LINE-USE-MSG1-NEXT: {{^}} ^{{$}}
210 SAME-LINE-USE2-LABEL: SAME LINE USE
211 SAME-LINE-USE2-NEXT: [[#VAR1:]]
212 SAME-LINE-USE2-NEXT: [[#VAR2:VAR1+1]] [[#VAR2+1]]
213 SAME-LINE-USE-MSG2: numeric-expression.txt:[[#@LINE-1]]:42: error: numeric variable 'VAR2' defined earlier in the same CHECK directive
214 SAME-LINE-USE-MSG2-NEXT: {{S}}AME-LINE-USE2-NEXT: {{\[\[#VAR2:VAR1\+1\]\] \[\[#VAR2\+1\]\]}}
215 SAME-LINE-USE-MSG2-NEXT: {{^}} ^{{$}}