Fix knownArgument false positive when sizeof is used

This commit is contained in:
Daniel Marjamäki 2020-09-24 19:43:39 +02:00
parent 514b7f4da4
commit c08e1a9a94
2 changed files with 9 additions and 0 deletions

View File

@ -3126,6 +3126,8 @@ void CheckOther::checkKnownArgument()
}
return ChildrenToVisit::none;
}
if (Token::simpleMatch(child->previous(), "sizeof ("))
return ChildrenToVisit::none;
return ChildrenToVisit::op1_and_op2;
});
if (varexpr.empty())

View File

@ -8830,6 +8830,13 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
check("char *yytext;\n"
"void re_init_scanner() {\n"
" int size = 256;\n"
" yytext = xmalloc(size * sizeof *yytext);\n"
"}");
ASSERT_EQUALS("", errout.str());
// #8986
check("void f(int);\n"
"void g() {\n"