CheckBufferOverrun: fix FP for array definition of static class member

This commit is contained in:
Daniel Marjamäki 2019-03-13 06:39:09 +01:00
parent 67e8b99c2c
commit 81a1d744c6
2 changed files with 7 additions and 3 deletions

View File

@ -188,7 +188,7 @@ void CheckBufferOverrun::arrayIndex()
const Token *parent = tok;
while (parent && !Token::simpleMatch(parent->astParent(), "="))
parent = parent->astParent();
if (parent && parent == parent->astParent()->astOperand1())
if (!parent || parent == parent->astParent()->astOperand1())
continue;
}

View File

@ -2138,11 +2138,15 @@ private:
ASSERT_EQUALS("", errout.str());
check("class X { static const int x[100]; };\n" // #6070
"const int X::x[100] = {0};", false, "test.cpp");
"const int X::x[100] = {0};");
ASSERT_EQUALS("", errout.str());
check("namespace { class X { static const int x[100]; };\n" // #6232
"const int X::x[100] = {0}; }", false, "test.cpp");
"const int X::x[100] = {0}; }");
ASSERT_EQUALS("", errout.str());
check("class ActorSprite { static ImageSet * targetCursorImages[2][10]; };\n"
"ImageSet *ActorSprite::targetCursorImages[2][10];\n");
ASSERT_EQUALS("", errout.str());
}