Skip to content

Commit

Permalink
Fix FP
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jan 6, 2024
1 parent 9cd89c7 commit e62c282
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2674,8 +2674,11 @@ void CheckClass::initializerListOrder()

const Token* const end = tok->next()->link();
for (const Token* tok2 = tok->next(); tok2 != end; tok2 = tok2->next()) {
if (const Variable* var2 = scope->getVariable(tok2->str()))
if (const Variable* var2 = scope->getVariable(tok2->str())) {
if (var->isPointer() && var2->isArray())
continue;
vars.back().initArgs.emplace_back(var2);
}
}
tok = end;
}
Expand Down
7 changes: 7 additions & 0 deletions test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7596,6 +7596,13 @@ class TestClass : public TestFixture {
" int a, b, c;\n"
"};");
ASSERT_EQUALS("", errout.str());

checkInitializerListOrder("struct S {\n"
" S() : p(a) {}\n"
" int* p;\n"
" int a[1];\n"
"};");
ASSERT_EQUALS("", errout.str());
}

#define checkInitializationListUsage(code) checkInitializationListUsage_(code, __FILE__, __LINE__)
Expand Down

0 comments on commit e62c282

Please sign in to comment.