mirror of
https://github.com/RPCS3/llvm.git
synced 2026-01-31 01:25:19 +01:00
Summary: Diagnosing use of undefined variables takes place in parseNumericVariableUse() and printSubstitutions() for numeric variables but only takes place in printSubstitutions() for string variables. The reason for the split location of diagnostics is that parsing is not aware of the clearing of variables due to --enable-var-scope and thus use of variables cleared in this way can only be catched by printSubstitutions(). Beyond the code level inconsistency, there is also a user facing inconsistency since diagnostics look different between the two functions. While the diagnostic in printSubstitutions is more verbose, doing the diagnostic there allows to diagnose all undefined variables rather than just the first one and error out. This patch create dummy variable definition when encountering a use of undefined variable so that parsing can proceed and be diagnosed by printSubstitutions() later. Tests that were testing whether parsing fails in such case are thus modified accordingly. Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk Subscribers: JonChesterfield, rogfer01, hfinkel, kristina, rnk, tra, arichardson, grimar, dblaikie, probinson, llvm-commits, hiraditya Tags: #llvm Differential Revision: https://reviews.llvm.org/D64228 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365219 91177308-0d34-0410-b5e6-96231b3b80d8
149 lines
5.3 KiB
Plaintext
149 lines
5.3 KiB
Plaintext
RUN: FileCheck --input-file %s %s
|
|
|
|
; We use CHECK-NEXT directives to force a match on all lines with digits.
|
|
|
|
; Numeric variable definition without spaces.
|
|
DEF NO SPC
|
|
11
|
|
CHECK-LABEL: DEF NO SPC
|
|
CHECK-NEXT: [[#VAR1:]]
|
|
|
|
; Numeric variable definition with different spacing.
|
|
DEF SPC
|
|
11
|
|
11
|
|
11
|
|
CHECK-LABEL: DEF SPC
|
|
CHECK-NEXT: [[# VAR1a:]]
|
|
CHECK-NEXT: [[# VAR1b :]]
|
|
CHECK-NEXT: [[# VAR1c : ]]
|
|
|
|
; Numeric expressions using variables defined on other lines without spaces.
|
|
USE NO SPC
|
|
11
|
|
12
|
|
10
|
|
11
|
|
11
|
|
11
|
|
CHECK-LABEL: USE
|
|
CHECK-NEXT: [[#VAR1]]
|
|
CHECK-NEXT: [[#VAR1+1]]
|
|
CHECK-NEXT: [[#VAR1-1]]
|
|
CHECK-NEXT: [[#VAR1a]]
|
|
CHECK-NEXT: [[#VAR1b]]
|
|
CHECK-NEXT: [[#VAR1c]]
|
|
|
|
; Numeric expressions using variables defined on other lines with different
|
|
; spacing.
|
|
USE SPC
|
|
11
|
|
11
|
|
12
|
|
12
|
|
12
|
|
12
|
|
10
|
|
10
|
|
10
|
|
10
|
|
CHECK-LABEL: USE SPC
|
|
CHECK-NEXT: [[# VAR1]]
|
|
CHECK-NEXT: [[# VAR1 ]]
|
|
CHECK-NEXT: [[# VAR1+1]]
|
|
CHECK-NEXT: [[# VAR1 +1]]
|
|
CHECK-NEXT: [[# VAR1 + 1]]
|
|
CHECK-NEXT: [[# VAR1 + 1 ]]
|
|
CHECK-NEXT: [[# VAR1-1]]
|
|
CHECK-NEXT: [[# VAR1 -1]]
|
|
CHECK-NEXT: [[# VAR1 - 1]]
|
|
CHECK-NEXT: [[# VAR1 - 1 ]]
|
|
|
|
; Numeric expressions using variables defined on the command-line and an
|
|
; immediate interpreted as an unsigned value.
|
|
; Note: 9223372036854775819 = 0x8000000000000000 + 11
|
|
; 9223372036854775808 = 0x8000000000000000
|
|
USE UNSIGNED IMM
|
|
9223372036854775819
|
|
CHECK-LABEL: USE UNSIGNED IMM
|
|
CHECK-NEXT: [[#VAR1+9223372036854775808]]
|
|
|
|
; Numeric expression using undefined variable.
|
|
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: [[#UNDEFVAR]]
|
|
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: {{\[\[#UNDEFVAR\]\]}}
|
|
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 "UNDEFVAR"
|
|
UNDEF-USE-MSG-NEXT: UNDEFVAR: 11
|
|
UNDEF-USE-MSG-NEXT: {{^\^$}}
|
|
|
|
; Numeric expression with unsupported operator.
|
|
RUN: not FileCheck -D#NUMVAR=10 --check-prefix INVAL-OP --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: not FileCheck --check-prefixes CONFLICT,CONFLICT1,CONFLICT2 --input-file %s %s 2>&1 \
|
|
RUN: | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s
|
|
RUN: not FileCheck -D#NUMVAR=42 --check-prefixes CONFLICT,CONFLICT2 --input-file %s %s 2>&1 \
|
|
RUN: | FileCheck --strict-whitespace --check-prefix INPUT-STR-CONFLICT %s
|
|
RUN: not FileCheck -D#NUMVAR=42 -DNUMVAR=foobar --check-prefix CONFLICT --input-file %s %s 2>&1 \
|
|
RUN: | FileCheck --strict-whitespace --check-prefix CLI-STR-CONFLICT %s
|
|
RUN: not FileCheck --check-prefixes CONFLICT,CONFLICT3,CONFLICT4 --input-file %s %s 2>&1 \
|
|
RUN: | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s
|
|
RUN: not FileCheck -DSTRVAR=foobar --check-prefixes CONFLICT,CONFLICT4 --input-file %s %s 2>&1 \
|
|
RUN: | FileCheck --strict-whitespace --check-prefix INPUT-NUM-CONFLICT %s
|
|
RUN: not FileCheck -DSTRVAR=foobar -D#STRVAR=42 --check-prefix CONFLICT --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:20: error: string variable with name 'STRVAR' already exists
|
|
CLI-NUM-CONFLICT-NEXT: Global define #2: #STRVAR=42
|
|
CLI-NUM-CONFLICT-NEXT: {{^ \^$}}
|
|
|
|
; Numeric variable definition with too big value.
|
|
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: {{^ \^$}}
|