Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7092,7 +7092,14 @@ ValueType::MatchResult ValueType::matchParameter(const ValueType *call, const Va

ValueType::MatchResult ValueType::matchParameter(const ValueType *call, const Variable *callVar, const Variable *funcVar)
{
ValueType::MatchResult res = ValueType::matchParameter(call, funcVar->valueType());
ValueType vt;
const ValueType* pvt = funcVar->valueType();
if (pvt && funcVar->isArray()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work when array is passed by reference(ie void f(const T (&array)[N]))? Maybe we should call matchParameter first and then if it doesn't match adjust the valuetype if funcVar->isArray()?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works in the sense that there is no FP if I change the test case accordingly. But ValueType can't store the dimension N anyway.

vt = *pvt;
++vt.pointer;
pvt = &vt;
}
ValueType::MatchResult res = ValueType::matchParameter(call, pvt);
if (callVar && ((res == ValueType::MatchResult::SAME && call->container) || res == ValueType::MatchResult::UNKNOWN)) {
const std::string type1 = getTypeString(callVar->typeStartToken());
const std::string type2 = getTypeString(funcVar->typeStartToken());
Expand Down
12 changes: 12 additions & 0 deletions test/testautovariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3305,6 +3305,18 @@ class TestAutoVariables : public TestFixture {
" {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());

check("struct String {\n" // #10469
" void Append(uint8_t Val);\n"
" String& operator+=(const char s[]);\n"
" String& operator+=(const std::string& Str) {\n"
" return operator+=(Str.c_str());\n"
" }\n"
" void operator+=(uint8_t Val) {\n"
" Append(Val);\n"
" }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}

void danglingLifetimeBorrowedMembers()
Expand Down