Fixed #1857 (XML tag no more included for unusedFunction error (1.44 regression))

This commit is contained in:
Daniel Marjamäki 2010-07-18 11:22:26 +02:00
parent 81a053aa90
commit c16b5d6f3a
2 changed files with 30 additions and 1 deletions

View File

@ -90,7 +90,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer)
// Multiple files => filename = "+"
else if (func.filename != tokenizer.getFiles()->at(0))
{
func.filename = "+";
//func.filename = "+";
func.usedOtherFile |= func.usedSameFile;
}
}

View File

@ -45,6 +45,8 @@ private:
TEST_CASE(throwIsNotAFunction);
TEST_CASE(unusedError);
TEST_CASE(initializationIsNotAFunction);
TEST_CASE(multipleFiles); // same function name in multiple files
}
void check(const char code[])
@ -181,6 +183,33 @@ private:
"};\n");
ASSERT_EQUALS("", errout.str());
}
void multipleFiles()
{
CheckUnusedFunctions c;
// Clear the error buffer..
errout.str("");
const char code[] = "static void f() { }";
for (int i = 1; i <= 2; ++i)
{
std::ostringstream fname;
fname << "test" << i << ".cpp";
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, fname.str().c_str());
c.parseTokens(tokenizer);
}
// Check for unused functions..
c.check(this);
ASSERT_EQUALS("[test1.cpp:1]: (style) The function 'f' is never used\n",errout.str());
}
};
REGISTER_TEST(TestUnusedFunctions)