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 710 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 variable redefinition. 22REDEF NO SPC 2311 24CHECK-LABEL: REDEF 25CHECK-NEXT: [[#VAR1:]] 26 27; Numeric expressions using variables defined on other lines without spaces. 28USE NO SPC 2911 3012 3110 3211 3311 3411 35CHECK-LABEL: USE 36CHECK-NEXT: [[#VAR1]] 37CHECK-NEXT: [[#VAR1+1]] 38CHECK-NEXT: [[#VAR1-1]] 39CHECK-NEXT: [[#VAR1a]] 40CHECK-NEXT: [[#VAR1b]] 41CHECK-NEXT: [[#VAR1c]] 42 43; Numeric expressions using variables defined on other lines with different 44; spacing. 45USE SPC 4611 4711 4812 4912 5012 5112 5210 5310 5410 5510 56CHECK-LABEL: USE SPC 57CHECK-NEXT: [[# VAR1]] 58CHECK-NEXT: [[# VAR1 ]] 59CHECK-NEXT: [[# VAR1+1]] 60CHECK-NEXT: [[# VAR1 +1]] 61CHECK-NEXT: [[# VAR1 + 1]] 62CHECK-NEXT: [[# VAR1 + 1 ]] 63CHECK-NEXT: [[# VAR1-1]] 64CHECK-NEXT: [[# VAR1 -1]] 65CHECK-NEXT: [[# VAR1 - 1]] 66CHECK-NEXT: [[# VAR1 - 1 ]] 67 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 72USE UNSIGNED IMM 739223372036854775819 74CHECK-LABEL: USE UNSIGNED IMM 75CHECK-NEXT: [[#VAR1+9223372036854775808]] 76 77; Numeric expressions using more than one variable defined on other lines. 78USE MULTI VAR 7931 8042 81CHECK-LABEL: USE MULTI VAR 82CHECK-NEXT: [[#VAR2:]] 83CHECK-NEXT: [[#VAR1+VAR2]] 84 85; Numeric expression using a variable defined from a numeric expression. 86DEF EXPR GOOD MATCH 8742 8841 89; CHECK-LABEL: DEF EXPR GOOD MATCH 90; CHECK-NEXT: [[# VAR42:VAR1+31]] 91; CHECK-NEXT: [[# VAR42-1]] 92 93; Empty numeric expression. 94EMPTY NUM EXPR 95foo 104 bar 96; CHECK-LABEL: EMPTY NUM EXPR 97; CHECK-NEXT: foo [[#]] bar 98 99; Numeric expression using undefined variables. 100RUN: %ProtectFileCheckOutput \ 101RUN: not FileCheck --check-prefix UNDEF-USE --input-file %s %s 2>&1 \ 102RUN: | FileCheck --strict-whitespace --check-prefix UNDEF-USE-MSG %s 103 104UNDEF VAR USE 105UNDEFVAR: 11 106UNDEF-USE-LABEL: UNDEF VAR USE 107UNDEF-USE-NEXT: UNDEFVAR: [[#UNDEFVAR1+UNDEFVAR2]] 108UNDEF-USE-MSG: numeric-expression.txt:[[#@LINE-1]]:17: error: {{U}}NDEF-USE-NEXT: expected string not found in input 109UNDEF-USE-MSG-NEXT: {{U}}NDEF-USE-NEXT: UNDEFVAR: {{\[\[#UNDEFVAR1\+UNDEFVAR2\]\]}} 110UNDEF-USE-MSG-NEXT: {{^}} ^{{$}} 111UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-6]]:1: note: scanning from here 112UNDEF-USE-MSG-NEXT: UNDEFVAR: 11 113UNDEF-USE-MSG-NEXT: {{^}}^{{$}} 114UNDEF-USE-MSG-NEXT: numeric-expression.txt:[[#@LINE-9]]:1: note: uses undefined variable(s): "UNDEFVAR1" "UNDEFVAR2" 115UNDEF-USE-MSG-NEXT: UNDEFVAR: 11 116UNDEF-USE-MSG-NEXT: {{^}}^{{$}} 117 118; Numeric expression with unsupported operator. 119RUN: %ProtectFileCheckOutput \ 120RUN: not FileCheck -D#NUMVAR=10 --check-prefix INVAL-OP \ 121RUN: --input-file %s %s 2>&1 \ 122RUN: | FileCheck --strict-whitespace --check-prefix INVAL-OP-MSG %s 123 124INVALID OPERATOR 125NUMVAR*2: 22 126INVAL-OP-LABEL: INVALID OPERATOR 127INVAL-OP-NEXT: NUMVAR*2: [[#NUMVAR*2]] 128INVAL-OP-MSG: numeric-expression.txt:[[#@LINE-1]]:35: error: unsupported operation '*' 129INVAL-OP-MSG-NEXT: {{I}}NVAL-OP-NEXT: NUMVAR*2: {{\[\[#NUMVAR\*2\]\]}} 130INVAL-OP-MSG-NEXT: {{^}} ^{{$}} 131 132; Name conflict between Numeric variable definition and string variable 133; definition whether from the command-line or input text. 134RUN: %ProtectFileCheckOutput \ 135RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT1,CONFLICT2 \ 136RUN: --input-file %s %s 2>&1 \ 137RUN: | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s 138RUN: %ProtectFileCheckOutput \ 139RUN: not FileCheck -D#NUMVAR=42 --check-prefixes CONFLICT,CONFLICT2 \ 140RUN: --input-file %s %s 2>&1 \ 141RUN: | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s 142RUN: %ProtectFileCheckOutput \ 143RUN: not FileCheck -D#NUMVAR=42 -DNUMVAR=foobar --check-prefix CONFLICT \ 144RUN: --input-file %s %s 2>&1 \ 145RUN: | FileCheck --strict-whitespace --check-prefix CLI-STR-CONFLICT %s 146RUN: %ProtectFileCheckOutput \ 147RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT3,CONFLICT4 \ 148RUN: --input-file %s %s 2>&1 \ 149RUN: | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s 150RUN: %ProtectFileCheckOutput \ 151RUN: not FileCheck -DSTRVAR=foobar --check-prefixes CONFLICT,CONFLICT4 \ 152RUN: --input-file %s %s 2>&1 \ 153RUN: | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s 154RUN: %ProtectFileCheckOutput \ 155RUN: not FileCheck -DSTRVAR=foobar -D#STRVAR=42 --check-prefix CONFLICT \ 156RUN: --input-file %s %s 2>&1 \ 157RUN: | FileCheck --strict-whitespace --check-prefix CLI-NUM-CONFLICT %s 158 159STRVAR NUMVAR CONFLICT 160redef1 42 161foobar 162redef2 42 163CONFLICT-LABEL: STRVAR NUMVAR CONFLICT 164CONFLICT1-NEXT: redef1 [[#NUMVAR:]] 165CONFLICT2: [[NUMVAR:foo.*]] 166CONFLICT3: [[STRVAR:foo.*]] 167CONFLICT4: redef2 [[#STRVAR:]] 168INPUT-STR-CONFLICT: numeric-expression.txt:[[#@LINE-3]]:14: error: numeric variable with name 'NUMVAR' already exists 169INPUT-STR-CONFLICT-NEXT: {{C}}ONFLICT2: {{\[\[NUMVAR:foo\.\*\]\]}} 170INPUT-STR-CONFLICT-NEXT: {{^}} ^{{$}} 171CLI-STR-CONFLICT: Global defines:2:19: error: numeric variable with name 'NUMVAR' already exists 172CLI-STR-CONFLICT-NEXT: Global define #2: NUMVAR=foobar 173CLI-STR-CONFLICT-NEXT: {{^}} ^{{$}} 174INPUT-NUM-CONFLICT: numeric-expression.txt:[[#@LINE-7]]:22: error: string variable with name 'STRVAR' already exists 175 INPUT-NUM-CONFLICT-NEXT: CONFLICT4: redef2 {{\[\[#STRVAR:\]\]}} 176INPUT-NUM-CONFLICT-NEXT: {{^}} ^{{$}} 177CLI-NUM-CONFLICT: Global defines:2:45: error: string variable with name 'STRVAR' already exists 178 CLI-NUM-CONFLICT-NEXT: Global define #2: #STRVAR=42 (parsed as: {{\[\[#STRVAR:42\]\]}}) 179CLI-NUM-CONFLICT-NEXT: {{^}} ^{{$}} 180 181; Numeric variable definition with too big value. 182RUN: %ProtectFileCheckOutput \ 183RUN: not FileCheck --check-prefix BIGVAL --input-file %s %s 2>&1 \ 184RUN: | FileCheck --strict-whitespace --check-prefix BIGVAL-MSG %s 185 186BIG VALUE 187NUMVAR: 10000000000000000000000 188BIGVAL-LABEL: BIG VALUE 189BIGVAL-NEXT: NUMVAR: [[#NUMVAR:]] 190BIGVAL-MSG: numeric-expression.txt:[[#@LINE-3]]:9: error: Unable to represent numeric value 191 BIGVAL-MSG-NEXT: {{N}}UMVAR: 10000000000000000000000 192BIGVAL-MSG-NEXT: {{^}} ^{{$}} 193 194; Verify that when a variable is set to an expression the expression is still 195; checked. 196RUN: %ProtectFileCheckOutput \ 197RUN: not FileCheck --check-prefix DEF-EXPR-FAIL --input-file %s %s 2>&1 \ 198RUN: | FileCheck --strict-whitespace --check-prefix DEF-EXPR-FAIL-MSG %s 199 200DEF EXPR WRONG MATCH 20120 20243 203DEF-EXPR-FAIL-LABEL: DEF EXPR WRONG MATCH 204DEF-EXPR-FAIL-NEXT: [[# VAR20:]] 205DEF-EXPR-FAIL-NEXT: [[# VAR42: VAR20+22]] 206DEF-EXPR-FAIL-MSG: numeric-expression.txt:[[#@LINE-1]]:21: error: {{D}}EF-EXPR-FAIL-NEXT: is not on the line after the previous match 207DEF-EXPR-FAIL-MSG-NEXT: {{D}}EF-EXPR-FAIL-NEXT: {{\[\[# VAR42: VAR20\+22\]\]}} 208DEF-EXPR-FAIL-MSG-NEXT: {{^}} ^{{$}} 209 210; Verify that using a numeric variable defined on the same line (whether from 211; input or from an expression) is rejected. 212RUN: %ProtectFileCheckOutput \ 213RUN: not FileCheck --check-prefix SAME-LINE-USE1 --input-file %s %s 2>&1 \ 214RUN: | FileCheck --strict-whitespace --check-prefix SAME-LINE-USE-MSG1 %s 215RUN: %ProtectFileCheckOutput \ 216RUN: not FileCheck --check-prefix SAME-LINE-USE2 --input-file %s %s 2>&1 \ 217RUN: | FileCheck --strict-whitespace --check-prefix SAME-LINE-USE-MSG2 %s 218 219SAME LINE USE 2203 2214 5 222SAME-LINE-USE1-LABEL: SAME LINE USE 223SAME-LINE-USE1-NEXT: [[#]] 224SAME-LINE-USE1-NEXT: [[#VAR1:]] [[#VAR1+1]] 225SAME-LINE-USE-MSG1: numeric-expression.txt:[[#@LINE-1]]:36: error: numeric variable 'VAR1' defined earlier in the same CHECK directive 226SAME-LINE-USE-MSG1-NEXT: {{S}}AME-LINE-USE1-NEXT: {{\[\[#VAR1:\]\] \[\[#VAR1\+1\]\]}} 227SAME-LINE-USE-MSG1-NEXT: {{^}} ^{{$}} 228 229SAME-LINE-USE2-LABEL: SAME LINE USE 230SAME-LINE-USE2-NEXT: [[#VAR1:]] 231SAME-LINE-USE2-NEXT: [[#VAR2:VAR1+1]] [[#VAR2+1]] 232SAME-LINE-USE-MSG2: numeric-expression.txt:[[#@LINE-1]]:42: error: numeric variable 'VAR2' defined earlier in the same CHECK directive 233SAME-LINE-USE-MSG2-NEXT: {{S}}AME-LINE-USE2-NEXT: {{\[\[#VAR2:VAR1\+1\]\] \[\[#VAR2\+1\]\]}} 234SAME-LINE-USE-MSG2-NEXT: {{^}} ^{{$}} 235