From 0b8581e71713f6ba50aeab2d088fbbf93bacb482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 8 Mar 2011 20:41:41 +0100 Subject: [PATCH] Fixed #2620 (Tokenizer::setVarId : wrong handling of member function parameters) --- lib/tokenize.cpp | 4 ++++ test/testtokenize.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 3881aec3b..e23d9a605 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3603,6 +3603,10 @@ void Tokenizer::setVarId() --indentlevel; } + // skip parantheses.. + else if (tok2->str() == "(") + tok2 = tok2->link(); + // Found a member variable.. else if (indentlevel == 1 && tok2->varId() > 0) varlist[tok2->str()] = tok2->varId(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 4fea2b224..6b316e3f1 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -190,6 +190,7 @@ private: TEST_CASE(varidclass6); TEST_CASE(varidclass7); TEST_CASE(varidclass8); + TEST_CASE(varidclass9); TEST_CASE(file1); TEST_CASE(file2); @@ -3363,6 +3364,32 @@ private: ASSERT_EQUALS(expected, tokenizeDebugListing(code)); } + void varidclass9() + { + const std::string code("typedef char Str[10];" + "class A {\n" + "public:\n" + " void f(Str &cl);\n" + " void g(Str cl);\n" + "}\n" + "void Fred::f(Str &cl) {\n" + " sizeof(cl);\n" + "}"); + + const std::string expected("\n\n" + "##file 0\n" + "1: ; class A {\n" + "2: public:\n" + "3: void f ( char ( & cl ) [ 10 ] ) ;\n" + "4: void g ( char cl@1 [ 10 ] ) ;\n" + "5: }\n" + "6: void Fred :: f ( char ( & cl ) [ 10 ] ) {\n" + "7: sizeof ( cl ) ;\n" + "8: }\n"); + + ASSERT_EQUALS(expected, tokenizeDebugListing(code)); + } + void file1() {