classPublicInterfaceDivZero: don't warn in overloaded operators. It is normal behaviour that these are not protected.
This commit is contained in:
parent
05e1e5e0a0
commit
299835da2f
|
@ -2457,6 +2457,8 @@ void CheckClass::checkPublicInterfaceDivZero(bool test)
|
|||
continue;
|
||||
if (!func->hasBody())
|
||||
continue;
|
||||
if (func->name().compare(0,8,"operator")==0)
|
||||
continue;
|
||||
for (const Token *tok = func->functionScope->classStart; tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "if|}"))
|
||||
break;
|
||||
|
|
|
@ -6527,6 +6527,13 @@ private:
|
|||
"void A::f1() {}\n"
|
||||
"void A::f2(int x) { int a = 1000 / x; }");
|
||||
ASSERT_EQUALS("[test.cpp:7]: (warning) Arbitrary usage of public method A::f2() could result in division by zero.\n", errout.str());
|
||||
|
||||
checkPublicInterfaceDivZero("class A {\n"
|
||||
"public:\n"
|
||||
" void operator/(int x);\n"
|
||||
"}\n"
|
||||
"void A::operator/(int x) { int a = 1000 / x; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue