Fix to make _Generic handle struct types properly.

Also, use an existing error message instead of creating a new equivalent one.
This commit is contained in:
Stephen Heumann 2021-03-07 23:35:12 -06:00
parent bccd86a627
commit 2de8ac993e
2 changed files with 8 additions and 2 deletions

View File

@ -1892,6 +1892,13 @@ var
controllingType.kind := pointerType;
controllingType.pType := expressionType;
end {if}
else if expressionType^.kind in [structType,unionType] then begin
controllingType.size := expressionType^.size;
controllingType.saveDisp := 0;
controllingType.isConstant := false;
controllingType.kind := definedType;
controllingType.dType := expressionType;
end {else if}
else
controllingType := expressionType^;
if controllingType.kind = arrayType then
@ -1910,7 +1917,7 @@ var
TypeName; {get the type name}
currentType := typeSpec;
if (currentType^.size = 0) or (currentType^.kind = functionType) then
Error(161);
Error(133);
tl := typesSeen; {check if it is a duplicate}
while tl <> nil do begin
if CompTypes(currentType, tl^.theType) then begin

View File

@ -699,7 +699,6 @@ if list or (numErr <> 0) then begin
158: msg := @'_Generic expression includes two compatible types';
159: msg := @'_Generic expression includes multiple default cases';
160: msg := @'no matching association in _Generic expression';
161: msg := @'complete object type expected';
otherwise: Error(57);
end; {case}
writeln(msg^);