CheckOther: Minor updates. Removed false positives for CheckScope

This commit is contained in:
Daniel Marjamäki 2008-09-23 16:03:39 +00:00
parent 815dd364ed
commit 6881a364a2
1 changed files with 23 additions and 26 deletions

View File

@ -423,6 +423,7 @@ void CheckVariableScope()
if (strcmp(tok1->str,"return")==0 ||
strcmp(tok1->str,"delete")==0 ||
strcmp(tok1->str,"goto")==0 ||
strcmp(tok1->str,"else")==0)
continue;
@ -669,35 +670,31 @@ void CheckCharVariable()
void CheckIncompleteStatement()
{
int parlevel = 0;
int parlevel = 0;
for ( const TOKEN *tok = tokens; tok; tok = tok->next )
{
if ( Match(tok,"; %str%") && !Match(gettok(tok,2), ",") )
{
std::ostringstream errmsg;
errmsg << FileLine(tok->next) << ": Redundant code: Found a statement that begins with string constant";
ReportErr(errmsg.str());
}
for ( const TOKEN *tok = tokens; tok; tok = tok->next )
{
if ( tok->str[0] == '(' )
++parlevel;
else if ( tok->str[0] == ')' )
--parlevel;
if ( Match(tok,"; %num%") && !Match(gettok(tok,2), ",") )
{
if ( parlevel != 0 )
continue;
if ( Match(tok,"; %str%") && !Match(gettok(tok,2), ",") )
{
std::ostringstream errmsg;
errmsg << FileLine(tok->next) << ": Redundant code: Found a statement that begins with numeric constant";
errmsg << FileLine(tok->next) << ": Redundant code: Found a statement that begins with string constant";
ReportErr(errmsg.str());
}
/*
if ( tok->str[0] == '(' )
++parlevel;
else if ( tok->str[0] == ')' )
--parlevel;
if ( parlevel == 0 && Match(tok, "[;{}] %var% ;") )
{
}
if ( Match(tok,"; %num%") && !Match(gettok(tok,2), ",") )
{
std::ostringstream errmsg;
errmsg << FileLine(tok->next) << ": Redundant code: Found a statement that only contains a variable";
errmsg << FileLine(tok->next) << ": Redundant code: Found a statement that begins with numeric constant";
ReportErr(errmsg.str());
}
*/
}
}
}
}
}