diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index f3e2c98d5..cb4e0c2c2 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -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? diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index d44e0deaa..196026771 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -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() {