From 408daf946ac4edbf79de2e6bc7dff86e82178d8e Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Thu, 6 Aug 2026 23:06:28 +0200 Subject: [PATCH] Fix #14967 internalAstError with function pointer in if --- lib/tokenlist.cpp | 2 +- test/testtokenize.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index ca509904db3..3e14464a95f 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -461,7 +461,7 @@ static Token* skipDecl(Token* tok, std::vector* inner = nullptr) return Token::Match(tok, "%name%| ,|)"); }; - if (!Token::Match(tok->previous(), "( %name%")) + if (tok->varId() || !Token::Match(tok->previous(), "( %name%")) return tok; Token *vartok = tok; while (Token::Match(vartok, "%name%|*|&|&&|::|<")) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 600d457e944..3d8ad479ccd 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -446,6 +446,7 @@ class TestTokenizer : public TestFixture { TEST_CASE(astfuncdecl); TEST_CASE(astarrayinit); TEST_CASE(astbracedinit); + TEST_CASE(astif); TEST_CASE(startOfExecutableScope); @@ -7643,6 +7644,14 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("anullptr{", testAst("int *a { nullptr };", AstStyle::Simple, ListSimplification::Full)); } + void astif() { + ASSERT_EQUALS( // #14967 + "ifxx(&&(", + testAst("void f(int (*x)()) {\n" + " if (x && x()) {}\n" + "}\n", AstStyle::Simple, ListSimplification::Full)); + } + #define isStartOfExecutableScope(offset, code) isStartOfExecutableScope_(offset, code, __FILE__, __LINE__) template bool isStartOfExecutableScope_(int offset, const char (&code)[size], const char* file, int line) {