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 a2c99bc commit 9cd89c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2674,7 +2674,7 @@ 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 = tok2->variable())
if (const Variable* var2 = scope->getVariable(tok2->str()))
vars.back().initArgs.emplace_back(var2);
}
tok = end;
Expand Down
6 changes: 6 additions & 0 deletions test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7590,6 +7590,12 @@ class TestClass : public TestFixture {
"};");
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:5]: (style, inconclusive) Member variable 'C::b' uses an uninitialized argument due to the order of declarations.\n",
errout.str());

checkInitializerListOrder("struct S {\n"
" S(const std::string& f, std::string i, int b, int c) : a(0), b(b), c(c) {}\n"
" int a, b, c;\n"
"};");
ASSERT_EQUALS("", errout.str());
}

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

0 comments on commit 9cd89c7

Please sign in to comment.