Fixed #1571 ('C-style pointer casting' should not be reported for C files)

This commit is contained in:
Daniel Marjamäki 2010-04-24 16:46:09 +02:00
parent 6b52730d4e
commit a15e25f9fe
2 changed files with 15 additions and 6 deletions

View File

@ -45,7 +45,7 @@ CheckOther instance;
void CheckOther::warningOldStylePointerCast()
{
if (!_settings->_checkCodingStyle)
if (!_settings->_checkCodingStyle || _tokenizer->fileLine(_tokenizer->tokens()).find(".cpp") == std::string::npos)
return;
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())

View File

@ -1993,10 +1993,15 @@ private:
void checkOldStylePointerCast(const char code[])
{
// Tokenize..
Tokenizer tokenizer;
Tokenizer tokenizerCpp;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.setVarId();
tokenizerCpp.tokenize(istr, "test.cpp");
tokenizerCpp.setVarId();
Tokenizer tokenizerC;
std::istringstream istr2(code);
tokenizerC.tokenize(istr2, "test.c");
tokenizerC.setVarId();
// Clear the error buffer..
errout.str("");
@ -2004,8 +2009,12 @@ private:
// Check for redundant code..
Settings settings;
settings._checkCodingStyle = true;
CheckOther checkOther(&tokenizer, &settings, this);
checkOther.warningOldStylePointerCast();
CheckOther checkOtherCpp(&tokenizerCpp, &settings, this);
checkOtherCpp.warningOldStylePointerCast();
CheckOther checkOtherC(&tokenizerC, &settings, this);
checkOtherC.warningOldStylePointerCast();
}
void oldStylePointerCast()