Uninitialized variables: Fix FP for unknown macro like 'list_for_each'

This commit is contained in:
Daniel Marjamäki 2018-02-04 22:30:08 +01:00
parent f009cfc845
commit dbc6771a0b
2 changed files with 8 additions and 1 deletions

View File

@ -1059,7 +1059,7 @@ int CheckUninitVar::isFunctionParUsage(const Token *vartok, bool pointer, Alloc
if (!start)
return -1;
if (Token::simpleMatch(start->link(), ") {"))
if (Token::simpleMatch(start->link(), ") {") && Token::Match(start->previous(), "if|for|while|switch"))
return (!pointer || alloc == NO_ALLOC);
// is this a function call?

View File

@ -2874,6 +2874,13 @@ private:
" buf[1] = buf[0];\n"
"}");
ASSERT_EQUALS("", errout.str());
// unknown macro
checkUninitVar("void f() {\n"
" struct listnode *item;\n"
" list_for_each(item, &key_list) {}\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void uninitvar2_value() {