cppcheck icon indicating copy to clipboard operation
cppcheck copied to clipboard

Fix #11786 deferencing fail to warn after the loop

Open mondaylord opened this issue 1 year ago • 1 comments

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;
}

mondaylord avatar May 10 '24 09:05 mondaylord

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.

chrchr-github avatar May 10 '24 11:05 chrchr-github

Feel free to reopen after CI issues are fixed.

chrchr-github avatar Jun 08 '24 21:06 chrchr-github