functionVariableUsage: no longer SIGSEGVs on unfinished struct. Fixes Ticket #31.
This commit is contained in:
parent
45c1b3c3ca
commit
e930525aa4
|
@ -896,6 +896,9 @@ void CheckOther::functionVariableUsage()
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
}
|
}
|
||||||
while (tok && indentlevel > indentlevel0);
|
while (tok && indentlevel > indentlevel0);
|
||||||
|
|
||||||
|
if (! tok)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok, "[;{}] bool|char|short|int|long|float|double %var% ;|="))
|
if (Token::Match(tok, "[;{}] bool|char|short|int|long|float|double %var% ;|="))
|
||||||
|
|
|
@ -69,6 +69,7 @@ private:
|
||||||
TEST_CASE(localvarStruct1);
|
TEST_CASE(localvarStruct1);
|
||||||
TEST_CASE(localvarStruct2);
|
TEST_CASE(localvarStruct2);
|
||||||
TEST_CASE(localvarStruct3);
|
TEST_CASE(localvarStruct3);
|
||||||
|
TEST_CASE(localvarStruct4); // Ticket #31: sigsegv on incomplete struct
|
||||||
|
|
||||||
TEST_CASE(localvarOp); // Usage with arithmetic operators
|
TEST_CASE(localvarOp); // Usage with arithmetic operators
|
||||||
TEST_CASE(localvarInvert); // Usage with inverted variable
|
TEST_CASE(localvarInvert); // Usage with inverted variable
|
||||||
|
@ -275,6 +276,15 @@ private:
|
||||||
ASSERT_EQUALS(std::string(""), errout.str());
|
ASSERT_EQUALS(std::string(""), errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void localvarStruct4()
|
||||||
|
{
|
||||||
|
/* This must not SIGSEGV: */
|
||||||
|
functionVariableUsage("void foo()\n"
|
||||||
|
"{\n"
|
||||||
|
" struct { \n");
|
||||||
|
errout.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void localvarOp()
|
void localvarOp()
|
||||||
|
|
Loading…
Reference in New Issue