Record the type being initialized in auto initializer records.

This commit is contained in:
Stephen Heumann 2022-11-26 19:58:01 -06:00
parent cd9931a60c
commit d1edc8821d
2 changed files with 11 additions and 1 deletions

View File

@ -327,7 +327,10 @@ type
bitsize: integer; {width in bits; 0 for byte sizes}
isStructOrUnion: boolean; {is this a struct or union initializer?}
case isConstant: boolean of {is this a constant initializer?}
false: (iTree: tokenPtr);
false: (
iType: typePtr; {type being initialized}
iTree: tokenPtr; {initializer expression}
);
true : ( {Note: qVal.lo must overlap iVal}
case basetype: baseTypeEnum of
cgByte,

View File

@ -2348,6 +2348,7 @@ var
end; {else}
iPtr^.isConstant := false;
iPtr^.iTree := initializerTree;
iPtr^.iType := tp;
iPtr^.bitdisp := bitdisp;
iPtr^.bitsize := bitsize;
end; {else}
@ -2465,6 +2466,7 @@ var
tk^.token.class := intConstant;
tk^.token.ival := 0;
iPtr^.iTree := tk;
iPtr^.iType := tp;
end; {else}
if count < 16384 then begin
iPtr^.count := long(count).lsw;
@ -2562,6 +2564,7 @@ var
iPtr^.isConstant := false;
new(ep);
iPtr^.iTree := ep;
iPtr^.iType := tp;
ep^.next := nil;
ep^.left := nil;
ep^.middle := nil;
@ -4520,6 +4523,10 @@ var
case itype^.kind of
scalarType,pointerType,enumType,functionType: begin
if not CompTypes(itype, iptr^.itype) then begin
writeln('Incompatible initializer type');
Error(57);
end; {debug}
tree := iptr^.itree;
if tree = nil then goto 2; {don't generate code in error case}
LoadAddress; {load the destination address}