diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 0ad9ddef1d6..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::simpleMatch(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 a1874d3c5f2..d0f910be099 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -1630,12 +1630,18 @@ 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" + "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"; + "4: A e ( int c@3 ) ;\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); }