diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index 94c0e43065f..655273a9048 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -468,6 +468,10 @@ bool CheckLeakAutoVar::checkScope(const Token * const startToken, const Token * closingParenthesis = tok->linkAt(1); for (const Token *innerTok = tok->tokAt(2); innerTok && innerTok != closingParenthesis; innerTok = innerTok->next()) { + if (isUnevaluated(innerTok)) { + innerTok = innerTok->linkAt(1); + continue; + } // TODO: replace with checkTokenInsideExpression() const Token* const openingPar = isFunctionCall(innerTok); if (!openingPar) diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 10911f8f7cf..239d5dd75cc 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -1701,6 +1701,16 @@ class TestLeakAutoVar : public TestFixture { " y = fclose(f);\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("void f() {\n" + " FILE *fp = fopen(\"abc\", \"r\");\n" + " if (({\n" + " __typeof__(fclose(fp)) r;\n" + " r = (fclose(fp));\n" + " r;\n" + " })) {}\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void exit1() {