diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 4f261e1a7..df35cb0d1 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2590,7 +2590,7 @@ void Tokenizer::setVarId() if (!tok3->isStandardType() && tok3->str() != "void" && !Token::Match(tok3, "struct|union|class %type%") && tok3->str() != "." && !Token::Match(tok2->link()->previous(), "[&*]")) { bool isDecl = true; for (; tok3; tok3 = tok3->nextArgument()) { - if (tok3->strAt(-1) == "&" || tok3->strAt(-1) == "*" || (notstart.find(tok3->str()) == notstart.end() && setVarIdParseDeclaration(&tok3, variableId, executableScope.top(), isCPP()))) { + if (tok3->strAt(-2) == "&" || tok3->strAt(-2) == "*" || (notstart.find(tok3->str()) == notstart.end() && setVarIdParseDeclaration(&tok3, variableId, executableScope.top(), isCPP()))) { isDecl = false; break; } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 1a8e82ba8..52b51c628 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -4639,6 +4639,7 @@ private: " int method_with_internal(int&);\n" " int method_with_internal(A* b, X&);\n" " int method_with_internal(X&, A* b);\n" + " int method_with_internal(const B &, int);\n" "};"; ASSERT_EQUALS("\n\n##file 0\n" "1: class Fred {\n" @@ -4647,7 +4648,8 @@ private: "4: int method_with_internal ( int & ) ;\n" "5: int method_with_internal ( A * b@1 , X & ) ;\n" "6: int method_with_internal ( X & , A * b@2 ) ;\n" - "7: } ;\n", tokenizeDebugListing(code, false, "test.cpp")); + "7: int method_with_internal ( const B & , int ) ;\n" + "8: } ;\n", tokenizeDebugListing(code, false, "test.cpp")); } void varid_initList() {