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 with default matching format without spaces. 6DEF DEFAULT FMT NO SPC 710 8CHECK-LABEL: DEF DEFAULT FMT NO SPC 9CHECK-NEXT: [[#VAR1:]] 10 11; Numeric variable definition with default matching format with different 12; spacing. 13DEF DEFAULT FMT SPC 1411 1511 1611 17CHECK-LABEL: DEF DEFAULT FMT SPC 18CHECK-NEXT: [[# VAR1a:]] 19CHECK-NEXT: [[# VAR1b :]] 20CHECK-NEXT: [[# VAR1c : ]] 21 22; Numeric variable redefinition. 23REDEF NO SPC 2411 25CHECK-LABEL: REDEF 26CHECK-NEXT: [[#VAR1:]] 27 28; Numeric variable definition with explicit matching format. 29DEF FMT 30c 31D 32CHECK-LABEL: DEF FMT 33CHECK-NEXT: [[#%x,VAR2:]] 34CHECK-NEXT: [[#%X,VAR3:]] 35 36; Numeric variable definition with explicit matching format with different 37; spacing. 38DEF FMT SPC 39c 40CHECK-LABEL: DEF FMT SPC 41CHECK-NEXT: [[# %x , VAR2a : ]] 42 43; Numeric variable definition with unsupported matching format. 44RUN: not FileCheck --check-prefixes ERR,INVALID-FMT-SPEC1 --input-file %s %s 2>&1 \ 45RUN: | FileCheck --check-prefix INVALID-FMT-SPEC-MSG1 --strict-whitespace %s 46RUN: not FileCheck --check-prefixes ERR,INVALID-FMT-SPEC2 --input-file %s %s 2>&1 \ 47RUN: | FileCheck --check-prefix INVALID-FMT-SPEC-MSG2 --strict-whitespace %s 48 49DEF INVALID FMT 50INVVAR1=a 51INVVAR2=11 52ERR-LABEL: DEF INVALID FMT 53INVALID-FMT-SPEC1-NEXT: INVVAR1=[[#%c,INVVAR1:]] 54INVALID-FMT-SPEC2-NEXT: INVVAR2=[[#%hhd,INVVAR2:]] 55INVALID-FMT-SPEC-MSG1: numeric-expression.txt:[[#@LINE-2]]:37: error: invalid format specifier in expression 56INVALID-FMT-SPEC-MSG1-NEXT: {{I}}NVALID-FMT-SPEC1-NEXT: INVVAR1={{\[\[#%c,INVVAR1:\]\]}} 57INVALID-FMT-SPEC-MSG1-NEXT: {{^}} ^{{$}} 58INVALID-FMT-SPEC-MSG2: numeric-expression.txt:[[#@LINE-4]]:37: error: invalid format specifier in expression 59INVALID-FMT-SPEC-MSG2-NEXT: {{I}}NVALID-FMT-SPEC2-NEXT: INVVAR2={{\[\[#%hhd,INVVAR2:\]\]}} 60INVALID-FMT-SPEC-MSG2-NEXT: {{^}} ^{{$}} 61 62; Numeric expressions in explicit matching format and default matching rule using 63; variables defined on other lines without spaces. 64USE DEF FMT IMPL MATCH 6511 6612 6710 68c 69d 70b 711a 72D 73E 74C 751B 7611 7711 7811 79c 80c 81c 82c 83c 84CHECK-LABEL: USE DEF FMT IMPL MATCH 85CHECK-NEXT: [[#%u,VAR1]] 86CHECK-NEXT: [[#%u,VAR1+1]] 87CHECK-NEXT: [[#%u,VAR1-1]] 88CHECK-NEXT: [[#%x,VAR2]] 89CHECK-NEXT: [[#%x,VAR2+1]] 90CHECK-NEXT: [[#%x,VAR2-1]] 91CHECK-NEXT: [[#%x,VAR2+14]] 92CHECK-NEXT: [[#%X,VAR3]] 93CHECK-NEXT: [[#%X,VAR3+1]] 94CHECK-NEXT: [[#%X,VAR3-1]] 95CHECK-NEXT: [[#%X,VAR3+14]] 96CHECK-NEXT: [[#%u,VAR1a]] 97CHECK-NEXT: [[#%u,VAR1b]] 98CHECK-NEXT: [[#%u,VAR1c]] 99CHECK-NEXT: [[#%x,VAR2a]] 100 101; Numeric expressions in explicit matching format and default matching rule using 102; variables defined on other lines with different spacing. 103USE EXPL FMT IMPL MATCH SPC 10411 10511 10611 10712 10812 10912 11012 11112 11212 11310 11410 11510 11610 11710 11810 119CHECK-LABEL: USE EXPL FMT IMPL MATCH SPC 120CHECK-NEXT: [[#%u, VAR1]] 121CHECK-NEXT: [[# %u, VAR1]] 122CHECK-NEXT: [[# %u, VAR1 ]] 123CHECK-NEXT: [[#%u, VAR1+1]] 124CHECK-NEXT: [[# %u, VAR1+1]] 125CHECK-NEXT: [[# %u , VAR1+1]] 126CHECK-NEXT: [[# %u , VAR1 +1]] 127CHECK-NEXT: [[# %u , VAR1 + 1]] 128CHECK-NEXT: [[# %u , VAR1 + 1 ]] 129CHECK-NEXT: [[#%u, VAR1-1]] 130CHECK-NEXT: [[# %u, VAR1-1]] 131CHECK-NEXT: [[# %u , VAR1-1]] 132CHECK-NEXT: [[# %u , VAR1 -1]] 133CHECK-NEXT: [[# %u , VAR1 - 1]] 134CHECK-NEXT: [[# %u , VAR1 - 1 ]] 135 136; Numeric expressions in implicit matching format and default matching rule using 137; variables defined on other lines. 138USE IMPL FMT IMPL MATCH 13911 14012 14110 142c 143d 144b 1451a 146D 147E 148C 1491B 150CHECK-LABEL: USE IMPL FMT IMPL MATCH 151CHECK-NEXT: [[#VAR1]] 152CHECK-NEXT: [[#VAR1+1]] 153CHECK-NEXT: [[#VAR1-1]] 154CHECK-NEXT: [[#VAR2]] 155CHECK-NEXT: [[#VAR2+1]] 156CHECK-NEXT: [[#VAR2-1]] 157CHECK-NEXT: [[#VAR2+14]] 158CHECK-NEXT: [[#VAR3]] 159CHECK-NEXT: [[#VAR3+1]] 160CHECK-NEXT: [[#VAR3-1]] 161CHECK-NEXT: [[#VAR3+14]] 162 163; Numeric expressions using variables defined on other lines and an immediate 164; interpreted as an unsigned value. 165; Note: 9223372036854775819 = 0x8000000000000000 + 11 166USE IMPL FMT IMPL MATCH UNSIGNED IMM 1679223372036854775819 168CHECK-LABEL: USE IMPL FMT IMPL MATCH UNSIGNED IMM 169CHECK-NEXT: [[#VAR1+0x8000000000000000]] 170 171; Numeric expressions with matching format overriding the implicit format of 172; variables defined on other lines. 173USE CONV FMT IMPL MATCH 174b 175B 17612 17713 178CHECK-LABEL: USE CONV FMT IMPL MATCH 179CHECK-NEXT: [[# %x, VAR1]] 180CHECK-NEXT: [[# %X, VAR1]] 181CHECK-NEXT: [[# %u, VAR2]] 182CHECK-NEXT: [[# %u, VAR3]] 183 184; Conflicting implicit format. 185RUN: not FileCheck --check-prefixes CHECK,FMT-CONFLICT --input-file %s %s 2>&1 \ 186RUN: | FileCheck --strict-whitespace --check-prefix FMT-CONFLICT-MSG %s 187 188VAR USE IMPL FMT CONFLICT 18923 190FMT-CONFLICT-LABEL: VAR USE IMPL FMT CONFLICT 191FMT-CONFLICT-NEXT: [[#VAR1 + VAR2]] 192FMT-CONFLICT-MSG: numeric-expression.txt:[[#@LINE-1]]:23: error: variables with conflicting format specifier: need an explicit one 193FMT-CONFLICT-MSG-NEXT: {{F}}MT-CONFLICT-NEXT: {{\[\[#VAR1 \+ VAR2\]\]}} 194FMT-CONFLICT-MSG-NEXT: {{^ \^$}} 195 196; Explicitly specified format can override conflicting implicit formats. 197VAR USE IMPL OVERRIDE FMT CONFLICT 19823 199CHECK-LABEL: VAR USE IMPL OVERRIDE FMT CONFLICT 200CHECK-NEXT: [[# %u, VAR1 + VAR2]] 201 202; Numeric expressions using more than one variable defined on other lines. 203USE MULTI VAR 20431 20542 206CHECK-LABEL: USE MULTI VAR 207CHECK-NEXT: [[#VAR4:]] 208CHECK-NEXT: [[#VAR1+VAR4]] 209 210; Numeric expression using a variable defined from a numeric expression. 211DEF EXPR GOOD MATCH 21242 21341 214; CHECK-LABEL: DEF EXPR GOOD MATCH 215; CHECK-NEXT: [[# VAR42:VAR1+31]] 216; CHECK-NEXT: [[# VAR42-1]] 217 218; Empty numeric expression. 219EMPTY NUM EXPR 220foo 104 bar 221CHECK-LABEL: EMPTY NUM EXPR 222CHECK-NEXT: foo [[#]] bar 223 224; Numeric expression using undefined variables. 225RUN: %ProtectFileCheckOutput \ 226RUN: not FileCheck --check-prefix UNDEF-USE --input-file %s %s 2>&1 \ 227RUN: | FileCheck --strict-whitespace --check-prefix UNDEF-USE-MSG %s 228 229UNDEF VAR USE 230UNDEFVAR: 11 231UNDEF-USE-LABEL: UNDEF VAR USE 232UNDEF-USE-NEXT: UNDEFVAR: [[#UNDEFVAR1+UNDEFVAR2]] 233UNDEF-USE-MSG: numeric-expression.txt:[[#@LINE-1]]:17: error: {{U}}NDEF-USE-NEXT: expected string not found in input 234UNDEF-USE-MSG-NEXT: {{U}}NDEF-USE-NEXT: UNDEFVAR: {{\[\[#UNDEFVAR1\+UNDEFVAR2\]\]}} 235UNDEF-USE-MSG-NEXT: {{^}} ^{{$}} 236UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-6]]:1: note: scanning from here 237UNDEF-USE-MSG-NEXT: UNDEFVAR: 11 238UNDEF-USE-MSG-NEXT: {{^}}^{{$}} 239UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-9]]:1: note: uses undefined variable(s): "UNDEFVAR1" "UNDEFVAR2" 240UNDEF-USE-MSG-NEXT: UNDEFVAR: 11 241UNDEF-USE-MSG-NEXT: {{^}}^{{$}} 242 243; Numeric expression with unsupported operator. 244RUN: %ProtectFileCheckOutput \ 245RUN: not FileCheck -D#NUMVAR=10 --check-prefix INVAL-OP \ 246RUN: --input-file %s %s 2>&1 \ 247RUN: | FileCheck --strict-whitespace --check-prefix INVAL-OP-MSG %s 248 249INVALID OPERATOR 250NUMVAR*2: 22 251INVAL-OP-LABEL: INVALID OPERATOR 252INVAL-OP-NEXT: NUMVAR*2: [[#NUMVAR*2]] 253INVAL-OP-MSG: numeric-expression.txt:[[#@LINE-1]]:35: error: unsupported operation '*' 254INVAL-OP-MSG-NEXT: {{I}}NVAL-OP-NEXT: NUMVAR*2: {{\[\[#NUMVAR\*2\]\]}} 255INVAL-OP-MSG-NEXT: {{^}} ^{{$}} 256 257; Name conflict between Numeric variable definition and string variable 258; definition whether from the command-line or input text. 259RUN: %ProtectFileCheckOutput \ 260RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT1,CONFLICT2 \ 261RUN: --input-file %s %s 2>&1 \ 262RUN: | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s 263RUN: %ProtectFileCheckOutput \ 264RUN: not FileCheck -D#NUMVAR=42 --check-prefixes CONFLICT,CONFLICT2 \ 265RUN: --input-file %s %s 2>&1 \ 266RUN: | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s 267RUN: %ProtectFileCheckOutput \ 268RUN: not FileCheck -D#NUMVAR=42 -DNUMVAR=foobar --check-prefix CONFLICT \ 269RUN: --input-file %s %s 2>&1 \ 270RUN: | FileCheck --strict-whitespace --check-prefix CLI-STR-CONFLICT %s 271RUN: %ProtectFileCheckOutput \ 272RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT3,CONFLICT4 \ 273RUN: --input-file %s %s 2>&1 \ 274RUN: | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s 275RUN: %ProtectFileCheckOutput \ 276RUN: not FileCheck -DSTRVAR=foobar --check-prefixes CONFLICT,CONFLICT4 \ 277RUN: --input-file %s %s 2>&1 \ 278RUN: | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s 279RUN: %ProtectFileCheckOutput \ 280RUN: not FileCheck -DSTRVAR=foobar -D#STRVAR=42 --check-prefix CONFLICT \ 281RUN: --input-file %s %s 2>&1 \ 282RUN: | FileCheck --strict-whitespace --check-prefix CLI-NUM-CONFLICT %s 283 284STRVAR NUMVAR CONFLICT 285redef1 42 286foobar 287redef2 42 288CONFLICT-LABEL: STRVAR NUMVAR CONFLICT 289CONFLICT1-NEXT: redef1 [[#NUMVAR:]] 290CONFLICT2: [[NUMVAR:foo.*]] 291CONFLICT3: [[STRVAR:foo.*]] 292CONFLICT4: redef2 [[#STRVAR:]] 293INPUT-STR-CONFLICT: numeric-expression.txt:[[#@LINE-3]]:14: error: numeric variable with name 'NUMVAR' already exists 294INPUT-STR-CONFLICT-NEXT: {{C}}ONFLICT2: {{\[\[NUMVAR:foo\.\*\]\]}} 295INPUT-STR-CONFLICT-NEXT: {{^}} ^{{$}} 296CLI-STR-CONFLICT: Global defines:2:19: error: numeric variable with name 'NUMVAR' already exists 297CLI-STR-CONFLICT-NEXT: Global define #2: NUMVAR=foobar 298CLI-STR-CONFLICT-NEXT: {{^}} ^{{$}} 299INPUT-NUM-CONFLICT: numeric-expression.txt:[[#@LINE-7]]:22: error: string variable with name 'STRVAR' already exists 300 INPUT-NUM-CONFLICT-NEXT: CONFLICT4: redef2 {{\[\[#STRVAR:\]\]}} 301INPUT-NUM-CONFLICT-NEXT: {{^}} ^{{$}} 302CLI-NUM-CONFLICT: Global defines:2:45: error: string variable with name 'STRVAR' already exists 303 CLI-NUM-CONFLICT-NEXT: Global define #2: #STRVAR=42 (parsed as: {{\[\[#STRVAR:42\]\]}}) 304CLI-NUM-CONFLICT-NEXT: {{^}} ^{{$}} 305 306; Numeric variable definition with too big value. 307RUN: %ProtectFileCheckOutput \ 308RUN: not FileCheck --check-prefix BIGVAL --input-file %s %s 2>&1 \ 309RUN: | FileCheck --strict-whitespace --check-prefix BIGVAL-MSG %s 310 311BIG VALUE 312NUMVAR: 10000000000000000000000 313BIGVAL-LABEL: BIG VALUE 314BIGVAL-NEXT: NUMVAR: [[#NUMVAR:]] 315BIGVAL-MSG: numeric-expression.txt:[[#@LINE-3]]:9: error: unable to represent numeric value 316 BIGVAL-MSG-NEXT: {{N}}UMVAR: 10000000000000000000000 317BIGVAL-MSG-NEXT: {{^}} ^{{$}} 318 319; Verify that when a variable is set to an expression the expression is still 320; checked. 321RUN: %ProtectFileCheckOutput \ 322RUN: not FileCheck --check-prefix DEF-EXPR-FAIL --input-file %s %s 2>&1 \ 323RUN: | FileCheck --strict-whitespace --check-prefix DEF-EXPR-FAIL-MSG %s 324 325DEF EXPR WRONG MATCH 32620 32743 328DEF-EXPR-FAIL-LABEL: DEF EXPR WRONG MATCH 329DEF-EXPR-FAIL-NEXT: [[# VAR20:]] 330DEF-EXPR-FAIL-NEXT: [[# VAR42: VAR20+22]] 331DEF-EXPR-FAIL-MSG: numeric-expression.txt:[[#@LINE-1]]:21: error: {{D}}EF-EXPR-FAIL-NEXT: is not on the line after the previous match 332DEF-EXPR-FAIL-MSG-NEXT: {{D}}EF-EXPR-FAIL-NEXT: {{\[\[# VAR42: VAR20\+22\]\]}} 333DEF-EXPR-FAIL-MSG-NEXT: {{^}} ^{{$}} 334 335; Verify that using a numeric variable defined on the same line (whether from 336; input or from an expression) is rejected. 337RUN: %ProtectFileCheckOutput \ 338RUN: not FileCheck --check-prefix SAME-LINE-USE1 --input-file %s %s 2>&1 \ 339RUN: | FileCheck --strict-whitespace --check-prefix SAME-LINE-USE-MSG1 %s 340RUN: %ProtectFileCheckOutput \ 341RUN: not FileCheck --check-prefix SAME-LINE-USE2 --input-file %s %s 2>&1 \ 342RUN: | FileCheck --strict-whitespace --check-prefix SAME-LINE-USE-MSG2 %s 343 344SAME LINE USE 3453 3464 5 347SAME-LINE-USE1-LABEL: SAME LINE USE 348SAME-LINE-USE1-NEXT: [[#]] 349SAME-LINE-USE1-NEXT: [[#VAR1:]] [[#VAR1+1]] 350SAME-LINE-USE-MSG1: numeric-expression.txt:[[#@LINE-1]]:36: error: numeric variable 'VAR1' defined earlier in the same CHECK directive 351SAME-LINE-USE-MSG1-NEXT: {{S}}AME-LINE-USE1-NEXT: {{\[\[#VAR1:\]\] \[\[#VAR1\+1\]\]}} 352SAME-LINE-USE-MSG1-NEXT: {{^}} ^{{$}} 353 354SAME-LINE-USE2-LABEL: SAME LINE USE 355SAME-LINE-USE2-NEXT: [[#VAR1:]] 356SAME-LINE-USE2-NEXT: [[#VAR2:VAR1+1]] [[#VAR2+1]] 357SAME-LINE-USE-MSG2: numeric-expression.txt:[[#@LINE-1]]:42: error: numeric variable 'VAR2' defined earlier in the same CHECK directive 358SAME-LINE-USE-MSG2-NEXT: {{S}}AME-LINE-USE2-NEXT: {{\[\[#VAR2:VAR1\+1\]\] \[\[#VAR2\+1\]\]}} 359SAME-LINE-USE-MSG2-NEXT: {{^}} ^{{$}} 360 361; Invalid change of format in variable redefinition. 362RUN: not FileCheck --check-prefix REDEF-NEW-FMT --input-file %s %s 2>&1 \ 363RUN: | FileCheck --strict-whitespace --check-prefix REDEF-NEW-FMT-MSG %s 364 365VAR REDEF FMT CHANGE 36622 367DC 368REDEF-NEW-FMT-LABEL: VAR REDEF FMT CHANGE 369REDEF-NEW-FMT-NEXT: [[#VAR1:]] 370REDEF-NEW-FMT-NEXT: [[#%X,VAR1:]] 371REDEF-NEW-FMT-MSG: numeric-expression.txt:[[#@LINE-1]]:31: error: format different from previous variable definition 372REDEF-NEW-FMT-MSG-NEXT: {{R}}EDEF-NEW-FMT-NEXT: {{\[\[#%X,VAR1:\]\]}} 373REDEF-NEW-FMT-MSG-NEXT: {{^ \^$}} 374