cppcheck
cppcheck copied to clipboard
Fix #11786 deferencing fail to warn after the loop
Try to handle loops, it works for https://trac.cppcheck.net/ticket/11786. However, I am uncertain if this change may introduce additional errors or unintended consequences.
else if (Token::Match(tok, "for|while|do")) {
continue;
}
// unknown control.. (TODO: handle loops)
else if ((Token::Match(tok, "%type% (") && Token::simpleMatch(tok->linkAt(1), ") {")) || Token::simpleMatch(tok, "do {")) {
varInfo.clear();
return false;
}
Thanks for your contribution. Please add a test for your fix. I expect that some logic must be added to pass the existing tests, see also the history of ticket #11786.
Feel free to reopen after CI issues are fixed.