Fixed #4642 (False positive: Returning an address value in a function with integer return type is not portable. (not returning address))

This commit is contained in:
Alexander Mai 2013-03-12 06:49:13 +01:00 committed by Daniel Marjamäki
parent 3d1cdd0eec
commit 9d88cc63e8
2 changed files with 11 additions and 1 deletions

View File

@ -77,7 +77,9 @@ void Check64BitPortability::pointerassignment()
else if (Token::Match(tok2, "%type% (")) {
type = NO;
break;
} else if (tok2->str() == ";")
} else if (type == PTR && Token::simpleMatch(tok2, "."))
type = NO; // Reset after pointer reference, see #4642
else if (tok2->str() == ";")
break;
}

View File

@ -180,6 +180,14 @@ private:
" return a + 1 - b;\n"
"}");
ASSERT_EQUALS("", errout.str());
check("struct s {\n" // 4642
" int i;\n"
"};\n"
"int func(struct s *p) {\n"
" return 1 + p->i;\n"
"}");
ASSERT_EQUALS("", errout.str());
}
};