From 9aa63a7fafc9d72e751969d4cce441e372f418e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 17 Aug 2024 20:23:13 +0200 Subject: [PATCH] Fix #12822 (FP knownPointerToBool with array parameter (regression)) (#6707) --- lib/astutils.cpp | 2 ++ test/testother.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 5aaf2722898..b0010471316 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -738,6 +738,8 @@ std::vector getParentValueTypes(const Token* tok, const Settings& set continue; nameTok = var->nameToken(); result.push_back(*var->valueType()); + if (var->isArray()) + result.back().pointer += var->dimensions().size(); } if (result.size() == 1 && nameTok && parent) { *parent = nameTok; diff --git a/test/testother.cpp b/test/testother.cpp index 57d73c4df2b..f43cd28a6a8 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -12404,6 +12404,13 @@ class TestOther : public TestFixture { " if (!ptr || !ptr()) {}\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("void g(bool b[2]);\n" // #12822 + "void f() {\n" + " bool b[2] = {};\n" + " g(b);\n" + "}"); + ASSERT_EQUALS("", errout_str()); } void iterateByValue() {