Fixed recently introduced FP when C-Style casting nullpointers

This commit is contained in:
PKEuS 2014-08-04 11:42:14 +02:00
parent 4c80ca4e8e
commit 4a3d719386
2 changed files with 9 additions and 0 deletions

View File

@ -499,6 +499,9 @@ void CheckOther::warningOldStylePointerCast()
if (tok->strAt(1) == "const")
tok = tok->next();
if (tok->strAt(4) == "0") // Casting nullpointers is safe
continue;
// Is "type" a class?
if (_tokenizer->getSymbolDatabase()->isClassOrStruct(tok->strAt(1)))
cstyleCastError(tok);

View File

@ -1468,6 +1468,12 @@ private:
"};");
ASSERT_EQUALS("[test.cpp:3]: (style) C-style pointer casting\n", errout.str());
checkOldStylePointerCast("class SomeType;\n"
"class X : public Base {\n"
" X() : Base((SomeType*)0) {}\n"
"};");
ASSERT_EQUALS("", errout.str());
// #5560
checkOldStylePointerCast("class C;\n"
"\n"