Valueflow: support global static const variables (#1861)

This commit is contained in:
Rikard Falkeborn 2019-06-29 14:33:55 +02:00 committed by Daniel Marjamäki
parent 090fa255e8
commit d1d622b74c
2 changed files with 4 additions and 1 deletions

View File

@ -1470,7 +1470,6 @@ static void valueFlowGlobalConstVar(TokenList* tokenList, const Settings *settin
continue;
// Initialization...
if (tok == tok->variable()->nameToken() &&
!tok->variable()->isStatic() &&
!tok->variable()->isVolatile() &&
!tok->variable()->isArgument() &&
tok->variable()->isConst() &&

View File

@ -3265,6 +3265,10 @@ private:
code = "volatile const int x = 42;\n"
"void f(){ int a = x; }\n";
ASSERT_EQUALS(false, testValueOfXKnown(code, 2U, 42));
code = "static const int x = 42;\n"
"void f(){ int a = x; }\n";
ASSERT_EQUALS(true, testValueOfX(code, 2U, 42));
}
void valueFlowGlobalStaticVar() {