support for record extensions when using -O gen-standalone-C++

This commit is contained in:
Vern Paxson 2025-01-09 16:11:37 -08:00 committed by Arne Welzel
parent 300b3788e2
commit 960931ba5c
7 changed files with 64 additions and 9 deletions

View file

@ -383,11 +383,18 @@ TypePtr CPP_TypeInits::BuildRecordType(InitsManager* im, ValElemVec& init_vals,
auto r = cast_intrusive<RecordType>(inits_vec[offset]);
ASSERT(r);
if ( r->NumFields() == 0 ) {
auto addl_fields = init_vals[2];
if ( addl_fields > 0 || r->NumFields() == 0 ) {
// We shouldn't be adding fields if the record doesn't have any
// existing fields - that would reflect an initialization botch.
if ( addl_fields > 0 && r->NumFields() == 0 )
reporter->InternalError("record unexpectedly empty when adding fields");
type_decl_list tl;
auto n = init_vals.size();
auto i = 2U;
auto i = 3U + addl_fields * 3;
while ( i < n ) {
auto s = im->Strings(init_vals[i++]);