File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -2457,6 +2457,8 @@ void CheckClass::checkPublicInterfaceDivZero(bool test)
24572457 continue ;
24582458 if (!func->hasBody ())
24592459 continue ;
2460+ if (func->name ().compare (0 ,8 ," operator" )==0 )
2461+ continue ;
24602462 for (const Token *tok = func->functionScope ->classStart ; tok; tok = tok->next ()) {
24612463 if (Token::Match (tok, " if|}" ))
24622464 break ;
Original file line number Diff line number Diff line change @@ -6527,6 +6527,13 @@ class TestClass : public TestFixture {
65276527 " void A::f1() {}\n "
65286528 " void A::f2(int x) { int a = 1000 / x; }" );
65296529 ASSERT_EQUALS (" [test.cpp:7]: (warning) Arbitrary usage of public method A::f2() could result in division by zero.\n " , errout.str ());
6530+
6531+ checkPublicInterfaceDivZero (" class A {\n "
6532+ " public:\n "
6533+ " void operator/(int x);\n "
6534+ " }\n "
6535+ " void A::operator/(int x) { int a = 1000 / x; }" );
6536+ ASSERT_EQUALS (" " , errout.str ());
65306537 }
65316538};
65326539
You can’t perform that action at this time.
0 commit comments