diff --git a/lib/fwdanalysis.cpp b/lib/fwdanalysis.cpp index 97337c3ab40..256f2e32a1b 100644 --- a/lib/fwdanalysis.cpp +++ b/lib/fwdanalysis.cpp @@ -497,6 +497,8 @@ bool FwdAnalysis::possiblyAliased(const Token *expr, const Token *startToken) co return true; if (Token::simpleMatch(expr, ". *")) return true; + if (expr->str() == "(" && Token::simpleMatch(expr->astOperand1(), ".")) + return true; const bool macro = false; const bool pure = false; diff --git a/test/cfg/qt.cpp b/test/cfg/qt.cpp index d89fc4a8443..f77ea2e88ba 100644 --- a/test/cfg/qt.cpp +++ b/test/cfg/qt.cpp @@ -775,3 +775,13 @@ void unusedVariable_qtContainers() // #10689 QLatin1String ql1s; } +void unreadVariable_QMapIterator(QMap& m) +{ + auto it = m.find("abc"); // #12662 + if (it != m.end()) { + // cppcheck-suppress checkLibraryFunction // TODO + delete it.value(); + // cppcheck-suppress checkLibraryFunction + it.value() = new QObject(); + } +}