diff --git a/lib/checkother.cpp b/lib/checkother.cpp index aae43d771..82126afda 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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()) diff --git a/test/testother.cpp b/test/testother.cpp index c2f450dde..ee30d1ab5 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -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()