Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2433,6 +2433,7 @@ std::pair<const Token*, const Token*> Token::typeDecl(const Token* tok, bool poi
varTok = varTok->next();
while (Token::Match(varTok, "%name% ::"))
varTok = varTok->tokAt(2);
assert(varTok != tok);
std::pair<const Token*, const Token*> r = typeDecl(varTok);
if (r.first)
return r;
Expand Down
2 changes: 1 addition & 1 deletion lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3142,7 +3142,7 @@ static void valueFlowLifetime(TokenList &tokenlist, ErrorLogger &errorLogger, co
valueFlowLifetimeConstructor(tok->next(), tokenlist, errorLogger, settings);
}
// Check function calls
else if (Token::Match(tok, "%name% (") && !Token::simpleMatch(tok->linkAt(1), ") {")) {
else if (tok->scope()->isExecutable() && Token::Match(tok, "%name% (")) {
valueFlowLifetimeFunction(tok, tokenlist, errorLogger, settings);
}
// Unique pointer lifetimes
Expand Down
11 changes: 11 additions & 0 deletions test/testvalueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8355,6 +8355,17 @@ class TestValueFlow : public TestFixture {
" auto b = a;\n"
"}\n";
(void)valueOfTok(code, "b");

code = "namespace O {}\n" // #14952
"namespace N {\n"
" using namespace O;\n"
" enum class E { E0 };\n"
" auto E0 = E::E0;\n"
" struct S {\n"
" E f() const { return E0; }\n"
" };\n"
"}\n";
(void)valueOfTok(code, "E0");
}

void valueFlowHang() {
Expand Down
Loading