diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index 9183eb7e7..a167de331 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -900,7 +900,7 @@ void CheckNullPointer::nullConstantDereference() --indentlevel; } - if (tok->str() == "(" && Token::Match(tok->previous(), "sizeof|decltype")) + if (tok->str() == "(" && Token::Match(tok->previous(), "sizeof|decltype|typeid")) tok = tok->link(); else if (Token::simpleMatch(tok, "exit ( )")) { @@ -1064,7 +1064,7 @@ private: } if (Token::Match(&tok, "%var% (")) { - if (tok.str() == "sizeof") + if (tok.str() == "sizeof" || tok.str() == "typeid") return tok.next()->link(); // parse usage.. diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 3864a0383..3893815f9 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -1560,20 +1560,20 @@ private: " PolymorphicA* a = 0;\n" " return typeid(*a) == typeid(*a);\n" "}"); - TODO_ASSERT_EQUALS("", "[test.cpp:4]: (error) Null pointer dereference\n", errout.str()); + ASSERT_EQUALS("", errout.str()); check("struct NonPolymorphicA { ~A() {} };\n" "bool foo() {\n" " NonPolymorphicA* a = 0;\n" " return typeid(*a) == typeid(*a);\n" "}"); - TODO_ASSERT_EQUALS("", "[test.cpp:4]: (error) Null pointer dereference\n", errout.str()); + ASSERT_EQUALS("", errout.str()); check("bool foo() {\n" " char* c = 0;\n" " return typeid(*c) == typeid(*c);\n" "}"); - TODO_ASSERT_EQUALS("", "[test.cpp:3]: (error) Null pointer dereference\n", errout.str()); + ASSERT_EQUALS("", errout.str()); }