view llvm/test/FileCheck/numeric-expression.txt @ 206:f17a3b42b08b

Added tag before-12 for changeset b7591485f4cd
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 07 Jun 2021 21:25:57 +0900
parents 0572611fdcc8
children 2e18cbf3894f
line wrap: on
line source

RUN: FileCheck --input-file %s %s

; We use CHECK-NEXT directives to force a match on all lines with digits.

; Numeric variable definition with default matching format without spaces.
DEF DEFAULT FMT NO SPC  // CHECK-LABEL: DEF DEFAULT FMT NO SPC
10  // CHECK-NEXT: {{^}}[[#UNSI:]]

; Numeric variable definition with default matching format with different
; spacing.
DEF DEFAULT FMT SPC  // CHECK-LABEL: DEF DEFAULT FMT SPC
11  // CHECK-NEXT: {{^}}[[# UNSIa:]]
11  // CHECK-NEXT: {{^}}[[# UNSIb :]]
11  // CHECK-NEXT: {{^}}[[# UNSIc : ]]

; Numeric variable redefinition.
REDEF NO SPC  // CHECK-LABEL: REDEF
11  // CHECK-NEXT: {{^}}[[#UNSI:]]

; Numeric variable definition with explicit matching format.
DEF FMT  // CHECK-LABEL: DEF FMT
c  // CHECK-NEXT: {{^}}[[#%x,LHEX:]]
D  // CHECK-NEXT: {{^}}[[#%X,UHEX:]]

; Numeric variable definition with explicit matching format with different
; spacing.
DEF FMT SPC  // CHECK-LABEL: DEF FMT SPC
c  // CHECK-NEXT: {{^}}[[# %x , LHEXa : ]]

; Numeric variable definition with unsupported matching format.
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck --check-prefixes ERR,INVALID-FMT-SPEC1 --input-file %s %s 2>&1 \
RUN:   | FileCheck --check-prefix INVALID-FMT-SPEC-MSG1 --strict-whitespace %s
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck --check-prefixes ERR,INVALID-FMT-SPEC2 --input-file %s %s 2>&1 \
RUN:   | FileCheck --check-prefix INVALID-FMT-SPEC-MSG2 --strict-whitespace %s

