Evaluation order: ignore usage in sizeof

This commit is contained in:
Daniel Marjamäki 2015-12-27 14:08:16 +01:00
parent e9635fd393
commit 908bc664a4
2 changed files with 8 additions and 0 deletions

View File

@ -2537,6 +2537,8 @@ void CheckOther::checkEvaluationOrder()
continue;
if (tok3->str() == "&" && !tok3->astOperand2())
continue; // don't handle adress-of for now
if (tok3->str() == "(" && Token::simpleMatch(tok3->previous(), "sizeof"))
continue; // don't care about sizeof usage
tokens.push(tok3->astOperand1());
tokens.push(tok3->astOperand2());
if (isSameExpression(_tokenizer->isCPP(), false, tok->astOperand1(), tok3, _settings->library.functionpure)) {

View File

@ -6143,6 +6143,12 @@ private:
"}", "test.c");
TODO_ASSERT_EQUALS("error", "", errout.str());
}
// sizeof
check("void f(char *buf) {\n"
" dostuff(buf++, sizeof(*buf));"
"}", "test.c");
ASSERT_EQUALS("", errout.str());
}
};