From 8479457ba5acb2ab7fb7ba0957934a30a1398f41 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 31 Jul 2026 13:32:31 +0200 Subject: [PATCH 1/3] Update token.cpp --- lib/token.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/token.cpp b/lib/token.cpp index d8b438c5073..eac69decee7 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -2433,6 +2433,7 @@ std::pair Token::typeDecl(const Token* tok, bool poi varTok = varTok->next(); while (Token::Match(varTok, "%name% ::")) varTok = varTok->tokAt(2); + assert(varTok != tok); std::pair r = typeDecl(varTok); if (r.first) return r; From 089f4737ea792ad6d60be778a4e618ddd363019a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 31 Jul 2026 13:34:02 +0200 Subject: [PATCH 2/3] Update valueflow.cpp --- lib/valueflow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 63543e1a8f5..da49c78e709 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -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 From 7f836d970fca946b617117380f9f0b0ebbc996c0 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 31 Jul 2026 13:35:22 +0200 Subject: [PATCH 3/3] Update testvalueflow.cpp --- test/testvalueflow.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index c98680b8180..72e115cfe2b 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -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() {