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: %ProtectFileCheckOutput \ 45RUN: not FileCheck --check-prefixes ERR,INVALID-FMT-SPEC1 --input-file %s %s 2>&1 \ 46RUN: | FileCheck --check-prefix INVALID-FMT-SPEC-MSG1 --strict-whitespace %s 47RUN: %ProtectFileCheckOutput \ 48RUN: not FileCheck --check-prefixes ERR,INVALID-FMT-SPEC2 --input-file %s %s 2>&1 \ 49RUN: | FileCheck --check-prefix INVALID-FMT-SPEC-MSG2 --strict-whitespace %s 50 51DEF INVALID FMT 52INVVAR1=a 53INVVAR2=11 54ERR-LABEL: DEF INVALID FMT 55INVALID-FMT-SPEC1-NEXT: INVVAR1=[[#%c,INVVAR1:]] 56INVALID-FMT-SPEC2-NEXT: INVVAR2=[[#%hhd,INVVAR2:]] 57INVALID-FMT-SPEC-MSG1: numeric-expression.txt:[[#@LINE-2]]:37: error: invalid format specifier in expression 58INVALID-FMT-SPEC-MSG1-NEXT: {{I}}NVALID-FMT-SPEC1-NEXT: INVVAR1={{\[\[#%c,INVVAR1:\]\]}} 59INVALID-FMT-SPEC-MSG1-NEXT: {{^}} ^{{$}} 60INVALID-FMT-SPEC-MSG2: numeric-expression.txt:[[#@LINE-4]]:37: error: invalid format specifier in expression 61INVALID-FMT-SPEC-MSG2-NEXT: {{I}}NVALID-FMT-SPEC2-NEXT: INVVAR2={{\[\[#%hhd,INVVAR2:\]\]}} 62INVALID-FMT-SPEC-MSG2-NEXT: {{^}} ^{{$}} 63 64; Numeric expressions in explicit matching format and default matching rule using 65; variables defined on other lines without spaces. 66USE DEF FMT IMPL MATCH 6711 6812 6910 70c 71d 72b 731a 74D 75E 76C 771B 7811 7911 8011 81c 82c 83c 84c 85c 86CHECK-LABEL: USE DEF FMT IMPL MATCH 87CHECK-NEXT: [[#%u,VAR1]] 88CHECK-NEXT: [[#%u,VAR1+1]] 89CHECK-NEXT: [[#%u,VAR1-1]] 90CHECK-NEXT: [[#%x,VAR2]] 91CHECK-NEXT: [[#%x,VAR2+1]] 92CHECK-NEXT: [[#%x,VAR2-1]] 93CHECK-NEXT: [[#%x,VAR2+14]] 94CHECK-NEXT: [[#%X,VAR3]] 95CHECK-NEXT: [[#%X,VAR3+1]] 96CHECK-NEXT: [[#%X,VAR3-1]] 97CHECK-NEXT: [[#%X,VAR3+14]] 98CHECK-NEXT: [[#%u,VAR1a]] 99CHECK-NEXT: [[#%u,VAR1b]] 100CHECK-NEXT: [[#%u,VAR1c]] 101CHECK-NEXT: [[#%x,VAR2a]] 102 103; Numeric expressions in explicit matching format and default matching rule using 104; variables defined on other lines with different spacing. 105USE EXPL FMT IMPL MATCH SPC 10611 10711 10811 10912 11012 11112 11212 11312 11412 11510 11610 11710 11810 11910 12010 121CHECK-LABEL: USE EXPL FMT IMPL MATCH SPC 122CHECK-NEXT: [[#%u, VAR1]] 123CHECK-NEXT: [[# %u, VAR1]] 124CHECK-NEXT: [[# %u, VAR1 ]] 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]] 135CHECK-NEXT: [[# %u , VAR1 - 1]] 136CHECK-NEXT: [[# %u , VAR1 - 1 ]] 137 138; Numeric expressions in implicit matching format and default matching rule using 139; variables defined on other lines. 140USE IMPL FMT IMPL MATCH 14111 14212 14310 144c 145d 146b 1471a 148D 149E 150C 1511B 152CHECK-LABEL: USE IMPL FMT IMPL MATCH 153CHECK-NEXT: [[#VAR1]] 154CHECK-NEXT: [[#VAR1+1]] 155CHECK-NEXT: [[#VAR1-1]] 156CHECK-NEXT: [[#VAR2]] 157CHECK-NEXT: [[#VAR2+1]] 158CHECK-NEXT: [[#VAR2-1]] 159CHECK-NEXT: [[#VAR2+14]] 160CHECK-NEXT: [[#VAR3]] 161CHECK-NEXT: [[#VAR3+1]] 162CHECK-NEXT: [[#VAR3-1]] 163CHECK-NEXT: [[#VAR3+14]] 164 165; Numeric expressions using variables defined on other lines and an immediate 166; interpreted as an unsigned value. 167; Note: 9223372036854775819 = 0x8000000000000000 + 11 168USE IMPL FMT IMPL MATCH UNSIGNED IMM 1699223372036854775819 170CHECK-LABEL: USE IMPL FMT IMPL MATCH UNSIGNED IMM 171CHECK-NEXT: [[#VAR1+0x8000000000000000]] 172 173; Numeric expressions with matching format overriding the implicit format of 174; variables defined on other lines. 175USE CONV FMT IMPL MATCH 176b 177B 17812 17913 180CHECK-LABEL: USE CONV FMT IMPL MATCH 181CHECK-NEXT: [[# %x, VAR1]] 182CHECK-NEXT: [[# %X, VAR1]] 183CHECK-NEXT: [[# %u, VAR2]] 184CHECK-NEXT: [[# %u, VAR3]] 185 186; Conflicting implicit format. 187RUN: %ProtectFileCheckOutput \ 188RUN: not FileCheck --check-prefixes CHECK,FMT-CONFLICT --input-file %s %s 2>&1 \ 189RUN: | FileCheck --strict-whitespace --check-prefix FMT-CONFLICT-MSG %s 190 191VAR USE IMPL FMT CONFLICT 19223 193FMT-CONFLICT-LABEL: VAR USE IMPL FMT CONFLICT 194FMT-CONFLICT-NEXT: [[#VAR1 + VAR2]] 195FMT-CONFLICT-MSG: numeric-expression.txt:[[#@LINE-1]]:23: error: variables with conflicting format specifier: need an explicit one 196FMT-CONFLICT-MSG-NEXT: {{F}}MT-CONFLICT-NEXT: {{\[\[#VAR1 \+ VAR2\]\]}} 197FMT-CONFLICT-MSG-NEXT: {{^ \^$}} 198 199; Explicitly specified format can override conflicting implicit formats. 200VAR USE IMPL OVERRIDE FMT CONFLICT 20123 202CHECK-LABEL: VAR USE IMPL OVERRIDE FMT CONFLICT 203CHECK-NEXT: [[# %u, VAR1 + VAR2]] 204 205; Numeric expressions using more than one variable defined on other lines. 206USE MULTI VAR 20731 20842 209CHECK-LABEL: USE MULTI VAR 210CHECK-NEXT: [[#VAR4:]] 211CHECK-NEXT: [[#VAR1+VAR4]] 212 213; Numeric expression using a variable defined from a numeric expression. 214DEF EXPR GOOD MATCH 21542 21641 217; CHECK-LABEL: DEF EXPR GOOD MATCH 218; CHECK-NEXT: [[# VAR42:VAR1+31]] 219; CHECK-NEXT: [[# VAR42-1]] 220 221; Empty numeric expression. 222EMPTY NUM EXPR 223foo 104 bar 224CHECK-LABEL: EMPTY NUM EXPR 225CHECK-NEXT: foo [[#]] bar 226 227; Numeric expression using undefined variables. 228RUN: %ProtectFileCheckOutput \ 229RUN: not FileCheck --check-prefix UNDEF-USE --input-file %s %s 2>&1 \ 230RUN: | FileCheck --strict-whitespace --check-prefix UNDEF-USE-MSG %s 231 232UNDEF VAR USE 233UNDEFVAR: 11 234UNDEF-USE-LABEL: UNDEF VAR USE 235UNDEF-USE-NEXT: UNDEFVAR: [[#UNDEFVAR1+UNDEFVAR2]] 236UNDEF-USE-MSG: numeric-expression.txt:[[#@LINE-1]]:17: error: {{U}}NDEF-USE-NEXT: expected string not found in input 237UNDEF-USE-MSG-NEXT: {{U}}NDEF-USE-NEXT: UNDEFVAR: {{\[\[#UNDEFVAR1\+UNDEFVAR2\]\]}} 238UNDEF-USE-MSG-NEXT: {{^}} ^{{$}} 239UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-6]]:1: note: scanning from here 240UNDEF-USE-MSG-NEXT: UNDEFVAR: 11 241UNDEF-USE-MSG-NEXT: {{^}}^{{$}} 242UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-9]]:1: note: uses undefined variable(s): "UNDEFVAR1" "UNDEFVAR2" 243UNDEF-USE-MSG-NEXT: UNDEFVAR: 11 244UNDEF-USE-MSG-NEXT: {{^}}^{{$}} 245 246; Numeric expression with unsupported operator. 247RUN: %ProtectFileCheckOutput \ 248RUN: not FileCheck -D#NUMVAR=10 --check-prefix INVAL-OP \ 249RUN: --input-file %s %s 2>&1 \ 250RUN: | FileCheck --strict-whitespace --check-prefix INVAL-OP-MSG %s 251 252INVALID OPERATOR 253NUMVAR*2: 22 254INVAL-OP-LABEL: INVALID OPERATOR 255INVAL-OP-NEXT: NUMVAR*2: [[#NUMVAR*2]] 256INVAL-OP-MSG: numeric-expression.txt:[[#@LINE-1]]:35: error: unsupported operation '*' 257INVAL-OP-MSG-NEXT: {{I}}NVAL-OP-NEXT: NUMVAR*2: {{\[\[#NUMVAR\*2\]\]}} 258INVAL-OP-MSG-NEXT: {{^}} ^{{$}} 259 260; Name conflict between Numeric variable definition and string variable 261; definition whether from the command-line or input text. 262RUN: %ProtectFileCheckOutput \ 263RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT1,CONFLICT2 \ 264RUN: --input-file %s %s 2>&1 \ 265RUN: | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s 266RUN: %ProtectFileCheckOutput \ 267RUN: not FileCheck -D#NUMVAR=42 --check-prefixes CONFLICT,CONFLICT2 \ 268RUN: --input-file %s %s 2>&1 \ 269RUN: | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s 270RUN: %ProtectFileCheckOutput \ 271RUN: not FileCheck -D#NUMVAR=42 -DNUMVAR=foobar --check-prefix CONFLICT \ 272RUN: --input-file %s %s 2>&1 \ 273RUN: | FileCheck --strict-whitespace --check-prefix CLI-STR-CONFLICT %s 274RUN: %ProtectFileCheckOutput \ 275RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT3,CONFLICT4 \ 276RUN: --input-file %s %s 2>&1 \ 277RUN: | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s 278RUN: %ProtectFileCheckOutput \ 279RUN: not FileCheck -DSTRVAR=foobar --check-prefixes CONFLICT,CONFLICT4 \ 280RUN: --input-file %s %s 2>&1 \ 281RUN: | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s 282RUN: %ProtectFileCheckOutput \ 283RUN: not FileCheck -DSTRVAR=foobar -D#STRVAR=42 --check-prefix CONFLICT \ 284RUN: --input-file %s %s 2>&1 \ 285RUN: | FileCheck --strict-whitespace --check-prefix CLI-NUM-CONFLICT %s 286 287STRVAR NUMVAR CONFLICT 288redef1 42 289foobar 290redef2 42 291CONFLICT-LABEL: STRVAR NUMVAR CONFLICT 292CONFLICT1-NEXT: redef1 [[#NUMVAR:]] 293CONFLICT2: [[NUMVAR:foo.*]] 294CONFLICT3: [[STRVAR:foo.*]] 295CONFLICT4: redef2 [[#STRVAR:]] 296INPUT-STR-CONFLICT: numeric-expression.txt:[[#@LINE-3]]:14: error: numeric variable with name 'NUMVAR' already exists 297INPUT-STR-CONFLICT-NEXT: {{C}}ONFLICT2: {{\[\[NUMVAR:foo\.\*\]\]}} 298INPUT-STR-CONFLICT-NEXT: {{^}} ^{{$}} 299CLI-STR-CONFLICT: Global defines:2:19: error: numeric variable with name 'NUMVAR' already exists 300CLI-STR-CONFLICT-NEXT: Global define #2: NUMVAR=foobar 301CLI-STR-CONFLICT-NEXT: {{^}} ^{{$}} 302INPUT-NUM-CONFLICT: numeric-expression.txt:[[#@LINE-7]]:22: error: string variable with name 'STRVAR' already exists 303 INPUT-NUM-CONFLICT-NEXT: CONFLICT4: redef2 {{\[\[#STRVAR:\]\]}} 304INPUT-NUM-CONFLICT-NEXT: {{^}} ^{{$}} 305CLI-NUM-CONFLICT: Global defines:2:45: error: string variable with name 'STRVAR' already exists 306 CLI-NUM-CONFLICT-NEXT: Global define #2: #STRVAR=42 (parsed as: {{\[\[#STRVAR:42\]\]}}) 307CLI-NUM-CONFLICT-NEXT: {{^}} ^{{$}} 308 309; Numeric variable definition with too big value. 310RUN: %ProtectFileCheckOutput \ 311RUN: not FileCheck --check-prefix BIGVAL --input-file %s %s 2>&1 \ 312RUN: | FileCheck --strict-whitespace --check-prefix BIGVAL-MSG %s 313 314BIG VALUE 315NUMVAR: 10000000000000000000000 316BIGVAL-LABEL: BIG VALUE 317BIGVAL-NEXT: NUMVAR: [[#NUMVAR:]] 318BIGVAL-MSG: numeric-expression.txt:[[#@LINE-3]]:9: error: unable to represent numeric value 319 BIGVAL-MSG-NEXT: {{N}}UMVAR: 10000000000000000000000 320BIGVAL-MSG-NEXT: {{^}} ^{{$}} 321 322; Verify that when a variable is set to an expression the expression is still 323; checked. 324RUN: %ProtectFileCheckOutput \ 325RUN: not FileCheck --check-prefix DEF-EXPR-FAIL --input-file %s %s 2>&1 \ 326RUN: | FileCheck --strict-whitespace --check-prefix DEF-EXPR-FAIL-MSG %s 327 328DEF EXPR WRONG MATCH 32920 33043 331DEF-EXPR-FAIL-LABEL: DEF EXPR WRONG MATCH 332DEF-EXPR-FAIL-NEXT: [[# VAR20:]] 333DEF-EXPR-FAIL-NEXT: [[# VAR42: VAR20+22]] 334DEF-EXPR-FAIL-MSG: numeric-expression.txt:[[#@LINE-1]]:21: error: {{D}}EF-EXPR-FAIL-NEXT: is not on the line after the previous match 335DEF-EXPR-FAIL-MSG-NEXT: {{D}}EF-EXPR-FAIL-NEXT: {{\[\[# VAR42: VAR20\+22\]\]}} 336DEF-EXPR-FAIL-MSG-NEXT: {{^}} ^{{$}} 337 338; Verify that using a numeric variable defined on the same line (whether from 339; input or from an expression) is rejected. 340RUN: %ProtectFileCheckOutput \ 341RUN: not FileCheck --check-prefix SAME-LINE-USE1 --input-file %s %s 2>&1 \ 342RUN: | FileCheck --strict-whitespace --check-prefix SAME-LINE-USE-MSG1 %s 343RUN: %ProtectFileCheckOutput \ 344RUN: not FileCheck --check-prefix SAME-LINE-USE2 --input-file %s %s 2>&1 \ 345RUN: | FileCheck --strict-whitespace --check-prefix SAME-LINE-USE-MSG2 %s 346 347SAME LINE USE 3483 3494 5 350SAME-LINE-USE1-LABEL: SAME LINE USE 351SAME-LINE-USE1-NEXT: [[#]] 352SAME-LINE-USE1-NEXT: [[#VAR1:]] [[#VAR1+1]] 353SAME-LINE-USE-MSG1: numeric-expression.txt:[[#@LINE-1]]:36: error: numeric variable 'VAR1' defined earlier in the same CHECK directive 354SAME-LINE-USE-MSG1-NEXT: {{S}}AME-LINE-USE1-NEXT: {{\[\[#VAR1:\]\] \[\[#VAR1\+1\]\]}} 355SAME-LINE-USE-MSG1-NEXT: {{^}} ^{{$}} 356 357SAME-LINE-USE2-LABEL: SAME LINE USE 358SAME-LINE-USE2-NEXT: [[#VAR1:]] 359SAME-LINE-USE2-NEXT: [[#VAR2:VAR1+1]] [[#VAR2+1]] 360SAME-LINE-USE-MSG2: numeric-expression.txt:[[#@LINE-1]]:42: error: numeric variable 'VAR2' defined earlier in the same CHECK directive 361SAME-LINE-USE-MSG2-NEXT: {{S}}AME-LINE-USE2-NEXT: {{\[\[#VAR2:VAR1\+1\]\] \[\[#VAR2\+1\]\]}} 362SAME-LINE-USE-MSG2-NEXT: {{^}} ^{{$}} 363 364; Invalid change of format in variable redefinition. 365RUN: %ProtectFileCheckOutput \ 366RUN: not FileCheck --check-prefix REDEF-NEW-FMT --input-file %s %s 2>&1 \ 367RUN: | FileCheck --strict-whitespace --check-prefix REDEF-NEW-FMT-MSG %s 368 369VAR REDEF FMT CHANGE 37022 371DC 372REDEF-NEW-FMT-LABEL: VAR REDEF FMT CHANGE 373REDEF-NEW-FMT-NEXT: [[#VAR1:]] 374REDEF-NEW-FMT-NEXT: [[#%X,VAR1:]] 375REDEF-NEW-FMT-MSG: numeric-expression.txt:[[#@LINE-1]]:31: error: format different from previous variable definition 376REDEF-NEW-FMT-MSG-NEXT: {{R}}EDEF-NEW-FMT-NEXT: {{\[\[#%X,VAR1:\]\]}} 377REDEF-NEW-FMT-MSG-NEXT: {{^ \^$}} 378