functionVariableUsage: no longer SIGSEGVs on unfinished struct. Fixes Ticket #31.

This commit is contained in:
Leandro Penz 2009-01-18 19:45:43 +00:00
parent 45c1b3c3ca
commit e930525aa4
2 changed files with 13 additions and 0 deletions

View File

@ -896,6 +896,9 @@ void CheckOther::functionVariableUsage()
tok = tok->next();
}
while (tok && indentlevel > indentlevel0);
if (! tok)
break;
}
if (Token::Match(tok, "[;{}] bool|char|short|int|long|float|double %var% ;|="))

View File

@ -69,6 +69,7 @@ private:
TEST_CASE(localvarStruct1);
TEST_CASE(localvarStruct2);
TEST_CASE(localvarStruct3);
TEST_CASE(localvarStruct4); // Ticket #31: sigsegv on incomplete struct
TEST_CASE(localvarOp); // Usage with arithmetic operators
TEST_CASE(localvarInvert); // Usage with inverted variable
@ -275,6 +276,15 @@ private:
ASSERT_EQUALS(std::string(""), errout.str());
}
void localvarStruct4()
{
/* This must not SIGSEGV: */
functionVariableUsage("void foo()\n"
"{\n"
" struct { \n");
errout.str();
}
void localvarOp()