From b624c9c2a01f565c645f7092aa5b1d4938a26e33 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 8 Apr 2024 19:39:18 +0200 Subject: [PATCH] Update valueflow.cpp --- lib/valueflow.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 10933187664..ea6370d91d7 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1120,8 +1120,12 @@ static size_t accumulateStructMembers(const Scope* scope, F f) const MathLib::bigint dim = std::accumulate(var.dimensions().cbegin(), var.dimensions().cend(), 1LL, [](MathLib::bigint i1, const Dimension& dim) { return i1 * dim.num; }); - const auto ret = anonScopes.insert(var.nameToken()->scope()); - if (ret.second) + if (var.nameToken()->scope() != scope && var.nameToken()->scope()->definedType) { // anonymous union + const auto ret = anonScopes.insert(var.nameToken()->scope()); + if (ret.second) + total = f(total, *vt, dim); + } + else total = f(total, *vt, dim); } if (total == 0)