DEF INVALID FMT
INVVAR1=a
INVVAR2=11
ERR-LABEL: DEF INVALID FMT
INVALID-FMT-SPEC1-NEXT: INVVAR1=[[#%c,INVVAR1:]]
INVALID-FMT-SPEC2-NEXT: INVVAR2=[[#%hhd,INVVAR2:]]
INVALID-FMT-SPEC-MSG1: numeric-expression.txt:[[#@LINE-2]]:37: error: invalid format specifier in expression
INVALID-FMT-SPEC-MSG1-NEXT: {{I}}NVALID-FMT-SPEC1-NEXT: INVVAR1={{\[\[#%c,INVVAR1:\]\]}}
INVALID-FMT-SPEC-MSG1-NEXT:    {{^}}                                    ^{{$}}
INVALID-FMT-SPEC-MSG2: numeric-expression.txt:[[#@LINE-4]]:37: error: invalid format specifier in expression
INVALID-FMT-SPEC-MSG2-NEXT: {{I}}NVALID-FMT-SPEC2-NEXT: INVVAR2={{\[\[#%hhd,INVVAR2:\]\]}}
INVALID-FMT-SPEC-MSG2-NEXT:    {{^}}                                    ^{{$}}

; Numeric expressions in explicit matching format and default matching rule using
; variables defined on other lines without spaces.
USE EXPL FMT IMPL MATCH  // CHECK-LABEL: USE EXPL FMT IMPL MATCH
11  // CHECK-NEXT: {{^}}[[#%u,UNSI]]
12  // CHECK-NEXT: {{^}}[[#%u,UNSI+1]]
10  // CHECK-NEXT: {{^}}[[#%u,UNSI-1]]
c   // CHECK-NEXT: {{^}}[[#%x,LHEX]]
d   // CHECK-NEXT: {{^}}[[#%x,LHEX+1]]
b   // CHECK-NEXT: {{^}}[[#%x,LHEX-1]]
1a  // CHECK-NEXT: {{^}}[[#%x,LHEX+0xe]]
1a  // CHECK-NEXT: {{^}}[[#%x,LHEX+0xE]]
D   // CHECK-NEXT: {{^}}[[#%X,UHEX]]
E   // CHECK-NEXT: {{^}}[[#%X,UHEX+1]]
C   // CHECK-NEXT: {{^}}[[#%X,UHEX-1]]
1B  // CHECK-NEXT: {{^}}[[#%X,UHEX+0xe]]
1B  // CHECK-NEXT: {{^}}[[#%X,UHEX+0xE]]
11  // CHECK-NEXT: {{^}}[[#%u,UNSIa]]
11  // CHECK-NEXT: {{^}}[[#%u,UNSIb]]
11  // CHECK-NEXT: {{^}}[[#%u,UNSIc]]
c   // CHECK-NEXT: {{^}}[[#%x,LHEXa]]

; Numeric expressions in explicit matching format and default matching rule using
; variables defined on other lines with different spacing.
USE EXPL FMT IMPL MATCH SPC  // CHECK-LABEL: USE EXPL FMT IMPL MATCH SPC
11  // CHECK-NEXT: {{^}}[[#%u, UNSI]]
11  // CHECK-NEXT: {{^}}[[# %u, UNSI]]
11  // CHECK-NEXT: {{^}}[[# %u, UNSI ]]
12  // CHECK-NEXT: {{^}}[[#%u, UNSI+1]]
12  // CHECK-NEXT: {{^}}[[# %u, UNSI+1]]
12  // CHECK-NEXT: {{^}}[[# %u , UNSI+1]]
12  // CHECK-NEXT: {{^}}[[# %u , UNSI +1]]
12  // CHECK-NEXT: {{^}}[[# %u , UNSI + 1]]
12  // CHECK-NEXT: {{^}}[[# %u , UNSI + 1 ]]
10  // CHECK-NEXT: {{^}}[[#%u, UNSI-1]]
10  // CHECK-NEXT: {{^}}[[# %u, UNSI-1]]
10  // CHECK-NEXT: {{^}}[[# %u , UNSI-1]]
10  // CHECK-NEXT: {{^}}[[# %u , UNSI -1]]
10  // CHECK-NEXT: {{^}}[[# %u , UNSI - 1]]
10  // CHECK-NEXT: {{^}}[[# %u , UNSI - 1 ]]

; Numeric expressions in implicit matching format and default matching rule using
; variables defined on other lines.
USE IMPL FMT IMPL MATCH  // CHECK-LABEL: USE IMPL FMT IMPL MATCH
11  // CHECK-NEXT: {{^}}[[#UNSI]]
12  // CHECK-NEXT: {{^}}[[#UNSI+1]]
10  // CHECK-NEXT: {{^}}[[#UNSI-1]]
c   // CHECK-NEXT: {{^}}[[#LHEX]]
d   // CHECK-NEXT: {{^}}[[#LHEX+1]]
b   // CHECK-NEXT: {{^}}[[#LHEX-1]]
1a  // CHECK-NEXT: {{^}}[[#LHEX+0xe]]
1a  // CHECK-NEXT: {{^}}[[#LHEX+0xE]]
D   // CHECK-NEXT: {{^}}[[#UHEX]]
E   // CHECK-NEXT: {{^}}[[#UHEX+1]]
C   // CHECK-NEXT: {{^}}[[#UHEX-1]]
1B  // CHECK-NEXT: {{^}}[[#UHEX+0xe]]
1B  // CHECK-NEXT: {{^}}[[#UHEX+0xE]]

; Numeric expressions using variables defined on other lines and an immediate
; interpreted as an unsigned value.
; Note: 9223372036854775819 = 0x8000000000000000 + 11
USE IMPL FMT IMPL MATCH UNSIGNED IMM
9223372036854775819
CHECK-LABEL: USE IMPL FMT IMPL MATCH UNSIGNED IMM
CHECK-NEXT: [[#UNSI+0x8000000000000000]]

; Numeric expressions with matching format overriding the implicit format of
; variables defined on other lines.
USE CONV FMT IMPL MATCH  // CHECK-LABEL: USE CONV FMT IMPL MATCH
b   // CHECK-NEXT: {{^}}[[# %x, UNSI]]
B   // CHECK-NEXT: {{^}}[[# %X, UNSI]]
12  // CHECK-NEXT: {{^}}[[# %u, LHEX]]
C   // CHECK-NEXT: {{^}}[[# %X, LHEX]]
13  // CHECK-NEXT: {{^}}[[# %u, UHEX]]
d   // CHECK-NEXT: {{^}}[[# %x, UHEX]]

; Conflicting implicit format.
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck --check-prefixes CHECK,FMT-CONFLICT1 --input-file %s %s 2>&1 \
RUN:   | FileCheck --strict-whitespace --check-prefix FMT-CONFLICT1-MSG %s
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck --check-prefixes CHECK,FMT-CONFLICT2 --input-file %s %s 2>&1 \
RUN:   | FileCheck --strict-whitespace --check-prefix FMT-CONFLICT2-MSG %s

VAR USE IMPL FMT CONFLICT
23
FMT-CONFLICT1-LABEL: VAR USE IMPL FMT CONFLICT
FMT-CONFLICT1-NEXT: [[#UNSI + LHEX]]
FMT-CONFLICT1-MSG: numeric-expression.txt:[[#@LINE-1]]:24: error: implicit format conflict between 'UNSI' (%u) and 'LHEX' (%x), need an explicit format specifier
FMT-CONFLICT1-MSG-NEXT: {{F}}MT-CONFLICT1-NEXT: {{\[\[#UNSI \+ LHEX\]\]}}
FMT-CONFLICT1-MSG-NEXT: {{^                       \^$}}

VAR USE IMPL FMT CONFLICT COMPLEX
34
FMT-CONFLICT2-LABEL: VAR USE IMPL FMT CONFLICT
FMT-CONFLICT2-NEXT: [[#UNSI + UNSIa + LHEX]]
FMT-CONFLICT2-MSG: numeric-expression.txt:[[#@LINE-1]]:24: error: implicit format conflict between 'UNSI + UNSIa' (%u) and 'LHEX' (%x), need an explicit format specifier
FMT-CONFLICT2-MSG-NEXT: {{F}}MT-CONFLICT2-NEXT: {{\[\[#UNSI \+ UNSIa \+ LHEX\]\]}}
FMT-CONFLICT2-MSG-NEXT: {{^                       \^$}}

; Explicitly specified format can override conflicting implicit formats.
VAR USE IMPL OVERRIDE FMT CONFLICT  // CHECK-LABEL: VAR USE IMPL OVERRIDE FMT CONFLICT
23  // CHECK-NEXT: {{^}}[[# %u, UNSI + LHEX]]

; Numeric expressions using more than one variable defined on other lines.
USE MULTI VAR  // CHECK-LABEL: USE MULTI VAR
22  // CHECK-NEXT: {{^}}[[#UNSI+UNSIa]]

; Numeric expression using a variable defined from a numeric expression.
DEF EXPR GOOD MATCH  // CHECK-LABEL: DEF EXPR GOOD MATCH
42  // CHECK-NEXT: {{^}}[[# VAR42:UNSI+31]]
41  // CHECK-NEXT: {{^}}[[# VAR42-1]]

; Empty numeric expression.
EMPTY NUM EXPR  // CHECK-LABEL: EMPTY NUM EXPR
foo 104 bar  // CHECK-NEXT: {{^}}foo [[#]] bar

; Numeric expression using undefined variables.
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck --check-prefix UNDEF-USE --input-file %s %s 2>&1 \
RUN:   | FileCheck --strict-whitespace --check-prefix UNDEF-USE-MSG %s

UNDEF VAR USE
UNDEFVAR: 11
UNDEF-USE-LABEL: UNDEF VAR USE
UNDEF-USE-NEXT: UNDEFVAR: [[#UNDEFVAR1+UNDEFVAR2]]
UNDEF-USE-MSG: numeric-expression.txt:[[#@LINE-1]]:17: error: {{U}}NDEF-USE-NEXT: expected string not found in input
UNDEF-USE-MSG-NEXT:      {{U}}NDEF-USE-NEXT: UNDEFVAR: {{\[\[#UNDEFVAR1\+UNDEFVAR2\]\]}}
UNDEF-USE-MSG-NEXT:     {{^}}                ^{{$}}
UNDEF-USE-MSG-NEXT:      numeric-expression.txt:[[#@LINE-6]]:1: note: scanning from here
UNDEF-USE-MSG-NEXT:      UNDEFVAR: 11
UNDEF-USE-MSG-NEXT: {{^}}^{{$}}
UNDEF-USE-MSG-NEXT:      numeric-expression.txt:[[#@LINE-9]]:1: note: uses undefined variable(s): "UNDEFVAR1" "UNDEFVAR2"
UNDEF-USE-MSG-NEXT:      UNDEFVAR: 11
UNDEF-USE-MSG-NEXT: {{^}}^{{$}}

; Numeric expression with unsupported operator.
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck -D#NUMVAR=10 --check-prefix INVAL-OP \
RUN:               --input-file %s %s 2>&1 \
RUN:   | FileCheck --strict-whitespace --check-prefix INVAL-OP-MSG %s

INVALID OPERATOR
NUMVAR*2: 22
INVAL-OP-LABEL: INVALID OPERATOR
INVAL-OP-NEXT: NUMVAR*2: [[#NUMVAR*2]]
INVAL-OP-MSG: numeric-expression.txt:[[#@LINE-1]]:35: error: unsupported operation '*'
INVAL-OP-MSG-NEXT: {{I}}NVAL-OP-NEXT: NUMVAR*2: {{\[\[#NUMVAR\*2\]\]}}
INVAL-OP-MSG-NEXT:     {{^}}                                  ^{{$}}

; Name conflict between Numeric variable definition and string variable
; definition whether from the command-line or input text.
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT1,CONFLICT2 \
RUN:               --input-file %s %s 2>&1 \
RUN:   | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck -D#NUMVAR=42 --check-prefixes CONFLICT,CONFLICT2 \
RUN:               --input-file %s %s 2>&1 \
RUN:   | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck -D#NUMVAR=42 -DNUMVAR=foobar --check-prefix CONFLICT \
RUN:               --input-file %s %s 2>&1 \
RUN:   | FileCheck --strict-whitespace --check-prefix CLI-STR-CONFLICT %s
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT3,CONFLICT4 \
RUN:               --input-file %s %s 2>&1 \
RUN:   | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck -DSTRVAR=foobar --check-prefixes CONFLICT,CONFLICT4 \
RUN:               --input-file %s %s 2>&1 \
RUN:   | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck -DSTRVAR=foobar -D#STRVAR=42 --check-prefix CONFLICT \
RUN:               --input-file %s %s 2>&1 \
RUN:   | FileCheck --strict-whitespace --check-prefix CLI-NUM-CONFLICT %s

STRVAR NUMVAR CONFLICT
redef1 42
foobar
redef2 42
CONFLICT-LABEL: STRVAR NUMVAR CONFLICT
CONFLICT1-NEXT: redef1 [[#NUMVAR:]]
CONFLICT2: [[NUMVAR:foo.*]]
CONFLICT3: [[STRVAR:foo.*]]
CONFLICT4: redef2 [[#STRVAR:]]
INPUT-STR-CONFLICT: numeric-expression.txt:[[#@LINE-3]]:14: error: numeric variable with name 'NUMVAR' already exists
INPUT-STR-CONFLICT-NEXT: {{C}}ONFLICT2: {{\[\[NUMVAR:foo\.\*\]\]}}
INPUT-STR-CONFLICT-NEXT:    {{^}}             ^{{$}}
CLI-STR-CONFLICT: Global defines:2:19: error: numeric variable with name 'NUMVAR' already exists
CLI-STR-CONFLICT-NEXT:      Global define #2: NUMVAR=foobar
CLI-STR-CONFLICT-NEXT: {{^}}                  ^{{$}}
INPUT-NUM-CONFLICT: numeric-expression.txt:[[#@LINE-7]]:22: error: string variable with name 'STRVAR' already exists
 INPUT-NUM-CONFLICT-NEXT: CONFLICT4: redef2 {{\[\[#STRVAR:\]\]}}
INPUT-NUM-CONFLICT-NEXT: {{^}}                     ^{{$}}
CLI-NUM-CONFLICT: Global defines:2:45: error: string variable with name 'STRVAR' already exists
 CLI-NUM-CONFLICT-NEXT: Global define #2: #STRVAR=42 (parsed as: {{\[\[#STRVAR:42\]\]}})
CLI-NUM-CONFLICT-NEXT: {{^}}                                            ^{{$}}

; Numeric variable definition with too big value.
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck --check-prefix BIGVAL --input-file %s %s 2>&1 \
RUN:   | FileCheck --strict-whitespace --check-prefix BIGVAL-MSG %s

BIG VALUE
NUMVAR: 10000000000000000000000
BIGVAL-LABEL: BIG VALUE
BIGVAL-NEXT: NUMVAR: [[#NUMVAR:]]
BIGVAL-MSG: numeric-expression.txt:[[#@LINE-3]]:9: error: unable to represent numeric value
 BIGVAL-MSG-NEXT: {{N}}UMVAR: 10000000000000000000000
BIGVAL-MSG-NEXT: {{^}}        ^{{$}}

; Verify that when a variable is set to an expression the expression is still
; checked.
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck --check-prefix DEF-EXPR-FAIL --input-file %s %s 2>&1 \
RUN:   | FileCheck --strict-whitespace --check-prefix DEF-EXPR-FAIL-MSG %s

DEF EXPR WRONG MATCH
20
43
DEF-EXPR-FAIL-LABEL: DEF EXPR WRONG MATCH
DEF-EXPR-FAIL-NEXT: [[# VAR20:]]
DEF-EXPR-FAIL-NEXT: [[# VAR42: VAR20+22]]
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
DEF-EXPR-FAIL-MSG-NEXT: {{D}}EF-EXPR-FAIL-NEXT: {{\[\[# VAR42: VAR20\+22\]\]}}
DEF-EXPR-FAIL-MSG-NEXT:   {{^}}                    ^{{$}}

; Verify that using a numeric variable defined on the same line (whether from
; input or from an expression) is rejected.
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck --check-prefix SAME-LINE-USE1 --input-file %s %s 2>&1 \
RUN:   | FileCheck --strict-whitespace --check-prefix SAME-LINE-USE-MSG1 %s
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck --check-prefix SAME-LINE-USE2 --input-file %s %s 2>&1 \
RUN:   | FileCheck --strict-whitespace --check-prefix SAME-LINE-USE-MSG2 %s

SAME LINE USE
3
4 5
SAME-LINE-USE1-LABEL: SAME LINE USE
SAME-LINE-USE1-NEXT: [[#]]
SAME-LINE-USE1-NEXT: [[#UNSI:]] [[#UNSI+1]]
SAME-LINE-USE-MSG1: numeric-expression.txt:[[#@LINE-1]]:36: error: numeric variable 'UNSI' defined earlier in the same CHECK directive
SAME-LINE-USE-MSG1-NEXT: {{S}}AME-LINE-USE1-NEXT: {{\[\[#UNSI:\]\] \[\[#UNSI\+1\]\]}}
SAME-LINE-USE-MSG1-NEXT:        {{^}}                                   ^{{$}}

SAME-LINE-USE2-LABEL: SAME LINE USE
SAME-LINE-USE2-NEXT: [[#UNSI:]]
SAME-LINE-USE2-NEXT: [[#UNSI2:UNSI+1]] [[#UNSI2+1]]
SAME-LINE-USE-MSG2: numeric-expression.txt:[[#@LINE-1]]:43: error: numeric variable 'UNSI2' defined earlier in the same CHECK directive
SAME-LINE-USE-MSG2-NEXT: {{S}}AME-LINE-USE2-NEXT: {{\[\[#UNSI2:UNSI\+1\]\] \[\[#UNSI2\+1\]\]}}
SAME-LINE-USE-MSG2-NEXT:        {{^}}                                          ^{{$}}

; Invalid change of format in variable redefinition.
RUN: %ProtectFileCheckOutput \
RUN: not FileCheck --check-prefix REDEF-NEW-FMT --input-file %s %s 2>&1 \
RUN:   | FileCheck --strict-whitespace --check-prefix REDEF-NEW-FMT-MSG %s

VAR REDEF FMT CHANGE
22
DC
REDEF-NEW-FMT-LABEL: VAR REDEF FMT CHANGE
REDEF-NEW-FMT-NEXT: [[#UNSI:]]
REDEF-NEW-FMT-NEXT: [[#%X,UNSI:]]
REDEF-NEW-FMT-MSG: numeric-expression.txt:[[#@LINE-1]]:31: error: format different from previous variable definition
REDEF-NEW-FMT-MSG-NEXT: {{R}}EDEF-NEW-FMT-NEXT: {{\[\[#%X,UNSI:\]\]}}
REDEF-NEW-FMT-MSG-NEXT:    {{^}}                              ^{{$}}