Skip to content

Commit aad723b

Browse files
authored
Fix false positive AssignmentIntegerToAddress (danmar#2971)
1 parent b091eac commit aad723b

File tree

3 files changed

+655
-887
lines changed

3 files changed

+655
-887
lines changed

lib/symboldatabase.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5912,6 +5912,9 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V
59125912
}
59135913
type = type->next();
59145914
}
5915+
if (type->str() == "(" && type->previous()->function())
5916+
// we are past the end of the type
5917+
type = type->previous();
59155918
continue;
59165919
} else if (settings->library.isSmartPointer(type)) {
59175920
const Token* argTok = Token::findsimplematch(type, "<");

test/test64bit.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class Test64BitPortability : public TestFixture {
4848

4949
// Tokenize..
5050
Tokenizer tokenizer(&settings, this);
51+
LOAD_LIB_2(settings.library, "std.cfg");
5152
std::istringstream istr(code);
5253
tokenizer.tokenize(istr, "test.cpp");
5354

@@ -104,6 +105,32 @@ class Test64BitPortability : public TestFixture {
104105
" return a;\n"
105106
"}");
106107
ASSERT_EQUALS("", errout.str());
108+
109+
check("std::array<int,2> f();\n"
110+
"void g() {\n"
111+
" std::array<int, 2> a = f();\n"
112+
"}");
113+
ASSERT_EQUALS("", errout.str());
114+
115+
check("std::array<int,2> f(int x);\n"
116+
"void g(int i) {\n"
117+
" std::array<int, 2> a = f(i);\n"
118+
"}");
119+
ASSERT_EQUALS("", errout.str());
120+
121+
check("typedef std::array<int, 2> Array;\n"
122+
"Array f(int x);\n"
123+
"void g(int i) {\n"
124+
" Array a = f(i);\n"
125+
"}");
126+
ASSERT_EQUALS("", errout.str());
127+
128+
check("typedef std::array<int, 2> Array;\n"
129+
"Array f();\n"
130+
"void g(int i) {\n"
131+
" Array a = f();\n"
132+
"}");
133+
ASSERT_EQUALS("", errout.str());
107134
}
108135

109136
void structmember() {

0 commit comments

Comments
 (0)