Fixed #2386 (segmentation fault occurs in the checking when typedef has same name as an enum constant)
This commit is contained in:
parent
3e5614a5a3
commit
2da3fea1b8
|
@ -341,6 +341,11 @@ void ExecutionPath::checkScope(const Token *tok, std::list<ExecutionPath *> &che
|
||||||
while (tok && tok->str() != "{" && tok->str() != ";")
|
while (tok && tok->str() != "{" && tok->str() != ";")
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
tok = tok ? tok->link() : 0;
|
tok = tok ? tok->link() : 0;
|
||||||
|
if (!tok)
|
||||||
|
{
|
||||||
|
ExecutionPath::bailOut(checks);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok, "= {"))
|
if (Token::Match(tok, "= {"))
|
||||||
|
|
|
@ -8415,8 +8415,10 @@ void Tokenizer::simplifyStructDecl()
|
||||||
Token *type = tok->next();
|
Token *type = tok->next();
|
||||||
Token *next = tok->tokAt(2);
|
Token *next = tok->tokAt(2);
|
||||||
|
|
||||||
while (next->str() != "{")
|
while (next && next->str() != "{")
|
||||||
next = next->next();
|
next = next->next();
|
||||||
|
if (!next)
|
||||||
|
continue;
|
||||||
|
|
||||||
tok = next->link();
|
tok = next->link();
|
||||||
restart = next;
|
restart = next;
|
||||||
|
|
|
@ -195,6 +195,7 @@ private:
|
||||||
TEST_CASE(executionPaths1);
|
TEST_CASE(executionPaths1);
|
||||||
TEST_CASE(executionPaths2);
|
TEST_CASE(executionPaths2);
|
||||||
TEST_CASE(executionPaths3); // no FP for function parameter
|
TEST_CASE(executionPaths3); // no FP for function parameter
|
||||||
|
TEST_CASE(executionPaths4); // Ticket #2386 - Segmentation fault in the ExecutionPath handling
|
||||||
|
|
||||||
TEST_CASE(cmdLineArgs1);
|
TEST_CASE(cmdLineArgs1);
|
||||||
|
|
||||||
|
@ -2685,6 +2686,17 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void executionPaths4()
|
||||||
|
{
|
||||||
|
// Ticket #2386 - Segmentation fault upon strange syntax
|
||||||
|
epcheck("void f() {\n"
|
||||||
|
" switch ( x ) {\n"
|
||||||
|
" case struct Tree : break;\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void cmdLineArgs1()
|
void cmdLineArgs1()
|
||||||
{
|
{
|
||||||
check("int main(int argc, char* argv[])\n"
|
check("int main(int argc, char* argv[])\n"
|
||||||
|
|
Loading…
Reference in New Issue