Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #4659 (portability: address value / integer false positive)

  • Loading branch information...
commit a4a2f78a7a4570e53e16d89b52d6d87ac2c2dee1 1 parent 1e66e0b
@danmar authored
Showing with 6 additions and 1 deletion.
  1. +1 −1  lib/check64bit.cpp
  2. +5 −0 test/test64bit.cpp
View
2  lib/check64bit.cpp
@@ -68,7 +68,7 @@ void Check64BitPortability::pointerassignment()
if (Token::Match(tok, "return %var%|%num% [;+]") && !Token::simpleMatch(tok, "return 0 ;")) {
enum { NO, INT, PTR, PTRDIFF } type = NO;
for (const Token *tok2 = tok->next(); tok2; tok2 = tok2->next()) {
- if ((type == NO || type == INT) && isaddr(tok2->variable()))
+ if ((type == NO || type == INT) && Token::Match(tok2, "%var% [+;]") && isaddr(tok2->variable()))
type = PTR;
else if (type == NO && (tok2->isNumber() || isint(tok2->variable())))
type = INT;
View
5 test/test64bit.cpp
@@ -95,6 +95,11 @@ class Test64BitPortability : public TestFixture {
" *p = 0;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning an integer to a pointer is not portable.\n", errout.str());
+
+ check("int f(const char *p) {\n" // #4659
+ " return 6 + p[2] * 256;\n"
+ "}");
+ ASSERT_EQUALS("", errout.str());
}
void structmember() {
Please sign in to comment.
Something went wrong with that request. Please try again.