From 624619372e9befafb116d67061cfb790a867e779 Mon Sep 17 00:00:00 2001 From: Oleksandr Labetskyi Date: Thu, 14 Dec 2023 14:34:00 +0200 Subject: [PATCH 1/2] #12260: revert some old changes --- lib/checkunusedvar.cpp | 5 +++-- test/testunusedvar.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index 161a309c61f..de23f0fb0a7 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -1630,8 +1630,9 @@ bool CheckUnusedVar::isRecordTypeWithoutSideEffects(const Type* type) bool CheckUnusedVar::isVariableWithoutSideEffects(const Variable& var) { - if (var.isPointer()) - return true; + // TODO why pointer is an automatic true + //if (var.isPointer()) + // return true; const Type* variableType = var.type(); if (variableType) { diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 82fc3a1141a..1c4cb62de1c 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -459,6 +459,20 @@ class TestUnusedVar : public TestFixture { "}"); TODO_ASSERT_EQUALS("error", "", errout.str()); + // constructor with hidden definition + functionVariableUsage( + "class B {\n" + "public:\n" + " B();\n" + "};\n" + "class A {\n" + " B* b = new B;\n" + "};\n" + "int main() {\n" + " A a;\n" + "}"); + TODO_ASSERT_EQUALS("error", "", errout.str()); + // side-effect variable functionVariableUsage( "class F {\n" From f90775c9ffe3b1aa7287af6e6141cd9a58d5140a Mon Sep 17 00:00:00 2001 From: Oleksandr Labetskyi Date: Thu, 14 Dec 2023 15:31:29 +0200 Subject: [PATCH 2/2] #12260: clean up --- lib/checkunusedvar.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index de23f0fb0a7..101c886fe91 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -1630,10 +1630,6 @@ bool CheckUnusedVar::isRecordTypeWithoutSideEffects(const Type* type) bool CheckUnusedVar::isVariableWithoutSideEffects(const Variable& var) { - // TODO why pointer is an automatic true - //if (var.isPointer()) - // return true; - const Type* variableType = var.type(); if (variableType) { if (!isRecordTypeWithoutSideEffects(variableType))