Valueflow: support global static const variables (#1861)
This commit is contained in:
parent
090fa255e8
commit
d1d622b74c
|
@ -1470,7 +1470,6 @@ static void valueFlowGlobalConstVar(TokenList* tokenList, const Settings *settin
|
||||||
continue;
|
continue;
|
||||||
// Initialization...
|
// Initialization...
|
||||||
if (tok == tok->variable()->nameToken() &&
|
if (tok == tok->variable()->nameToken() &&
|
||||||
!tok->variable()->isStatic() &&
|
|
||||||
!tok->variable()->isVolatile() &&
|
!tok->variable()->isVolatile() &&
|
||||||
!tok->variable()->isArgument() &&
|
!tok->variable()->isArgument() &&
|
||||||
tok->variable()->isConst() &&
|
tok->variable()->isConst() &&
|
||||||
|
|
|
@ -3265,6 +3265,10 @@ private:
|
||||||
code = "volatile const int x = 42;\n"
|
code = "volatile const int x = 42;\n"
|
||||||
"void f(){ int a = x; }\n";
|
"void f(){ int a = x; }\n";
|
||||||
ASSERT_EQUALS(false, testValueOfXKnown(code, 2U, 42));
|
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() {
|
void valueFlowGlobalStaticVar() {
|
||||||
|
|
Loading…
Reference in New Issue