[PATCH] D104285: [analyzer] Retrieve a value from list initialization of constant array declaration in a global scope.
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 5 16:09:58 PDT 2021
NoQ added a comment.
Hey, I brought you some regressions!
const int arr[];
const int arr[3] = {1, 2, 3};
void foo() {
if (arr[0] < 3) {
}
}
test.c:6:14: warning: The left operand of '<' is a garbage value [core.UndefinedBinaryOperatorResult]
if (arr[0] < 3) {
~~~~~~ ^
1 warning generated.
According to the `-ast-dump` these are redeclarations of the same variable:
|-VarDecl 0x7fd1ed8844e0 <test.c:1:1, col:11> col:7 used arr 'const int []'
|-VarDecl 0x7fd1ed884670 prev 0x7fd1ed8844e0 <line:3:1, col:24> col:7 used arr 'const int [3]' cinit
| `-InitListExpr 0x7fd1ed8847a0 <col:16, col:24> 'const int [3]'
| |-IntegerLiteral 0x7fd1ed8846d8 <col:17> 'int' 1
| |-IntegerLiteral 0x7fd1ed8846f8 <col:20> 'int' 2
| `-IntegerLiteral 0x7fd1ed884718 <col:23> 'int' 3
So I suspect that you need to pick the redeclaration with the initializer before invoking the new machinery.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104285/new/
https://reviews.llvm.org/D104285
More information about the cfe-commits
mailing list