Uninitialized variables: bailout when ({..}) are used to avoid fp. it can be handled better.
This commit is contained in:
parent
1f698ca493
commit
f2e5fbd30d
|
@ -1424,6 +1424,11 @@ bool CheckUninitVar::checkScopeForVariable(const Scope* scope, const Token *tok,
|
|||
return true;
|
||||
}
|
||||
|
||||
// bailout if there is ({
|
||||
if (Token::simpleMatch(tok, "( {")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// bailout if there is assembler code
|
||||
if (Token::simpleMatch(tok, "asm (")) {
|
||||
return true;
|
||||
|
|
|
@ -145,6 +145,12 @@ void ExecutionPath::checkScope(const Token *tok, std::list<ExecutionPath *> &che
|
|||
return;
|
||||
}
|
||||
|
||||
// ({ is not handled well
|
||||
if (Token::simpleMatch(tok, "( {")) {
|
||||
ExecutionPath::bailOut(checks);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Token::simpleMatch(tok, "union {")) {
|
||||
tok = tok->next()->link();
|
||||
continue;
|
||||
|
|
|
@ -905,6 +905,20 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// ({ .. })
|
||||
{
|
||||
const char code[] = "void f() {\n"
|
||||
" int x;\n"
|
||||
" if (abc) { x = 123; }\n"
|
||||
" else { a = ({b=c;}); x = 456; }\n"
|
||||
" ++x;\n"
|
||||
"}";
|
||||
checkUninitVar(code);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
checkUninitVar2(code);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// Ticket #3098 - False negative uninitialized variable
|
||||
checkUninitVar("void f()\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue