Fixed #1571 ('C-style pointer casting' should not be reported for C files)
This commit is contained in:
parent
6b52730d4e
commit
a15e25f9fe
|
@ -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())
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue