From 6881a364a2444e14769b339129569091f83fac45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 23 Sep 2008 16:03:39 +0000 Subject: [PATCH] CheckOther: Minor updates. Removed false positives for CheckScope --- CheckOther.cpp | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/CheckOther.cpp b/CheckOther.cpp index 22968e1fd..2985a7294 100644 --- a/CheckOther.cpp +++ b/CheckOther.cpp @@ -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()); - } -*/ - } -} \ No newline at end of file + } + } +} +