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-CONFLICT1 --input-file %s %s 2>&1 \ 189RUN: | FileCheck --strict-whitespace --check-prefix FMT-CONFLICT1-MSG %s 190RUN: %ProtectFileCheckOutput \ 191RUN: not FileCheck --check-prefixes CHECK,FMT-CONFLICT2 --input-file %s %s 2>&1 \ 192RUN: | FileCheck --strict-whitespace --check-prefix FMT-CONFLICT2-MSG %s 193 194VAR USE IMPL FMT CONFLICT 19523 196FMT-CONFLICT1-LABEL: VAR USE IMPL FMT CONFLICT 197FMT-CONFLICT1-NEXT: [[#VAR1 + VAR2]] 198FMT-CONFLICT1-MSG: numeric-expression.txt:[[#@LINE-1]]:24: error: implicit format conflict between 'VAR1' (%u) and 'VAR2' (%x), need an explicit format specifier 199FMT-CONFLICT1-MSG-NEXT: {{F}}MT-CONFLICT1-NEXT: {{\[\[#VAR1 \+ VAR2\]\]}} 200FMT-CONFLICT1-MSG-NEXT: {{^ \^$}} 201 202VAR USE IMPL FMT CONFLICT COMPLEX 20334 204FMT-CONFLICT2-LABEL: VAR USE IMPL FMT CONFLICT 205FMT-CONFLICT2-NEXT: [[#VAR1 + VAR1a + VAR2]] 206FMT-CONFLICT2-MSG: numeric-expression.txt:[[#@LINE-1]]:24: error: implicit format conflict between 'VAR1 + VAR1a' (%u) and 'VAR2' (%x), need an explicit format specifier 207FMT-CONFLICT2-MSG-NEXT: {{F}}MT-CONFLICT2-NEXT: {{\[\[#VAR1 \+ VAR1a \+ VAR2\]\]}} 208FMT-CONFLICT2-MSG-NEXT: {{^ \^$}} 209 210; Explicitly specified format can override conflicting implicit formats. 211VAR USE IMPL OVERRIDE FMT CONFLICT 21223 213CHECK-LABEL: VAR USE IMPL OVERRIDE FMT CONFLICT 214CHECK-NEXT: [[# %u, VAR1 + VAR2]] 215 216; Numeric expressions using more than one variable defined on other lines. 217USE MULTI VAR 21831 21942 220CHECK-LABEL: USE MULTI VAR 221CHECK-NEXT: [[#VAR4:]] 222CHECK-NEXT: [[#VAR1+VAR4]] 223 224; Numeric expression using a variable defined from a numeric expression. 225DEF EXPR GOOD MATCH 22642 22741 228; CHECK-LABEL: DEF EXPR GOOD MATCH 229; CHECK-NEXT: [[# VAR42:VAR1+31]] 230; CHECK-NEXT: [[# VAR42-1]] 231 232; Empty numeric expression. 233EMPTY NUM EXPR 234foo 104 bar 235CHECK-LABEL: EMPTY NUM EXPR 236CHECK-NEXT: foo [[#]] bar 237 238; Numeric expression using undefined variables. 239RUN: %ProtectFileCheckOutput \ 240RUN: not FileCheck --check-prefix UNDEF-USE --input-file %s %s 2>&1 \ 241RUN: | FileCheck --strict-whitespace --check-prefix UNDEF-USE-MSG %s 242 243UNDEF VAR USE 244UNDEFVAR: 11 245UNDEF-USE-LABEL: UNDEF VAR USE 246UNDEF-USE-NEXT: UNDEFVAR: [[#UNDEFVAR1+UNDEFVAR2]] 247UNDEF-USE-MSG: numeric-expression.txt:[[#@LINE-1]]:17: error: {{U}}NDEF-USE-NEXT: expected string not found in input 248UNDEF-USE-MSG-NEXT: {{U}}NDEF-USE-NEXT: UNDEFVAR: {{\[\[#UNDEFVAR1\+UNDEFVAR2\]\]}} 249UNDEF-USE-MSG-NEXT: {{^}} ^{{$}} 250UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-6]]:1: note: scanning from here 251UNDEF-USE-MSG-NEXT: UNDEFVAR: 11 252UNDEF-USE-MSG-NEXT: {{^}}^{{$}} 253UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-9]]:1: note: uses undefined variable(s): "UNDEFVAR1" "UNDEFVAR2" 254UNDEF-USE-MSG-NEXT: UNDEFVAR: 11 255UNDEF-USE-MSG-NEXT: {{^}}^{{$}} 256 257; Numeric expression with unsupported operator. 258RUN: %ProtectFileCheckOutput \ 259RUN: not FileCheck -D#NUMVAR=10 --check-prefix INVAL-OP \ 260RUN: --input-file %s %s 2>&1 \ 261RUN: | FileCheck --strict-whitespace --check-prefix INVAL-OP-MSG %s 262 263INVALID OPERATOR 264NUMVAR*2: 22 265INVAL-OP-LABEL: INVALID OPERATOR 266INVAL-OP-NEXT: NUMVAR*2: [[#NUMVAR*2]] 267INVAL-OP-MSG: numeric-expression.txt:[[#@LINE-1]]:35: error: unsupported operation '*' 268INVAL-OP-MSG-NEXT: {{I}}NVAL-OP-NEXT: NUMVAR*2: {{\[\[#NUMVAR\*2\]\]}} 269INVAL-OP-MSG-NEXT: {{^}} ^{{$}} 270 271; Name conflict between Numeric variable definition and string variable 272; definition whether from the command-line or input text. 273RUN: %ProtectFileCheckOutput \ 274RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT1,CONFLICT2 \ 275RUN: --input-file %s %s 2>&1 \ 276RUN: | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s 277RUN: %ProtectFileCheckOutput \ 278RUN: not FileCheck -D#NUMVAR=42 --check-prefixes CONFLICT,CONFLICT2 \ 279RUN: --input-file %s %s 2>&1 \ 280RUN: | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s 281RUN: %ProtectFileCheckOutput \ 282RUN: not FileCheck -D#NUMVAR=42 -DNUMVAR=foobar --check-prefix CONFLICT \ 283RUN: --input-file %s %s 2>&1 \ 284RUN: | FileCheck --strict-whitespace --check-prefix CLI-STR-CONFLICT %s 285RUN: %ProtectFileCheckOutput \ 286RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT3,CONFLICT4 \ 287RUN: --input-file %s %s 2>&1 \ 288RUN: | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s 289RUN: %ProtectFileCheckOutput \ 290RUN: not FileCheck -DSTRVAR=foobar --check-prefixes CONFLICT,CONFLICT4 \ 291RUN: --input-file %s %s 2>&1 \ 292RUN: | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s 293RUN: %ProtectFileCheckOutput \ 294RUN: not FileCheck -DSTRVAR=foobar -D#STRVAR=42 --check-prefix CONFLICT \ 295RUN: --input-file %s %s 2>&1 \ 296RUN: | FileCheck --strict-whitespace --check-prefix CLI-NUM-CONFLICT %s 297 298STRVAR NUMVAR CONFLICT 299redef1 42 300foobar 301redef2 42 302CONFLICT-LABEL: STRVAR NUMVAR CONFLICT 303CONFLICT1-NEXT: redef1 [[#NUMVAR:]] 304CONFLICT2: [[NUMVAR:foo.*]] 305CONFLICT3: [[STRVAR:foo.*]] 306CONFLICT4: redef2 [[#STRVAR:]] 307INPUT-STR-CONFLICT: numeric-expression.txt:[[#@LINE-3]]:14: error: numeric variable with name 'NUMVAR' already exists 308INPUT-STR-CONFLICT-NEXT: {{C}}ONFLICT2: {{\[\[NUMVAR:foo\.\*\]\]}} 309INPUT-STR-CONFLICT-NEXT: {{^}} ^{{$}} 310CLI-STR-CONFLICT: Global defines:2:19: error: numeric variable with name 'NUMVAR' already exists 311CLI-STR-CONFLICT-NEXT: Global define #2: NUMVAR=foobar 312CLI-STR-CONFLICT-NEXT: {{^}} ^{{$}} 313INPUT-NUM-CONFLICT: numeric-expression.txt:[[#@LINE-7]]:22: error: string variable with name 'STRVAR' already exists 314 INPUT-NUM-CONFLICT-NEXT: CONFLICT4: redef2 {{\[\[#STRVAR:\]\]}} 315INPUT-NUM-CONFLICT-NEXT: {{^}} ^{{$}} 316CLI-NUM-CONFLICT: Global defines:2:45: error: string variable with name 'STRVAR' already exists 317 CLI-NUM-CONFLICT-NEXT: Global define #2: #STRVAR=42 (parsed as: {{\[\[#STRVAR:42\]\]}}) 318CLI-NUM-CONFLICT-NEXT: {{^}} ^{{$}} 319 320; Numeric variable definition with too big value. 321RUN: %ProtectFileCheckOutput \ 322RUN: not FileCheck --check-prefix BIGVAL --input-file %s %s 2>&1 \ 323RUN: | FileCheck --strict-whitespace --check-prefix BIGVAL-MSG %s 324 325BIG VALUE 326NUMVAR: 10000000000000000000000 327BIGVAL-LABEL: BIG VALUE 328BIGVAL-NEXT: NUMVAR: [[#NUMVAR:]] 329BIGVAL-MSG: numeric-expression.txt:[[#@LINE-3]]:9: error: unable to represent numeric value 330 BIGVAL-MSG-NEXT: {{N}}UMVAR: 10000000000000000000000 331BIGVAL-MSG-NEXT: {{^}} ^{{$}} 332 333; Verify that when a variable is set to an expression the expression is still 334; checked. 335RUN: %ProtectFileCheckOutput \ 336RUN: not FileCheck --check-prefix DEF-EXPR-FAIL --input-file %s %s 2>&1 \ 337RUN: | FileCheck --strict-whitespace --check-prefix DEF-EXPR-FAIL-MSG %s 338 339DEF EXPR WRONG MATCH 34020 34143 342DEF-EXPR-FAIL-LABEL: DEF EXPR WRONG MATCH 343DEF-EXPR-FAIL-NEXT: [[# VAR20:]] 344DEF-EXPR-FAIL-NEXT: [[# VAR42: VAR20+22]] 345DEF-EXPR-FAIL-MSG: numeric-expression.txt:[[#@LINE-1]]:21: error: {{D}}EF-EXPR-FAIL-NEXT: is not on the line after the previous match 346DEF-EXPR-FAIL-MSG-NEXT: {{D}}EF-EXPR-FAIL-NEXT: {{\[\[# VAR42: VAR20\+22\]\]}} 347DEF-EXPR-FAIL-MSG-NEXT: {{^}} ^{{$}} 348 349; Verify that using a numeric variable defined on the same line (whether from 350; input or from an expression) is rejected. 351RUN: %ProtectFileCheckOutput \ 352RUN: not FileCheck --check-prefix SAME-LINE-USE1 --input-file %s %s 2>&1 \ 353RUN: | FileCheck --strict-whitespace --check-prefix SAME-LINE-USE-MSG1 %s 354RUN: %ProtectFileCheckOutput \ 355RUN: not FileCheck --check-prefix SAME-LINE-USE2 --input-file %s %s 2>&1 \ 356RUN: | FileCheck --strict-whitespace --check-prefix SAME-LINE-USE-MSG2 %s 357 358SAME LINE USE 3593 3604 5 361SAME-LINE-USE1-LABEL: SAME LINE USE 362SAME-LINE-USE1-NEXT: [[#]] 363SAME-LINE-USE1-NEXT: [[#VAR1:]] [[#VAR1+1]] 364SAME-LINE-USE-MSG1: numeric-expression.txt:[[#@LINE-1]]:36: error: numeric variable 'VAR1' defined earlier in the same CHECK directive 365SAME-LINE-USE-MSG1-NEXT: {{S}}AME-LINE-USE1-NEXT: {{\[\[#VAR1:\]\] \[\[#VAR1\+1\]\]}} 366SAME-LINE-USE-MSG1-NEXT: {{^}} ^{{$}} 367 368SAME-LINE-USE2-LABEL: SAME LINE USE 369SAME-LINE-USE2-NEXT: [[#VAR1:]] 370SAME-LINE-USE2-NEXT: [[#VAR2:VAR1+1]] [[#VAR2+1]] 371SAME-LINE-USE-MSG2: numeric-expression.txt:[[#@LINE-1]]:42: error: numeric variable 'VAR2' defined earlier in the same CHECK directive 372SAME-LINE-USE-MSG2-NEXT: {{S}}AME-LINE-USE2-NEXT: {{\[\[#VAR2:VAR1\+1\]\] \[\[#VAR2\+1\]\]}} 373SAME-LINE-USE-MSG2-NEXT: {{^}} ^{{$}} 374 375; Invalid change of format in variable redefinition. 376RUN: %ProtectFileCheckOutput \ 377RUN: not FileCheck --check-prefix REDEF-NEW-FMT --input-file %s %s 2>&1 \ 378RUN: | FileCheck --strict-whitespace --check-prefix REDEF-NEW-FMT-MSG %s 379 380VAR REDEF FMT CHANGE 38122 382DC 383REDEF-NEW-FMT-LABEL: VAR REDEF FMT CHANGE 384REDEF-NEW-FMT-NEXT: [[#VAR1:]] 385REDEF-NEW-FMT-NEXT: [[#%X,VAR1:]] 386REDEF-NEW-FMT-MSG: numeric-expression.txt:[[#@LINE-1]]:31: error: format different from previous variable definition 387REDEF-NEW-FMT-MSG-NEXT: {{R}}EDEF-NEW-FMT-NEXT: {{\[\[#%X,VAR1:\]\]}} 388REDEF-NEW-FMT-MSG-NEXT: {{^ \^$}} 389