Fix false positive AssignmentIntegerToAddress (#2971)

This commit is contained in:
Ken-Patrick Lehrmann 2020-12-24 19:57:02 +01:00 committed by GitHub
parent b091eaccbe
commit aad723bf3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 651 additions and 883 deletions

View File

@ -5912,6 +5912,9 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V
}
type = type->next();
}
if (type->str() == "(" && type->previous()->function())
// we are past the end of the type
type = type->previous();
continue;
} else if (settings->library.isSmartPointer(type)) {
const Token* argTok = Token::findsimplematch(type, "<");

View File

@ -48,6 +48,7 @@ private:
// Tokenize..
Tokenizer tokenizer(&settings, this);
LOAD_LIB_2(settings.library, "std.cfg");
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
@ -104,6 +105,32 @@ private:
" return a;\n"
"}");
ASSERT_EQUALS("", errout.str());
check("std::array<int,2> f();\n"
"void g() {\n"
" std::array<int, 2> a = f();\n"
"}");
ASSERT_EQUALS("", errout.str());
check("std::array<int,2> f(int x);\n"
"void g(int i) {\n"
" std::array<int, 2> a = f(i);\n"
"}");
ASSERT_EQUALS("", errout.str());
check("typedef std::array<int, 2> Array;\n"
"Array f(int x);\n"
"void g(int i) {\n"
" Array a = f(i);\n"
"}");
ASSERT_EQUALS("", errout.str());
check("typedef std::array<int, 2> Array;\n"
"Array f();\n"
"void g(int i) {\n"
" Array a = f();\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void structmember() {

File diff suppressed because it is too large Load Diff