Fix issue 9202: False positive: std::array, size is a constant (#2132)
This commit is contained in:
parent
717aa826d8
commit
121093658d
|
@ -5365,8 +5365,8 @@ static void valueFlowContainerSize(TokenList *tokenlist, SymbolDatabase* symbold
|
|||
continue;
|
||||
ValueFlow::Value value(0);
|
||||
if (var->valueType()->container->size_templateArgNo >= 0) {
|
||||
if (var->dimensions().size() == 1 && var->dimensions().front().known)
|
||||
value.intvalue = var->dimensions().front().num;
|
||||
if (var->dimensions().size() == 1 && var->dimensions().front().tok && var->dimensions().front().tok->hasKnownIntValue())
|
||||
value.intvalue = var->dimensions().front().tok->getKnownIntValue();
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -311,6 +311,13 @@ private:
|
|||
" ++abc[s];\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkNormal("void f() {\n"
|
||||
" static const int N = 4;\n"
|
||||
" std::array<int, N> x;\n"
|
||||
" x[0] = 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void outOfBoundsIndexExpression() {
|
||||
|
|
Loading…
Reference in New Issue