File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -769,7 +769,7 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
769769 variables.clear ();
770770 break ;
771771 }
772- if (Token::simpleMatch (tok, " goto" )) { // https://sourceforge.net/apps/trac/cppcheck/ticket/ 4447
772+ if (Token::Match (tok, " goto|break " )) { // # 4447
773773 variables.clear ();
774774 break ;
775775 }
Original file line number Diff line number Diff line change @@ -3770,9 +3770,25 @@ class TestUnusedVar : public TestFixture {
37703770 " }\n "
37713771 " return ptr;\n "
37723772 " }" );
3773-
3774- // Don't write an error that "a" is not used
3775- ASSERT_EQUALS (" " , errout.str ());
3773+ ASSERT_EQUALS (" " , errout.str ()); // Don't write an error that "a" is not used
3774+
3775+ functionVariableUsage (" void x() {\n "
3776+ " unsigned char* pcOctet = NULL;\n "
3777+ " float fValeur;\n "
3778+ " switch (pnodeCurrent->left.pnode->usLen) {\n "
3779+ " case 4:\n "
3780+ " fValeur = (float)pevalDataLeft->data.fd;\n "
3781+ " pcOctet = (unsigned char*)&fValeur;\n "
3782+ " break;\n "
3783+ " case 8:\n "
3784+ " pcOctet = (unsigned char*)&pevalDataLeft->data.fd;\n "
3785+ " break;\n "
3786+ " }\n "
3787+ " for (iIndice = 1; iIndice <= (pnodeCurrent->usLen / 2); iIndice++) {\n "
3788+ " *pcData = gacHexChar[(*pcOctet >> 4) & 0x0F];\n "
3789+ " }\n "
3790+ " }" );
3791+ ASSERT_EQUALS (" " , errout.str ()); // Don't write an error that "fValeur" is not used
37763792 }
37773793
37783794 void localvarNULL () { // #4203 - Setting NULL value is not redundant - it is safe
You can’t perform that action at this time.
0 commit comments