Skip to content

Commit

Permalink
Fix #12822 (FP knownPointerToBool with array parameter (regression)) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar authored Aug 17, 2024
1 parent 97277b0 commit 9aa63a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,8 @@ std::vector<ValueType> 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;
Expand Down
7 changes: 7 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 9aa63a7

Please sign in to comment.