diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 233d08e9a..c8aaaacd0 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1047,6 +1047,10 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value, const Setti } } } + + else if (Token::Match(parent, ":: %name%") && parent->astOperand2() == tok) { + setTokenValue(parent, value, settings); + } } static void setTokenValueCast(Token *parent, const ValueType &valueType, const ValueFlow::Value &value, const Settings *settings) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 3fbe185db..e62206bf4 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -331,6 +331,13 @@ private: ASSERT_EQUALS((int)('a'), valueOfTok("x='a';", "'a'").intvalue); ASSERT_EQUALS((int)('\n'), valueOfTok("x='\\n';", "'\\n'").intvalue); ASSERT_EQUALS(0xFFFFFFFF00000000, valueOfTok("x=0xFFFFFFFF00000000;","18446744069414584320U").intvalue); // #7701 + + // scope + { + const char code[] = "namespace N { enum E {e0,e1}; }\n" + "void foo() { x = N::e1; }"; + ASSERT_EQUALS(1, valueOfTok(code, "::").intvalue); + } } void valueFlowString() {