From 11614021e8dbce648fea16374fecde4051d806a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 5 May 2012 09:59:43 +0200 Subject: [PATCH] Fixed #3768 (Tokenizer::setVarId: no varid for 'std::string' parameter after a 'std::string' parameter called 'string') --- lib/tokenize.cpp | 2 +- test/testtokenize.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 906d6add4..2c468223e 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2754,7 +2754,7 @@ static bool setVarIdParseDeclaration(const Token **tok, const std::mapstr() == "const") { ; // just skip "const" - } else if (!hasstruct && variableId.find(tok2->str()) != variableId.end()) { + } else if (!hasstruct && variableId.find(tok2->str()) != variableId.end() && tok2->previous()->str() != "::") { ++typeCount; tok2 = tok2->next(); if (tok2->str() != "::") diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 5757dca8b..1c3c6e60f 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -210,6 +210,7 @@ private: TEST_CASE(varid44); TEST_CASE(varid45); // #3466 TEST_CASE(varid46); // struct varname + TEST_CASE(varid47); // function parameters TEST_CASE(varid_cpp_keywords_in_c_code); TEST_CASE(varidFunctionCall1); TEST_CASE(varidFunctionCall2); @@ -3215,6 +3216,13 @@ private: tokenizeDebugListing(code, false, "test.c")); } + void varid47() { // #3768 + const std::string code("void f(std::string &string, std::string &len) {}"); + ASSERT_EQUALS("\n\n##file 0\n" + "1: void f ( std :: string & string@1 , std :: string & len@2 ) { }\n", + tokenizeDebugListing(code, false, "test.cpp")); + } + void varid_cpp_keywords_in_c_code() { const char code[] = "void f() {\n" " delete d;\n"