Skip to content

Commit 6112795

Browse files
authored
Fixed #12260 (false positive: unusedVariable with side effects in member initialization) (#5762)
revert old changes
1 parent d7835f1 commit 6112795

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

lib/checkunusedvar.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,9 +1630,6 @@ bool CheckUnusedVar::isRecordTypeWithoutSideEffects(const Type* type)
16301630

16311631
bool CheckUnusedVar::isVariableWithoutSideEffects(const Variable& var)
16321632
{
1633-
if (var.isPointer())
1634-
return true;
1635-
16361633
const Type* variableType = var.type();
16371634
if (variableType) {
16381635
if (!isRecordTypeWithoutSideEffects(variableType))

test/testunusedvar.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,20 @@ class TestUnusedVar : public TestFixture {
459459
"}");
460460
TODO_ASSERT_EQUALS("error", "", errout.str());
461461

462+
// constructor with hidden definition
463+
functionVariableUsage(
464+
"class B {\n"
465+
"public:\n"
466+
" B();\n"
467+
"};\n"
468+
"class A {\n"
469+
" B* b = new B;\n"
470+
"};\n"
471+
"int main() {\n"
472+
" A a;\n"
473+
"}");
474+
TODO_ASSERT_EQUALS("error", "", errout.str());
475+
462476
// side-effect variable
463477
functionVariableUsage(
464478
"class F {\n"

0 commit comments

Comments
 (0)