Skip to content

Commit b4a1e77

Browse files
authored
fix #13851: FN sizeofFunctionCall after preceding sizeof (danmar#7704)
1 parent 405edfd commit b4a1e77

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/checksizeof.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ void CheckSizeof::sizeofFunction()
379379
if (const Token *argument = tok->next()->astOperand2()) {
380380
const Token *checkToken = argument->previous();
381381
if (checkToken->tokType() == Token::eName)
382-
break;
382+
continue;
383383
const Function * fun = checkToken->function();
384384
// Don't report error if the function is overloaded
385385
if (fun && fun->nestedIn->functionMap.count(checkToken->str()) == 1) {

test/testsizeof.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ class TestSizeof : public TestFixture {
206206
" };\n"
207207
"};");
208208
ASSERT_EQUALS("", errout_str());
209+
210+
check("int g();\n"
211+
"size_t f1() { return sizeof(x[0]); }\n"
212+
"size_t f2() { return sizeof(g()); }\n");
213+
ASSERT_EQUALS("[test.cpp:3:22]: (warning) Found function call inside sizeof(). [sizeofFunctionCall]\n", errout_str());
209214
}
210215

211216
void sizeofForArrayParameter() {

0 commit comments

Comments
 (0)