TestCharVar: Fixed some false positives
This commit is contained in:
parent
7d234fd5c2
commit
ffa8e3d0b6
|
@ -685,15 +685,15 @@ void CheckCharVariable()
|
|||
break;
|
||||
}
|
||||
|
||||
else if ( Match(tok2, "%var% [ %var1% ]", varname) )
|
||||
if (!Match(tok2,".") && Match(tok2->next, "%var% [ %var1% ]", varname))
|
||||
{
|
||||
std::ostringstream errmsg;
|
||||
errmsg << FileLine(tok2) << ": Warning - using char variable as array index";
|
||||
errmsg << FileLine(tok2->next) << ": Warning - using char variable as array index";
|
||||
ReportErr(errmsg.str());
|
||||
break;
|
||||
}
|
||||
|
||||
else if ( Match(tok2, "[&|] %var1%", varname) || Match(tok2, "%var1% [&|]", varname) )
|
||||
if ( Match(tok2, "%var% [&|] %var1%", varname) || Match(tok2, "%var1% [&|]", varname) )
|
||||
{
|
||||
std::ostringstream errmsg;
|
||||
errmsg << FileLine(tok2) << ": Warning - using char variable in bit operation";
|
||||
|
|
|
@ -37,7 +37,8 @@ private:
|
|||
void run()
|
||||
{
|
||||
TEST_CASE( array_index );
|
||||
TEST_CASE( bitop );
|
||||
TEST_CASE( bitop1 );
|
||||
TEST_CASE( bitop2 );
|
||||
}
|
||||
|
||||
void check( const char code[] )
|
||||
|
@ -82,7 +83,7 @@ private:
|
|||
}
|
||||
|
||||
|
||||
void bitop()
|
||||
void bitop1()
|
||||
{
|
||||
check( "void foo()\n"
|
||||
"{\n"
|
||||
|
@ -91,6 +92,16 @@ private:
|
|||
"}\n" );
|
||||
ASSERT_EQUALS( std::string("[test.cpp:4]: Warning - using char variable in bit operation\n"), errout.str() );
|
||||
}
|
||||
|
||||
void bitop2()
|
||||
{
|
||||
check( "void foo()\n"
|
||||
"{\n"
|
||||
" char ch;\n"
|
||||
" func(&ch);\n"
|
||||
"}\n" );
|
||||
ASSERT_EQUALS( std::string(""), errout.str() );
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST( TestCharVar )
|
||||
|
|
Loading…
Reference in New Issue