Fix FP divideSizeof (#4003)
This commit is contained in:
parent
07fb6c1853
commit
bf6bcafc56
|
@ -387,7 +387,9 @@ void CheckSizeof::suspiciousSizeofCalculation()
|
|||
divideSizeofError(tok);
|
||||
else if (varTok && varTok->str() == "*") {
|
||||
const Token* arrTok = lPar->astParent()->astOperand1();
|
||||
arrTok = arrTok ? arrTok->next() : nullptr;
|
||||
arrTok = arrTok ? arrTok->astOperand2() : nullptr;
|
||||
while (Token::simpleMatch(arrTok, "."))
|
||||
arrTok = arrTok->astOperand2();
|
||||
var = arrTok ? arrTok->variable() : nullptr;
|
||||
if (var && var->isPointer() && !var->isArray())
|
||||
divideSizeofError(tok);
|
||||
|
|
|
@ -456,6 +456,16 @@ private:
|
|||
" for (size_t i = 0; i < sizeof(t->s) / sizeof(t->s[0]); i++) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct S {\n"
|
||||
" struct T {\n"
|
||||
" char* c[3];\n"
|
||||
" } t[1];\n"
|
||||
"};\n"
|
||||
"void f(S* s) {\n"
|
||||
" for (int i = 0; i != sizeof(s->t[0].c) / sizeof(char*); i++) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void checkPointerSizeof() {
|
||||
|
|
Loading…
Reference in New Issue