From 4ad90bf6f1cb0149c79324dff027cf8558c041c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 24 May 2021 17:02:19 +0200 Subject: [PATCH] Uninitialized variables; Fixed FP in inner for loop --- lib/checkuninitvar.cpp | 4 ++-- test/testuninitvar.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 7a3b78190..01617d263 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -902,8 +902,8 @@ const Token* CheckUninitVar::checkLoopBodyRecursive(const Token *start, const Va continue; const Token *bodyStart = top->link()->next(); const Token *errorToken1 = checkLoopBodyRecursive(bodyStart, var, alloc, membervar, bailout); - if (errorToken1) - return errorToken1; + if (!errorToken) + errorToken = errorToken1; if (bailout) return nullptr; } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index b361cbec8..dcb729f82 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -1259,6 +1259,16 @@ private: "}"); ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: x\n", errout.str()); + checkUninitVar("void foo(int n) {\n" + " int one[10];\n" + " for (int rank = 0; rank < n; ++rank) {\n" + " for (int i=0;i