From f462d7c91bd49fa11c2a4e658148e3af31881501 Mon Sep 17 00:00:00 2001 From: William Jakobsson <50847546+wjakobsson@users.noreply.github.com> Date: Fri, 30 Oct 2026 14:49:14 +0100 Subject: [PATCH 1/3] test --- test/testvarid.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/testvarid.cpp b/test/testvarid.cpp index a1874d3c5f2..2a489772673 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -1630,12 +1630,14 @@ class TestVarID : public TestFixture { "A f(3);\n" "A f2(true);\n" "A g();\n" - "A e(int c);\n", dinit(TokenizeOptions, $.cpp = false)); + "A e(int c);\n" + "A h(T (*p)[16]);\n", dinit(TokenizeOptions, $.cpp = false)); const char expected[] = "1: A f@1 ( 3 ) ;\n" "2: A f2@2 ( true ) ;\n" "3: A g ( ) ;\n" - "4: A e ( int c@3 ) ;\n"; + "4: A e ( int c@3 ) ;\n" + "5: A h ( T ( * p@4 ) [ 16 ] ) ;\n"; ASSERT_EQUALS(expected, actual); } From d92ca92a4ada94672d1b6d4eefe15658461a8210 Mon Sep 17 00:00:00 2001 From: William Jakobsson <50847546+wjakobsson@users.noreply.github.com> Date: Fri, 30 Oct 2026 14:49:16 +0100 Subject: [PATCH 2/3] fix --- lib/tokenize.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 0ad9ddef1d6..be923628244 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5062,7 +5062,7 @@ void Tokenizer::setVarIdPass1() if (tok3->isLiteral() || (tok3->isName() && (variableMap.hasVariable(tok3->str()) || - (tok3->strAt(-1) == "(" && Token::simpleMatch(tok3->next(), "(") && !Token::simpleMatch(tok3->linkAt(1)->next(), "(")))) || + (tok3->strAt(-1) == "(" && Token::simpleMatch(tok3->next(), "(") && !Token::Match(tok3->linkAt(1)->next(), "(|[")))) || tok3->isOp() || tok3->str() == "(" || notstart.find(tok3->str()) != notstart.end()) { From 09b35e0908f115f5ef5cf3be4452a5e5d9956e7d Mon Sep 17 00:00:00 2001 From: William Jakobsson <50847546+wjakobsson@users.noreply.github.com> Date: Wed, 4 Nov 2026 09:14:02 +0100 Subject: [PATCH 3/3] nits --- lib/tokenize.cpp | 3 ++- test/testvarid.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index be923628244..e2da734a14d 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5062,7 +5062,8 @@ void Tokenizer::setVarIdPass1() if (tok3->isLiteral() || (tok3->isName() && (variableMap.hasVariable(tok3->str()) || - (tok3->strAt(-1) == "(" && Token::simpleMatch(tok3->next(), "(") && !Token::Match(tok3->linkAt(1)->next(), "(|[")))) || + (tok3->strAt(-1) == "(" && Token::simpleMatch(tok3->next(), "(") && !Token::simpleMatch(tok3->linkAt(1)->next(), "(") && + !(Token::Match(tok3->next(), "( *|&|&& %name%| ) [") && !variableMap.hasVariable(tok3->strAt(3)))))) || tok3->isOp() || tok3->str() == "(" || notstart.find(tok3->str()) != notstart.end()) { diff --git a/test/testvarid.cpp b/test/testvarid.cpp index 2a489772673..d0f910be099 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -1631,13 +1631,17 @@ class TestVarID : public TestFixture { "A f2(true);\n" "A g();\n" "A e(int c);\n" - "A h(T (*p)[16]);\n", dinit(TokenizeOptions, $.cpp = false)); + "A h(T (*p)[16]);\n" + "int x(g(1)[0]);\n" + "A u(T (*)[16]);\n", dinit(TokenizeOptions, $.cpp = false)); const char expected[] = "1: A f@1 ( 3 ) ;\n" "2: A f2@2 ( true ) ;\n" "3: A g ( ) ;\n" "4: A e ( int c@3 ) ;\n" - "5: A h ( T ( * p@4 ) [ 16 ] ) ;\n"; + "5: A h ( T ( * p@4 ) [ 16 ] ) ;\n" + "6: int x@5 ( g ( 1 ) [ 0 ] ) ;\n" + "7: A u ( T ( * ) [ 16 ] ) ;\n"; ASSERT_EQUALS(expected, actual); }