@@ -1116,11 +1116,10 @@ static size_t accumulateStructMembers(const Scope* scope, F f)
1116
1116
if (const ValueType* vt = var.valueType ()) {
1117
1117
if (vt->type == ValueType::Type::RECORD && vt->typeScope == scope)
1118
1118
return 0 ;
1119
- total = f (total, *vt);
1120
1119
const MathLib::bigint dim = std::accumulate (var.dimensions ().cbegin (), var.dimensions ().cend (), 1LL , [](MathLib::bigint i1, const Dimension& dim) {
1121
1120
return i1 * dim.num ;
1122
1121
});
1123
- total *= dim;
1122
+ total = f (total, *vt, dim) ;
1124
1123
}
1125
1124
if (total == 0 )
1126
1125
return 0 ;
@@ -1149,7 +1148,7 @@ static size_t getAlignOf(const ValueType& vt, const Settings& settings)
1149
1148
return align == 0 ? 0 : bitCeil (align);
1150
1149
}
1151
1150
if (vt.type == ValueType::Type::RECORD && vt.typeScope ) {
1152
- return accumulateStructMembers (vt.typeScope , [&](size_t max, const ValueType& vt2) {
1151
+ return accumulateStructMembers (vt.typeScope , [&](size_t max, const ValueType& vt2, size_t /* dim */ ) {
1153
1152
size_t a = getAlignOf (vt2, settings);
1154
1153
return std::max (max, a);
1155
1154
});
@@ -1187,11 +1186,12 @@ size_t ValueFlow::getSizeOf(const ValueType &vt, const Settings &settings)
1187
1186
if (vt.type == ValueType::Type::LONGDOUBLE)
1188
1187
return settings.platform .sizeof_long_double ;
1189
1188
if (vt.type == ValueType::Type::RECORD && vt.typeScope ) {
1190
- size_t total = accumulateStructMembers (vt.typeScope , [&](size_t total, const ValueType& vt2) -> size_t {
1189
+ size_t total = accumulateStructMembers (vt.typeScope , [&](size_t total, const ValueType& vt2, size_t dim ) -> size_t {
1191
1190
size_t n = ValueFlow::getSizeOf (vt2, settings);
1192
1191
size_t a = getAlignOf (vt2, settings);
1193
1192
if (n == 0 || a == 0 )
1194
1193
return 0 ;
1194
+ n *= dim;
1195
1195
size_t padding = (a - (total % a)) % a;
1196
1196
return total + padding + n;
1197
1197
});
0 commit comments