From 9d88cc63e86bd8a2d4b6a1ec21e33c0529d2c678 Mon Sep 17 00:00:00 2001 From: Alexander Mai Date: Tue, 12 Mar 2013 06:49:13 +0100 Subject: [PATCH] Fixed #4642 (False positive: Returning an address value in a function with integer return type is not portable. (not returning address)) --- lib/check64bit.cpp | 4 +++- test/test64bit.cpp | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/check64bit.cpp b/lib/check64bit.cpp index 65018177b..78675440d 100644 --- a/lib/check64bit.cpp +++ b/lib/check64bit.cpp @@ -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; } diff --git a/test/test64bit.cpp b/test/test64bit.cpp index 22eb6ba1f..d408a83e7 100644 --- a/test/test64bit.cpp +++ b/test/test64bit.cpp @@ -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()); } };