Fixed #12260 (false positive: unusedVariable with side effects in member initialization) (#5762)

revert old changes
This commit is contained in:
olabetskyi 2023-12-14 16:16:30 +02:00 committed by GitHub
parent d7835f199f
commit 61127950b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -1630,9 +1630,6 @@ bool CheckUnusedVar::isRecordTypeWithoutSideEffects(const Type* type)
bool CheckUnusedVar::isVariableWithoutSideEffects(const Variable& var)
{
if (var.isPointer())
return true;
const Type* variableType = var.type();
if (variableType) {
if (!isRecordTypeWithoutSideEffects(variableType))

View File

@ -459,6 +459,20 @@ private:
"}");
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"