Skip to content
Closed
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
2 changes: 1 addition & 1 deletion cfg/std.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9050,7 +9050,7 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
<checkFiniteLifetime>std::scoped_lock</checkFiniteLifetime>
<checkFiniteLifetime>std::unique_lock</checkFiniteLifetime>
<checkFiniteLifetime>std::shared_lock</checkFiniteLifetime>
<check>std::pair</check>
<checkFiniteLifetime>std::pair</checkFiniteLifetime>
<check>std::complex</check>
<check>std::exception</check>
<check>std::logic_error</check>
Expand Down
5 changes: 2 additions & 3 deletions lib/checkunusedvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,10 +724,9 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
type = Variables::pointer;
else if (mTokenizer->isC() ||
i->typeEndToken()->isStandardType() ||
i->isStlType() ||
(i->valueType() && i->valueType()->container) ||
mTokenizer->getSymbolDatabase()->isRecordTypeWithoutSideEffects(i->type()) ||
mSettings->library.detectContainer(i->typeStartToken()) ||
mSettings->library.getTypeCheck("unusedvar", i->typeStartToken()->str()) == Library::TypeCheck::check)
mSettings->library.getTypeCheck("unusedvar", i->getTypeName()) == Library::TypeCheck::check)
type = Variables::standard;

if (type == Variables::none || isPartOfClassStructUnion(i->typeStartToken()))
Expand Down
5 changes: 5 additions & 0 deletions test/testunusedvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6597,6 +6597,11 @@ class TestUnusedVar : public TestFixture {
" }\n"
"}\n");
ASSERT_EQUALS("[test.cpp:2:23]: (style) Variable 's' is assigned a value that is never used. [unreadVariable]\n", errout_str());

functionVariableUsage("void f() {\n" // #14201
" std::pair<T, U> p;\n"
"}\n");
ASSERT_EQUALS("", errout_str());
}

void localVarClass() {
Expand Down
Loading