Skip to content

Commit 15045b2

Browse files
Update symboldatabase.cpp [skip ci]
1 parent c594e9b commit 15045b2

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎lib/symboldatabase.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8702,10 +8702,10 @@ static Result accumulateStructMembers(const Scope* scope, F f, ValueType::Accura
87028702
});
87038703
if (vt->container && vt->container->startPattern == "std :: array <") {
87048704
const ValueType vtElement = ValueType::parseDecl(vt->containerTypeToken, settings);
8705-
total = f(total, vtElement, dim, bits);
8705+
total = f(total, vtElement, dim, bits, /*isAnonUnion*/ false);
87068706
}
87078707
else
8708-
total = f(total, *vt, dim, bits);
8708+
total = f(total, *vt, dim, bits, var.nameToken()->scope() != scope);
87098709
}
87108710
if (accuracy == ValueType::Accuracy::ExactOrZero && total == 0 && bits == -1)
87118711
return {0, false};
@@ -8739,7 +8739,7 @@ static size_t getAlignOf(const ValueType& vt, const Settings& settings, ValueTyp
87398739
return align == 0 ? 0 : bitCeil(align);
87408740
}
87418741
if (vt.type == ValueType::Type::RECORD && vt.typeScope) {
8742-
auto accHelper = [&](size_t max, const ValueType& vt2, size_t /*dim*/, MathLib::bigint /*bits*/) {
8742+
auto accHelper = [&](size_t max, const ValueType& vt2, size_t /*dim*/, MathLib::bigint /*bits*/, bool /*isAnonUnion*/) {
87438743
size_t a = getAlignOf(vt2, settings, accuracy, ValueType::SizeOf::Pointer, ++maxRecursion);
87448744
return std::max(max, a);
87458745
};
@@ -8791,7 +8791,7 @@ size_t ValueType::getSizeOf( const Settings& settings, Accuracy accuracy, SizeOf
87918791
if (type == ValueType::Type::RECORD && typeScope) {
87928792
size_t currentBitCount = 0;
87938793
size_t currentBitfieldAlloc = 0;
8794-
auto accHelper = [&](size_t total, const ValueType& vt2, size_t dim, MathLib::bigint nBits) -> size_t {
8794+
auto accHelper = [&](size_t total, const ValueType& vt2, size_t dim, MathLib::bigint nBits, bool isAnonUnion) -> size_t {
87958795
const size_t charBit = settings.platform.char_bit;
87968796
size_t n = vt2.getSizeOf(settings, accuracy, SizeOf::Pointer, ++maxRecursion);
87978797
size_t a = getAlignOf(vt2, settings, accuracy, SizeOf::Pointer);
@@ -8834,7 +8834,7 @@ size_t ValueType::getSizeOf( const Settings& settings, Accuracy accuracy, SizeOf
88348834
currentBitfieldAlloc = 0;
88358835
currentBitCount = 0;
88368836
}
8837-
const bool isUnion = typeScope->type == ScopeType::eUnion || (vt2.typeScope && vt2.typeScope->nestedIn->type == ScopeType::eUnion && vt2.typeScope->nestedIn->className.empty());
8837+
const bool isUnion = isAnonUnion || typeScope->type == ScopeType::eUnion;
88388838
return isUnion ? std::max(total, n) : total + padding + n;
88398839
};
88408840
Result result = accumulateStructMembers(typeScope, accHelper, accuracy, settings);

0 commit comments

Comments
 (0)